fix: increase reformulate word limit to 2000 + i18n error messages
Some checks failed
Deploy to Production / Build and Deploy (push) Failing after 4s
Some checks failed
Deploy to Production / Build and Deploy (push) Failing after 4s
- Raise MAX_WORDS from 500 to 2000 for text reformulation - Error messages now use i18n keys (ai.wordCountMin/Max) instead of hardcoded English strings - Client translates server errors using the user's UI language Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -56,7 +56,7 @@ export const REFACTOR_OPTIONS: RefactorOption[] = [
|
||||
export class ParagraphRefactorService {
|
||||
private languageDetection: LanguageDetectionService
|
||||
private readonly MIN_WORDS = 10
|
||||
private readonly MAX_WORDS = 500
|
||||
private readonly MAX_WORDS = 2000
|
||||
|
||||
constructor() {
|
||||
this.languageDetection = new LanguageDetectionService()
|
||||
@@ -288,20 +288,24 @@ CRITICAL: Respond ONLY with the refactored text in ${language}. No explanations,
|
||||
/**
|
||||
* Validate that text is within acceptable word count range
|
||||
*/
|
||||
validateWordCount(content: string): { valid: boolean; error?: string } {
|
||||
validateWordCount(content: string): { valid: boolean; error?: string; errorKey?: string; params?: Record<string, number> } {
|
||||
const wordCount = content.split(/\s+/).length
|
||||
|
||||
if (wordCount < this.MIN_WORDS) {
|
||||
return {
|
||||
valid: false,
|
||||
error: `Please select at least ${this.MIN_WORDS} words to reformulate (currently ${wordCount} words)`
|
||||
errorKey: 'ai.wordCountMin',
|
||||
params: { min: this.MIN_WORDS, current: wordCount },
|
||||
error: `min:${this.MIN_WORDS}:current:${wordCount}`
|
||||
}
|
||||
}
|
||||
|
||||
if (wordCount > this.MAX_WORDS) {
|
||||
return {
|
||||
valid: false,
|
||||
error: `Please select at most ${this.MAX_WORDS} words to reformulate (currently ${wordCount} words)`
|
||||
errorKey: 'ai.wordCountMax',
|
||||
params: { max: this.MAX_WORDS, current: wordCount },
|
||||
error: `max:${this.MAX_WORDS}:current:${wordCount}`
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user