locai 2.1.2 → 2.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.d.ts +2 -0
- package/dist/commands/review.d.ts +109 -0
- package/dist/commands/translator.d.ts +23 -0
- package/dist/config/index.d.ts +145 -0
- package/dist/core/adapters/base-adapter.d.ts +20 -0
- package/dist/core/adapters/factory.d.ts +16 -0
- package/dist/core/adapters/json-adapter.d.ts +9 -0
- package/dist/core/adapters/po-adapter.d.ts +9 -0
- package/dist/core/adapters/properties-adapter.d.ts +9 -0
- package/dist/core/adapters/yaml-adapter.d.ts +9 -0
- package/dist/core/context-processor.d.ts +81 -0
- package/dist/core/detection/framework-detector.d.ts +9 -0
- package/dist/core/detection/structure-detector.d.ts +9 -0
- package/dist/core/fallback-provider.d.ts +54 -0
- package/dist/core/orchestrator.d.ts +101 -0
- package/dist/core/pipeline/Pipeline.d.ts +23 -0
- package/dist/core/pipeline/PipelineStep.d.ts +18 -0
- package/dist/core/pipeline/context.d.ts +29 -0
- package/dist/core/pipeline/steps/CacheReadStep.d.ts +25 -0
- package/dist/core/pipeline/steps/CacheWriteStep.d.ts +11 -0
- package/dist/core/pipeline/steps/ConfidenceCheckStep.d.ts +10 -0
- package/dist/core/pipeline/steps/GlossaryPostStep.d.ts +9 -0
- package/dist/core/pipeline/steps/GlossaryPreStep.d.ts +9 -0
- package/dist/core/pipeline/steps/InputValidationStep.d.ts +8 -0
- package/dist/core/pipeline/steps/QualityCheckStep.d.ts +10 -0
- package/dist/core/pipeline/steps/ToneCheckStep.d.ts +13 -0
- package/dist/core/pipeline/steps/TranslationStep.d.ts +22 -0
- package/dist/core/pipeline/steps/VectorCacheReadStep.d.ts +17 -0
- package/dist/core/pipeline/steps/VectorCacheWriteStep.d.ts +11 -0
- package/dist/core/pipeline/steps/__tests__/ToneCheckStep.test.d.ts +1 -0
- package/dist/core/provider-factory.d.ts +41 -0
- package/dist/core/provider-factory.js +4 -0
- package/dist/providers/anthropic.d.ts +25 -0
- package/dist/providers/anthropic.js +178 -0
- package/dist/providers/base-provider.d.ts +66 -0
- package/dist/providers/dashscope.d.ts +24 -0
- package/dist/providers/deepseek.d.ts +22 -0
- package/dist/providers/gemini.d.ts +22 -0
- package/dist/providers/gemini.js +3 -3
- package/dist/providers/openai.d.ts +28 -0
- package/dist/providers/openai.js +3 -3
- package/dist/providers/xai.d.ts +22 -0
- package/dist/services/embedding-provider.d.ts +26 -0
- package/dist/services/translation-service.d.ts +138 -0
- package/dist/services/vector-store.d.ts +26 -0
- package/dist/utils/ai-context-analyzer.d.ts +73 -0
- package/dist/utils/confidence-scorer.d.ts +77 -0
- package/dist/utils/error-helper.d.ts +87 -0
- package/dist/utils/error-helper.js +3 -1
- package/dist/utils/file-manager.d.ts +129 -0
- package/dist/utils/glossary-manager.d.ts +69 -0
- package/dist/utils/graceful-shutdown.d.ts +22 -0
- package/dist/utils/input-validator.d.ts +227 -0
- package/dist/utils/input-validator.js +8 -1
- package/dist/utils/logger.d.ts +134 -0
- package/dist/utils/object-transformer.d.ts +38 -0
- package/dist/utils/progress-tracker.d.ts +63 -0
- package/dist/utils/prompt-templates.d.ts +37 -0
- package/dist/utils/prompt-templates.js +18 -0
- package/dist/utils/quality/__tests__/tone-verifier.test.d.ts +1 -0
- package/dist/utils/quality/base-checker.d.ts +79 -0
- package/dist/utils/quality/code-block-checker.d.ts +64 -0
- package/dist/utils/quality/html-tag-checker.d.ts +33 -0
- package/dist/utils/quality/index.d.ts +39 -0
- package/dist/utils/quality/length-checker.d.ts +70 -0
- package/dist/utils/quality/markdown-checker.d.ts +63 -0
- package/dist/utils/quality/placeholder-checker.d.ts +42 -0
- package/dist/utils/quality/punctuation-checker.d.ts +31 -0
- package/dist/utils/quality/quote-balance-checker.d.ts +37 -0
- package/dist/utils/quality/special-characters-checker.d.ts +66 -0
- package/dist/utils/quality/style-guide-checker.d.ts +71 -0
- package/dist/utils/quality/text-sanitizer.d.ts +51 -0
- package/dist/utils/quality/tone-verifier.d.ts +14 -0
- package/dist/utils/rate-limiter.d.ts +73 -0
- package/dist/utils/rate-limiter.js +6 -0
- package/dist/utils/retry-helper.d.ts +49 -0
- package/dist/utils/state-manager.d.ts +62 -0
- package/dist/utils/statistics-manager.d.ts +47 -0
- package/dist/utils/ui-manager.d.ts +21 -0
- package/package.json +13 -5
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Base Quality Checker.
|
|
3
|
+
* Common infrastructure for all quality checkers.
|
|
4
|
+
*/
|
|
5
|
+
export interface CheckerOptions {
|
|
6
|
+
placeholderConsistency?: boolean;
|
|
7
|
+
htmlTagsConsistency?: boolean;
|
|
8
|
+
punctuationCheck?: boolean;
|
|
9
|
+
lengthValidation?: boolean;
|
|
10
|
+
sanitizeOutput?: boolean;
|
|
11
|
+
rules?: Record<string, any>;
|
|
12
|
+
styleGuide?: {
|
|
13
|
+
formality?: string;
|
|
14
|
+
toneOfVoice?: string;
|
|
15
|
+
};
|
|
16
|
+
context?: Record<string, any>;
|
|
17
|
+
[key: string]: any;
|
|
18
|
+
}
|
|
19
|
+
export interface Issue {
|
|
20
|
+
type: string;
|
|
21
|
+
message: string;
|
|
22
|
+
timestamp: string;
|
|
23
|
+
[key: string]: any;
|
|
24
|
+
}
|
|
25
|
+
export interface Fix {
|
|
26
|
+
type: string;
|
|
27
|
+
message: string;
|
|
28
|
+
timestamp: string;
|
|
29
|
+
[key: string]: any;
|
|
30
|
+
}
|
|
31
|
+
export interface ValidationResult {
|
|
32
|
+
isValid: boolean;
|
|
33
|
+
issues: Issue[];
|
|
34
|
+
source?: string;
|
|
35
|
+
translated?: string;
|
|
36
|
+
context?: Record<string, any>;
|
|
37
|
+
}
|
|
38
|
+
export interface FixResult {
|
|
39
|
+
originalText: string;
|
|
40
|
+
fixedText: string;
|
|
41
|
+
isModified: boolean;
|
|
42
|
+
issues: Issue[];
|
|
43
|
+
fixes: Fix[];
|
|
44
|
+
metadata?: {
|
|
45
|
+
sourceLength: number;
|
|
46
|
+
originalLength: number;
|
|
47
|
+
fixedLength: number;
|
|
48
|
+
timestamp: string;
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
declare class BaseChecker {
|
|
52
|
+
protected rules: Record<string, boolean | any>;
|
|
53
|
+
protected styleGuide: {
|
|
54
|
+
formality: string;
|
|
55
|
+
toneOfVoice: string;
|
|
56
|
+
};
|
|
57
|
+
/**
|
|
58
|
+
* Create a new BaseChecker.
|
|
59
|
+
* @param {CheckerOptions} [options={}] - Configuration options.
|
|
60
|
+
*/
|
|
61
|
+
constructor(options?: CheckerOptions);
|
|
62
|
+
/**
|
|
63
|
+
* Create an issue object.
|
|
64
|
+
*/
|
|
65
|
+
createIssue(type: string, message: string, details?: Record<string, any>): Issue;
|
|
66
|
+
/**
|
|
67
|
+
* Create a fix object.
|
|
68
|
+
*/
|
|
69
|
+
createFix(type: string, message: string, details?: Record<string, any>): Fix;
|
|
70
|
+
/**
|
|
71
|
+
* Validate translation.
|
|
72
|
+
*/
|
|
73
|
+
validate(_sourceText: string, _translatedText: string, _options?: any): ValidationResult;
|
|
74
|
+
/**
|
|
75
|
+
* Validate and fix translation.
|
|
76
|
+
*/
|
|
77
|
+
validateAndFix(sourceText: string, translatedText: string): FixResult;
|
|
78
|
+
}
|
|
79
|
+
export default BaseChecker;
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
export interface CodeBlockIssue {
|
|
2
|
+
type: "code-block-count" | "code-block-modified" | "code-block-restore";
|
|
3
|
+
severity: "error" | "critical";
|
|
4
|
+
message: string;
|
|
5
|
+
details?: any;
|
|
6
|
+
}
|
|
7
|
+
export interface CodeBlockFixResult {
|
|
8
|
+
text: string;
|
|
9
|
+
foundIssues: CodeBlockIssue[];
|
|
10
|
+
appliedFixes: {
|
|
11
|
+
type: "code-block-restore";
|
|
12
|
+
message: string;
|
|
13
|
+
}[];
|
|
14
|
+
}
|
|
15
|
+
export interface CodeBlock {
|
|
16
|
+
type: "fenced" | "inline" | "html-code" | "html-pre";
|
|
17
|
+
full: string;
|
|
18
|
+
code: string;
|
|
19
|
+
position: number;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Code Block Preservation Checker.
|
|
23
|
+
* Ensures code blocks are preserved exactly during translation.
|
|
24
|
+
*/
|
|
25
|
+
declare class CodeBlockChecker {
|
|
26
|
+
private codePatterns;
|
|
27
|
+
constructor();
|
|
28
|
+
/**
|
|
29
|
+
* Check if code blocks are preserved.
|
|
30
|
+
*/
|
|
31
|
+
checkCodeBlockPreservation(sourceText: string, translatedText: string): CodeBlockIssue[];
|
|
32
|
+
/**
|
|
33
|
+
* Extract all code blocks from text.
|
|
34
|
+
*/
|
|
35
|
+
extractCodeBlocks(text: string): CodeBlock[];
|
|
36
|
+
/**
|
|
37
|
+
* Fix code block preservation issues.
|
|
38
|
+
*/
|
|
39
|
+
fixCodeBlockPreservation(sourceText: string, translatedText: string): CodeBlockFixResult;
|
|
40
|
+
/**
|
|
41
|
+
* Restore missing code blocks from source.
|
|
42
|
+
*/
|
|
43
|
+
restoreCodeBlocks(sourceText: string, translatedText: string, sourceCodeBlocks: CodeBlock[]): {
|
|
44
|
+
text: string;
|
|
45
|
+
appliedFixes: any[];
|
|
46
|
+
};
|
|
47
|
+
/**
|
|
48
|
+
* Protect code blocks before translation.
|
|
49
|
+
* Replaces code blocks with tokens to prevent translation.
|
|
50
|
+
*/
|
|
51
|
+
protectCodeBlocks(text: string): {
|
|
52
|
+
protectedText: string;
|
|
53
|
+
tokenMap: Map<string, string>;
|
|
54
|
+
};
|
|
55
|
+
/**
|
|
56
|
+
* Restore code blocks after translation.
|
|
57
|
+
*/
|
|
58
|
+
restoreCodeBlocksFromTokens(text: string, tokenMap: Map<string, string>): string;
|
|
59
|
+
/**
|
|
60
|
+
* Check if text contains code blocks.
|
|
61
|
+
*/
|
|
62
|
+
hasCodeBlocks(text: string): boolean;
|
|
63
|
+
}
|
|
64
|
+
export default CodeBlockChecker;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
export interface HtmlTagIssue {
|
|
2
|
+
type: "htmlTag";
|
|
3
|
+
message: string;
|
|
4
|
+
source?: string[];
|
|
5
|
+
translated?: string[];
|
|
6
|
+
}
|
|
7
|
+
export interface HtmlTagFixResult {
|
|
8
|
+
text: string;
|
|
9
|
+
foundIssues: HtmlTagIssue[];
|
|
10
|
+
appliedFixes: {
|
|
11
|
+
type: "htmlTag";
|
|
12
|
+
message: string;
|
|
13
|
+
}[];
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* HTML Tag Consistency Checker.
|
|
17
|
+
* Ensures HTML tags are preserved and correctly nested in translations.
|
|
18
|
+
*/
|
|
19
|
+
declare class HtmlTagChecker {
|
|
20
|
+
/**
|
|
21
|
+
* Check for HTML tag mismatches between source and translation.
|
|
22
|
+
*/
|
|
23
|
+
checkHtmlTags(source: string, translated: string): HtmlTagIssue[];
|
|
24
|
+
/**
|
|
25
|
+
* Fix missing HTML tags in translated text.
|
|
26
|
+
*/
|
|
27
|
+
fixHtmlTags(source: string, translated: string): HtmlTagFixResult;
|
|
28
|
+
/**
|
|
29
|
+
* Insert HTML tag into text.
|
|
30
|
+
*/
|
|
31
|
+
insertHtmlTag(text: string, tag: string): string;
|
|
32
|
+
}
|
|
33
|
+
export default HtmlTagChecker;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import BaseChecker, { CheckerOptions, FixResult, ValidationResult } from "./base-checker.js";
|
|
2
|
+
/**
|
|
3
|
+
* Main Quality Checker Class.
|
|
4
|
+
* Orchestrates various quality checks and fixes for translated text.
|
|
5
|
+
*/
|
|
6
|
+
declare class QualityChecker extends BaseChecker {
|
|
7
|
+
private placeholderChecker;
|
|
8
|
+
private htmlTagChecker;
|
|
9
|
+
private punctuationChecker;
|
|
10
|
+
private lengthChecker;
|
|
11
|
+
private textSanitizer;
|
|
12
|
+
private quoteBalanceChecker;
|
|
13
|
+
private styleGuideChecker;
|
|
14
|
+
private markdownChecker;
|
|
15
|
+
private codeBlockChecker;
|
|
16
|
+
private specialCharactersChecker;
|
|
17
|
+
private context;
|
|
18
|
+
/**
|
|
19
|
+
* Initialize QualityChecker with options.
|
|
20
|
+
*/
|
|
21
|
+
constructor(options?: CheckerOptions);
|
|
22
|
+
/**
|
|
23
|
+
* Initialize all individual checkers.
|
|
24
|
+
*/
|
|
25
|
+
initializeCheckers(): void;
|
|
26
|
+
/**
|
|
27
|
+
* Validate translated text against source text.
|
|
28
|
+
*/
|
|
29
|
+
validate(sourceText: string, translatedText: string, options?: Record<string, any>): ValidationResult;
|
|
30
|
+
/**
|
|
31
|
+
* Validate and attempt to fix translated text.
|
|
32
|
+
*/
|
|
33
|
+
validateAndFix(sourceText: string, translatedText: string): FixResult;
|
|
34
|
+
/**
|
|
35
|
+
* Sanitize translated text using multiple passes.
|
|
36
|
+
*/
|
|
37
|
+
sanitizeTranslation(text: string): string;
|
|
38
|
+
}
|
|
39
|
+
export default QualityChecker;
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
export interface LengthConfig {
|
|
2
|
+
mode: "strict" | "flexible" | "exact" | "relaxed" | "smart";
|
|
3
|
+
maxDeviation: number;
|
|
4
|
+
minDeviation: number;
|
|
5
|
+
targetLang?: string;
|
|
6
|
+
context?: string;
|
|
7
|
+
}
|
|
8
|
+
export interface LengthIssue {
|
|
9
|
+
type: "length";
|
|
10
|
+
severity: "critical" | "warning" | "error";
|
|
11
|
+
message: string;
|
|
12
|
+
details: {
|
|
13
|
+
mode?: string;
|
|
14
|
+
context?: string;
|
|
15
|
+
targetLang?: string;
|
|
16
|
+
sourceLength?: number;
|
|
17
|
+
translatedLength?: number;
|
|
18
|
+
ratio?: number;
|
|
19
|
+
allowedRange?: {
|
|
20
|
+
min: number;
|
|
21
|
+
max: number;
|
|
22
|
+
};
|
|
23
|
+
deviation?: number;
|
|
24
|
+
error?: string;
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Length Validation Checker.
|
|
29
|
+
* Checks if translated text length is within acceptable bounds relative to source text.
|
|
30
|
+
*/
|
|
31
|
+
declare class LengthChecker {
|
|
32
|
+
private defaultConfig;
|
|
33
|
+
constructor();
|
|
34
|
+
/**
|
|
35
|
+
* Check if translated text length is acceptable.
|
|
36
|
+
*/
|
|
37
|
+
checkLength(source: string, translated: string, options?: any): LengthIssue[];
|
|
38
|
+
/**
|
|
39
|
+
* Calculate length of text ignoring whitespace.
|
|
40
|
+
*/
|
|
41
|
+
calculateLength(text: string): number;
|
|
42
|
+
/**
|
|
43
|
+
* Get configuration for length check.
|
|
44
|
+
*/
|
|
45
|
+
getConfig(options: any): LengthConfig;
|
|
46
|
+
/**
|
|
47
|
+
* Get configuration for smart mode.
|
|
48
|
+
*/
|
|
49
|
+
getSmartModeConfig(lengthControl: any, targetLang: string, context: string): LengthConfig;
|
|
50
|
+
/**
|
|
51
|
+
* Get configuration for standard mode.
|
|
52
|
+
*/
|
|
53
|
+
getStandardModeConfig(lengthControl: any, mode: any, targetLang: string, context: string): LengthConfig;
|
|
54
|
+
/**
|
|
55
|
+
* Calculate allowed length ratio range.
|
|
56
|
+
*/
|
|
57
|
+
calculateAllowedRange(config: LengthConfig): {
|
|
58
|
+
minRatio: number;
|
|
59
|
+
maxRatio: number;
|
|
60
|
+
};
|
|
61
|
+
/**
|
|
62
|
+
* Determine severity of length mismatch.
|
|
63
|
+
*/
|
|
64
|
+
determineSeverity(ratio: number, minRatio: number, maxRatio: number): "critical" | "warning";
|
|
65
|
+
/**
|
|
66
|
+
* Generate error message for length mismatch.
|
|
67
|
+
*/
|
|
68
|
+
generateErrorMessage(ratio: number, config: LengthConfig): string;
|
|
69
|
+
}
|
|
70
|
+
export default LengthChecker;
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
export interface MarkdownIssue {
|
|
2
|
+
type: "markdown-preservation" | "markdown-link" | "markdown-missing";
|
|
3
|
+
severity: "error" | "warning" | "critical";
|
|
4
|
+
message: string;
|
|
5
|
+
pattern?: string;
|
|
6
|
+
details?: any;
|
|
7
|
+
}
|
|
8
|
+
export interface MarkdownFixResult {
|
|
9
|
+
text: string;
|
|
10
|
+
foundIssues: MarkdownIssue[];
|
|
11
|
+
appliedFixes: {
|
|
12
|
+
type: "markdown-link";
|
|
13
|
+
message: string;
|
|
14
|
+
}[];
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Markdown Preservation Checker.
|
|
18
|
+
* Ensures markdown formatting is preserved during translation.
|
|
19
|
+
*/
|
|
20
|
+
declare class MarkdownChecker {
|
|
21
|
+
private markdownPatterns;
|
|
22
|
+
constructor();
|
|
23
|
+
/**
|
|
24
|
+
* Check if markdown is preserved between source and translation.
|
|
25
|
+
*/
|
|
26
|
+
checkMarkdownPreservation(sourceText: string, translatedText: string): MarkdownIssue[];
|
|
27
|
+
/**
|
|
28
|
+
* Check for broken markdown links.
|
|
29
|
+
*/
|
|
30
|
+
checkBrokenMarkdownLinks(text: string): MarkdownIssue[];
|
|
31
|
+
/**
|
|
32
|
+
* Fix markdown preservation issues.
|
|
33
|
+
*/
|
|
34
|
+
fixMarkdownPreservation(sourceText: string, translatedText: string): MarkdownFixResult;
|
|
35
|
+
/**
|
|
36
|
+
* Extract markdown elements from text.
|
|
37
|
+
*/
|
|
38
|
+
extractMarkdownElements(text: string): Record<string, any[]>;
|
|
39
|
+
/**
|
|
40
|
+
* Restore markdown elements that were lost in translation.
|
|
41
|
+
*/
|
|
42
|
+
restoreMarkdownElements(text: string, elements: any[], type: string): {
|
|
43
|
+
text: string;
|
|
44
|
+
foundIssues: MarkdownIssue[];
|
|
45
|
+
appliedFixes: any[];
|
|
46
|
+
};
|
|
47
|
+
/**
|
|
48
|
+
* Fix broken markdown links.
|
|
49
|
+
*/
|
|
50
|
+
fixBrokenLinks(text: string): {
|
|
51
|
+
text: string;
|
|
52
|
+
foundIssues: MarkdownIssue[];
|
|
53
|
+
appliedFixes: {
|
|
54
|
+
type: "markdown-link";
|
|
55
|
+
message: string;
|
|
56
|
+
}[];
|
|
57
|
+
};
|
|
58
|
+
/**
|
|
59
|
+
* Check if text contains markdown.
|
|
60
|
+
*/
|
|
61
|
+
hasMarkdown(text: string): boolean;
|
|
62
|
+
}
|
|
63
|
+
export default MarkdownChecker;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
export interface PlaceholderIssue {
|
|
2
|
+
type: "placeholder";
|
|
3
|
+
message: string;
|
|
4
|
+
source?: string[] | string;
|
|
5
|
+
translated?: string[] | string;
|
|
6
|
+
corrupted?: string;
|
|
7
|
+
}
|
|
8
|
+
export interface PlaceholderFixResult {
|
|
9
|
+
text: string;
|
|
10
|
+
foundIssues: PlaceholderIssue[];
|
|
11
|
+
appliedFixes: {
|
|
12
|
+
type: "placeholder";
|
|
13
|
+
message: string;
|
|
14
|
+
}[];
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Placeholder Consistency Checker.
|
|
18
|
+
* Ensures placeholders like {name}, ${value}, %s are preserved correctly.
|
|
19
|
+
*/
|
|
20
|
+
declare class PlaceholderChecker {
|
|
21
|
+
/**
|
|
22
|
+
* Check for placeholder mismatches or corruptions.
|
|
23
|
+
*/
|
|
24
|
+
checkPlaceholders(source: string, translated: string): PlaceholderIssue[];
|
|
25
|
+
/**
|
|
26
|
+
* Fix corrupted or missing placeholders in translated text.
|
|
27
|
+
*/
|
|
28
|
+
fixPlaceholders(source: string, translated: string): PlaceholderFixResult;
|
|
29
|
+
/**
|
|
30
|
+
* Find a corrupted version of a placeholder in translated text.
|
|
31
|
+
*/
|
|
32
|
+
findCorruptedPlaceholder(translated: string, sourcePlaceholder: string): string | null;
|
|
33
|
+
/**
|
|
34
|
+
* Find best position to insert a missing placeholder.
|
|
35
|
+
*/
|
|
36
|
+
findBestPlaceholderPosition(translated: string, source: string, placeholder: string): number;
|
|
37
|
+
/**
|
|
38
|
+
* Insert placeholder into text at specified position.
|
|
39
|
+
*/
|
|
40
|
+
insertPlaceholder(text: string, placeholder: string, position: number): string;
|
|
41
|
+
}
|
|
42
|
+
export default PlaceholderChecker;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
export interface PunctuationIssue {
|
|
2
|
+
type: "punctuation";
|
|
3
|
+
message: string;
|
|
4
|
+
}
|
|
5
|
+
export interface PunctuationFixResult {
|
|
6
|
+
text: string;
|
|
7
|
+
foundIssues: PunctuationIssue[];
|
|
8
|
+
appliedFixes: {
|
|
9
|
+
type: "punctuation";
|
|
10
|
+
message: string;
|
|
11
|
+
}[];
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Punctuation Consistency Checker.
|
|
15
|
+
* Ensures end punctuation marks are preserved in translation.
|
|
16
|
+
*/
|
|
17
|
+
declare class PunctuationChecker {
|
|
18
|
+
/**
|
|
19
|
+
* Check for punctuation mismatches.
|
|
20
|
+
*/
|
|
21
|
+
checkPunctuation(source: string, translated: string): PunctuationIssue[];
|
|
22
|
+
/**
|
|
23
|
+
* Fix missing punctuation marks.
|
|
24
|
+
*/
|
|
25
|
+
fixPunctuation(source: string, translated: string): PunctuationFixResult;
|
|
26
|
+
/**
|
|
27
|
+
* Add punctuation to the end of text.
|
|
28
|
+
*/
|
|
29
|
+
addPunctuation(text: string, punctuation: string): string;
|
|
30
|
+
}
|
|
31
|
+
export default PunctuationChecker;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
export interface QuoteIssue {
|
|
2
|
+
type: "unbalanced-quotes" | "quote-consistency" | "quote-balance";
|
|
3
|
+
severity: "error" | "warning";
|
|
4
|
+
message: string;
|
|
5
|
+
char?: string;
|
|
6
|
+
}
|
|
7
|
+
export interface QuoteFixResult {
|
|
8
|
+
text: string;
|
|
9
|
+
foundIssues: QuoteIssue[];
|
|
10
|
+
appliedFixes: {
|
|
11
|
+
type: "quote-balance";
|
|
12
|
+
message: string;
|
|
13
|
+
}[];
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Quote Balance Checker.
|
|
17
|
+
* Ensures quotes (single, double, guillemets, etc.) are balanced in translation.
|
|
18
|
+
*/
|
|
19
|
+
declare class QuoteBalanceChecker {
|
|
20
|
+
/**
|
|
21
|
+
* Check for unbalanced quotes.
|
|
22
|
+
*/
|
|
23
|
+
checkQuoteBalance(text: string): QuoteIssue[];
|
|
24
|
+
/**
|
|
25
|
+
* Count occurrences of a quote character.
|
|
26
|
+
*/
|
|
27
|
+
private _countQuotes;
|
|
28
|
+
/**
|
|
29
|
+
* Fix unbalanced quotes.
|
|
30
|
+
*/
|
|
31
|
+
fixQuoteBalance(text: string): QuoteFixResult;
|
|
32
|
+
/**
|
|
33
|
+
* Validate that quotes in source and translation match in pattern.
|
|
34
|
+
*/
|
|
35
|
+
validateQuoteConsistency(source: string, translated: string): QuoteIssue[];
|
|
36
|
+
}
|
|
37
|
+
export default QuoteBalanceChecker;
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
export interface SpecialCharIssue {
|
|
2
|
+
type: "special-characters" | "special-character-substitution" | "emoji-preservation" | "missing-special-chars" | "character-substitution";
|
|
3
|
+
category?: string;
|
|
4
|
+
severity: "error" | "warning";
|
|
5
|
+
message: string;
|
|
6
|
+
details?: any;
|
|
7
|
+
}
|
|
8
|
+
export interface SpecialCharFixResult {
|
|
9
|
+
text: string;
|
|
10
|
+
foundIssues: SpecialCharIssue[];
|
|
11
|
+
appliedFixes: {
|
|
12
|
+
type: "critical-char-restore" | "character-substitution";
|
|
13
|
+
message: string;
|
|
14
|
+
}[];
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Special Characters Preservation Checker.
|
|
18
|
+
* Ensures special characters, symbols, and formatting are preserved.
|
|
19
|
+
*/
|
|
20
|
+
declare class SpecialCharactersChecker {
|
|
21
|
+
private specialCharacterSets;
|
|
22
|
+
private criticalCharacters;
|
|
23
|
+
constructor();
|
|
24
|
+
/**
|
|
25
|
+
* Check if special characters are preserved.
|
|
26
|
+
*/
|
|
27
|
+
checkSpecialCharacters(sourceText: string, translatedText: string): SpecialCharIssue[];
|
|
28
|
+
/**
|
|
29
|
+
* Check emoji preservation.
|
|
30
|
+
*/
|
|
31
|
+
checkEmojiPreservation(sourceText: string, translatedText: string): SpecialCharIssue[];
|
|
32
|
+
/**
|
|
33
|
+
* Fix special character issues.
|
|
34
|
+
*/
|
|
35
|
+
fixSpecialCharacters(sourceText: string, translatedText: string): SpecialCharFixResult;
|
|
36
|
+
/**
|
|
37
|
+
* Extract special characters by category.
|
|
38
|
+
*/
|
|
39
|
+
extractSpecialCharacters(text: string): Record<string, string[]>;
|
|
40
|
+
/**
|
|
41
|
+
* Restore critical characters that were lost.
|
|
42
|
+
*/
|
|
43
|
+
restoreCriticalCharacters(sourceText: string, translatedText: string, missingChars: string[]): {
|
|
44
|
+
text: string;
|
|
45
|
+
appliedFixes: {
|
|
46
|
+
type: "critical-char-restore";
|
|
47
|
+
message: string;
|
|
48
|
+
}[];
|
|
49
|
+
};
|
|
50
|
+
/**
|
|
51
|
+
* Fix common character substitutions.
|
|
52
|
+
*/
|
|
53
|
+
fixCommonSubstitutions(sourceText: string, translatedText: string): {
|
|
54
|
+
text: string;
|
|
55
|
+
foundIssues: SpecialCharIssue[];
|
|
56
|
+
appliedFixes: {
|
|
57
|
+
type: "character-substitution";
|
|
58
|
+
message: string;
|
|
59
|
+
}[];
|
|
60
|
+
};
|
|
61
|
+
/**
|
|
62
|
+
* Check if text has special characters.
|
|
63
|
+
*/
|
|
64
|
+
hasSpecialCharacters(text: string): boolean;
|
|
65
|
+
}
|
|
66
|
+
export default SpecialCharactersChecker;
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { ProviderConfig } from "../../providers/base-provider.js";
|
|
2
|
+
export interface StyleGuideConfig {
|
|
3
|
+
formality?: string;
|
|
4
|
+
toneOfVoice?: string;
|
|
5
|
+
toneProvider?: string;
|
|
6
|
+
analysisOptions?: ProviderConfig;
|
|
7
|
+
enforceTone?: boolean;
|
|
8
|
+
conventions?: {
|
|
9
|
+
useOxfordComma?: boolean;
|
|
10
|
+
useSentenceCase?: boolean;
|
|
11
|
+
[key: string]: any;
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
export interface StyleIssue {
|
|
15
|
+
type: "oxford-comma" | "sentence-case";
|
|
16
|
+
severity: "warning" | "info";
|
|
17
|
+
message: string;
|
|
18
|
+
suggestion?: string;
|
|
19
|
+
}
|
|
20
|
+
export interface StyleFixResult {
|
|
21
|
+
text: string;
|
|
22
|
+
foundIssues: StyleIssue[];
|
|
23
|
+
appliedFixes: {
|
|
24
|
+
type: "oxford-comma" | "sentence-case";
|
|
25
|
+
message: string;
|
|
26
|
+
}[];
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Style Guide Checker.
|
|
30
|
+
* Enforces style guide conventions like Oxford comma and sentence case.
|
|
31
|
+
*/
|
|
32
|
+
declare class StyleGuideChecker {
|
|
33
|
+
private styleGuide;
|
|
34
|
+
constructor(styleGuide?: StyleGuideConfig);
|
|
35
|
+
/**
|
|
36
|
+
* Check if text follows style guide conventions.
|
|
37
|
+
*/
|
|
38
|
+
checkStyleGuide(_sourceText: string, translatedText: string): StyleIssue[];
|
|
39
|
+
/**
|
|
40
|
+
* Check for Oxford comma usage in lists.
|
|
41
|
+
*/
|
|
42
|
+
checkOxfordComma(text: string): StyleIssue[];
|
|
43
|
+
/**
|
|
44
|
+
* Check sentence case for headings/titles.
|
|
45
|
+
*/
|
|
46
|
+
checkSentenceCase(text: string): StyleIssue[];
|
|
47
|
+
/**
|
|
48
|
+
* Fix style guide issues.
|
|
49
|
+
*/
|
|
50
|
+
fixStyleGuide(sourceText: string, translatedText: string): StyleFixResult;
|
|
51
|
+
/**
|
|
52
|
+
* Fix missing Oxford commas.
|
|
53
|
+
*/
|
|
54
|
+
fixOxfordComma(text: string): StyleFixResult;
|
|
55
|
+
/**
|
|
56
|
+
* Fix sentence case issues.
|
|
57
|
+
*/
|
|
58
|
+
fixSentenceCase(text: string): {
|
|
59
|
+
text: string;
|
|
60
|
+
foundIssues: StyleIssue[];
|
|
61
|
+
appliedFixes: {
|
|
62
|
+
type: "sentence-case";
|
|
63
|
+
message: string;
|
|
64
|
+
}[];
|
|
65
|
+
};
|
|
66
|
+
/**
|
|
67
|
+
* Convert text to sentence case.
|
|
68
|
+
*/
|
|
69
|
+
convertToSentenceCase(text: string): string;
|
|
70
|
+
}
|
|
71
|
+
export default StyleGuideChecker;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Text Sanitizer.
|
|
3
|
+
* Cleans up translated text by removing AI artifacts, think tags, and unwanted formatting.
|
|
4
|
+
*/
|
|
5
|
+
declare class TextSanitizer {
|
|
6
|
+
/**
|
|
7
|
+
* Sanitize text by applying a sequence of cleaning rules.
|
|
8
|
+
*/
|
|
9
|
+
sanitize(text: string): string;
|
|
10
|
+
/**
|
|
11
|
+
* Apply a list of rules to text.
|
|
12
|
+
*/
|
|
13
|
+
applyRules(text: string, rules: ((text: string) => string)[]): string;
|
|
14
|
+
/**
|
|
15
|
+
* Remove <think> tags and their content.
|
|
16
|
+
*/
|
|
17
|
+
removeThinkTags: (text: string) => string;
|
|
18
|
+
/**
|
|
19
|
+
* Remove bold/italic markdown formatting.
|
|
20
|
+
*/
|
|
21
|
+
removeMarkdownFormatting: (text: string) => string;
|
|
22
|
+
/**
|
|
23
|
+
* Remove leading/trailing quotes.
|
|
24
|
+
*/
|
|
25
|
+
removeQuotes: (text: string) => string;
|
|
26
|
+
/**
|
|
27
|
+
* Remove bullet points at the start.
|
|
28
|
+
*/
|
|
29
|
+
removeBulletPoints: (text: string) => string;
|
|
30
|
+
/**
|
|
31
|
+
* Remove explanatory text and metadata.
|
|
32
|
+
*/
|
|
33
|
+
removeExplanations: (text: string) => string;
|
|
34
|
+
/**
|
|
35
|
+
* Remove common AI conversational artifacts.
|
|
36
|
+
*/
|
|
37
|
+
removeAIArtifacts: (text: string) => string;
|
|
38
|
+
/**
|
|
39
|
+
* Trim special characters from ends.
|
|
40
|
+
*/
|
|
41
|
+
trimSpecialChars: (text: string) => string;
|
|
42
|
+
/**
|
|
43
|
+
* Normalize whitespace and remove duplicate lines.
|
|
44
|
+
*/
|
|
45
|
+
normalizeWhitespace: (text: string) => string;
|
|
46
|
+
/**
|
|
47
|
+
* Aggressive cleanup of all artifacts.
|
|
48
|
+
*/
|
|
49
|
+
removeAllArtifacts: (text: string) => string;
|
|
50
|
+
}
|
|
51
|
+
export default TextSanitizer;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { ProviderConfig } from "../../providers/base-provider.js";
|
|
2
|
+
export interface ToneVerificationResult {
|
|
3
|
+
passed: boolean;
|
|
4
|
+
score: number;
|
|
5
|
+
reasoning: string;
|
|
6
|
+
suggestions?: string;
|
|
7
|
+
}
|
|
8
|
+
export declare class ToneVerifier {
|
|
9
|
+
private provider;
|
|
10
|
+
private initialized;
|
|
11
|
+
constructor();
|
|
12
|
+
private initProvider;
|
|
13
|
+
verify(sourceText: string, translatedText: string, sourceLang: string, targetLang: string, targetTone: string, providerName?: string, options?: ProviderConfig): Promise<ToneVerificationResult>;
|
|
14
|
+
}
|