woaru
Version:
Universal Project Setup Autopilot - Analyze and automatically configure development tools for ANY programming language
90 lines • 2.59 kB
TypeScript
/**
* Enhanced Translation Validator
*
* This utility ensures translation keys are consistent across all language files
* and provides comprehensive validation for internationalization requirements.
*/
interface TranslationIssue {
key: string;
issue: 'missing' | 'extra' | 'type_mismatch' | 'empty_value' | 'placeholder_mismatch';
language: string;
details?: string;
severity: 'error' | 'warning' | 'info';
}
interface ValidationOptions {
checkEmptyValues?: boolean;
checkPlaceholders?: boolean;
requiredLanguages?: string[];
baseLanguage?: string;
ignorePaths?: string[];
}
interface ValidationSummary {
totalKeys: number;
totalIssues: number;
errorCount: number;
warningCount: number;
infoCount: number;
languages: string[];
completeness: Record<string, number>;
}
export declare class TranslationValidator {
private localesPath;
private options;
constructor(localesPath?: string, options?: ValidationOptions);
/**
* Validates all translation files for consistency and completeness
*/
validateTranslations(): Promise<TranslationIssue[]>;
/**
* Recursively extract all keys from a translation object
*/
private extractKeys;
/**
* Get value by dot-notation key
*/
private getValueByKey;
/**
* Check for empty or whitespace-only values
*/
private checkEmptyValues;
/**
* Check placeholder consistency between languages
*/
private checkPlaceholderConsistency;
/**
* Extract placeholders from translation object
*/
private extractPlaceholders;
/**
* Check if a key should be ignored based on ignore patterns
*/
private shouldIgnoreKey;
/**
* Generate a comprehensive validation summary
*/
generateSummary(issues: TranslationIssue[]): ValidationSummary;
/**
* Compare specific languages and return detailed comparison
*/
compareLanguages(lang1: string, lang2: string): Promise<{
onlyInLang1: string[];
onlyInLang2: string[];
common: string[];
differences: Array<{
key: string;
lang1Value: unknown;
lang2Value: unknown;
}>;
}>;
/**
* Generate a report of translation issues
*/
generateReport(issues: TranslationIssue[]): string;
/**
* Helper method to add issue type sections to report
*/
private addIssueTypeSection;
}
export declare function validateI18n(): Promise<void>;
export {};
//# sourceMappingURL=translationValidator.d.ts.map