i18ntk 2.1.0 → 2.3.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/README.md +87 -50
- package/main/i18ntk-analyze.js +63 -63
- package/main/i18ntk-backup-class.js +37 -41
- package/main/i18ntk-backup.js +28 -30
- package/main/i18ntk-complete.js +75 -74
- package/main/i18ntk-doctor.js +7 -6
- package/main/i18ntk-fixer.js +3 -3
- package/main/i18ntk-init.js +49 -13
- package/main/i18ntk-scanner.js +2 -2
- package/main/i18ntk-sizing.js +36 -37
- package/main/i18ntk-summary.js +4 -4
- package/main/i18ntk-ui.js +95 -96
- package/main/i18ntk-usage.js +31 -19
- package/main/i18ntk-validate.js +78 -27
- package/main/manage/commands/AnalyzeCommand.js +71 -73
- package/main/manage/commands/CommandRouter.js +15 -12
- package/main/manage/commands/FixerCommand.js +94 -38
- package/main/manage/commands/ScannerCommand.js +2 -2
- package/main/manage/commands/ValidateCommand.js +87 -36
- package/main/manage/index.js +165 -152
- package/main/manage/managers/DebugMenu.js +6 -6
- package/main/manage/managers/InteractiveMenu.js +6 -6
- package/main/manage/managers/LanguageMenu.js +12 -6
- package/main/manage/managers/SettingsMenu.js +6 -6
- package/main/manage/services/AuthenticationService.js +5 -6
- package/main/manage/services/ConfigurationService.js +22 -34
- package/main/manage/services/FileManagementService.js +6 -6
- package/main/manage/services/InitService.js +44 -8
- package/main/manage/services/UsageService.js +24 -12
- package/package.json +21 -42
- package/settings/settings-cli.js +5 -5
- package/settings/settings-manager.js +984 -968
- package/ui-locales/de.json +12 -11
- package/ui-locales/en.json +12 -11
- package/ui-locales/es.json +12 -11
- package/ui-locales/fr.json +12 -11
- package/ui-locales/ja.json +12 -11
- package/ui-locales/ru.json +12 -11
- package/ui-locales/zh.json +12 -11
- package/utils/config-helper.js +27 -16
- package/utils/config-manager.js +8 -7
- package/utils/i18n-helper.js +161 -166
- package/utils/init-helper.js +3 -2
- package/utils/json-output.js +11 -10
- package/{scripts → utils}/locale-optimizer.js +61 -60
- package/utils/logger.js +4 -4
- package/utils/safe-json.js +3 -3
- package/utils/secure-backup.js +8 -7
- package/utils/setup-enforcer.js +63 -98
- package/main/i18ntk-go.js +0 -283
- package/main/i18ntk-java.js +0 -380
- package/main/i18ntk-js.js +0 -512
- package/main/i18ntk-manage.js +0 -1694
- package/main/i18ntk-php.js +0 -462
- package/main/i18ntk-py.js +0 -379
- package/main/i18ntk-settings.js +0 -23
- package/main/manage/index-fixed.js +0 -1447
- package/scripts/build-lite.js +0 -279
- package/scripts/deprecate-versions.js +0 -317
- package/scripts/export-translations.js +0 -84
- package/scripts/fix-all-i18n.js +0 -236
- package/scripts/fix-and-purify-i18n.js +0 -233
- package/scripts/fix-locale-control-chars.js +0 -110
- package/scripts/lint-locales.js +0 -80
- package/scripts/prepublish-dev.js +0 -221
- package/scripts/prepublish.js +0 -362
- package/scripts/security-check.js +0 -117
- package/scripts/sync-translations.js +0 -151
- package/scripts/sync-ui-locales.js +0 -20
- package/scripts/validate-all-translations.js +0 -195
- package/scripts/verify-deprecations.js +0 -157
- package/scripts/verify-translations.js +0 -63
- package/utils/security-fixed.js +0 -609
|
@@ -11,16 +11,17 @@ const fs = require('fs');
|
|
|
11
11
|
const path = require('path');
|
|
12
12
|
const { loadTranslations, t } = require('../../../utils/i18n-helper');
|
|
13
13
|
const configManager = require('../../../utils/config-manager');
|
|
14
|
-
const SecurityUtils = require('../../../utils/security');
|
|
15
|
-
const AdminCLI = require('../../../utils/admin-cli');
|
|
16
|
-
const
|
|
17
|
-
const
|
|
18
|
-
const {
|
|
19
|
-
const
|
|
20
|
-
const
|
|
21
|
-
const
|
|
22
|
-
|
|
23
|
-
|
|
14
|
+
const SecurityUtils = require('../../../utils/security');
|
|
15
|
+
const AdminCLI = require('../../../utils/admin-cli');
|
|
16
|
+
const AdminAuth = require('../../../utils/admin-auth');
|
|
17
|
+
const watchLocales = require('../../../utils/watch-locales');
|
|
18
|
+
const { getGlobalReadline, closeGlobalReadline } = require('../../../utils/cli');
|
|
19
|
+
const { getUnifiedConfig, parseCommonArgs, displayHelp, validateSourceDir, displayPaths } = require('../../../utils/config-helper');
|
|
20
|
+
const I18nInitializer = require('../../i18ntk-init');
|
|
21
|
+
const JsonOutput = require('../../../utils/json-output');
|
|
22
|
+
const ExitCodes = require('../../../utils/exit-codes');
|
|
23
|
+
|
|
24
|
+
loadTranslations('en', path.resolve(__dirname, '../../../ui-locales'));
|
|
24
25
|
|
|
25
26
|
class ValidateCommand {
|
|
26
27
|
constructor(config = {}, ui = null) {
|
|
@@ -68,7 +69,7 @@ class ValidateCommand {
|
|
|
68
69
|
this.config = { ...baseConfig, ...(this.config || {}) };
|
|
69
70
|
|
|
70
71
|
const uiLanguage = (this.config && this.config.uiLanguage) || 'en';
|
|
71
|
-
loadTranslations(uiLanguage, path.resolve(__dirname, '../../../
|
|
72
|
+
loadTranslations(uiLanguage, path.resolve(__dirname, '../../../ui-locales'));
|
|
72
73
|
|
|
73
74
|
SecurityUtils.logSecurityEvent(
|
|
74
75
|
'I18n validator initializing',
|
|
@@ -166,18 +167,31 @@ class ValidateCommand {
|
|
|
166
167
|
this.warnings.push({ message, details, type: 'warning' });
|
|
167
168
|
}
|
|
168
169
|
|
|
169
|
-
// Get all available languages
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
170
|
+
// Get all available languages
|
|
171
|
+
isExcludedLanguageDirectory(name) {
|
|
172
|
+
if (!name || typeof name !== 'string') return true;
|
|
173
|
+
const lowered = name.toLowerCase();
|
|
174
|
+
return lowered.startsWith('backup-') ||
|
|
175
|
+
lowered === 'backup' ||
|
|
176
|
+
lowered === 'backups' ||
|
|
177
|
+
lowered === 'i18ntk-backups' ||
|
|
178
|
+
lowered === 'reports' ||
|
|
179
|
+
lowered === 'i18ntk-reports';
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
getAvailableLanguages() {
|
|
183
|
+
try {
|
|
184
|
+
if (!SecurityUtils.safeExistsSync(this.sourceDir)) {
|
|
185
|
+
throw new Error(`Source directory not found: ${this.sourceDir}`);
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
const languages = fs.readdirSync(this.sourceDir)
|
|
189
|
+
.filter(item => {
|
|
190
|
+
const itemPath = path.join(this.sourceDir, item);
|
|
191
|
+
return fs.statSync(itemPath).isDirectory() &&
|
|
192
|
+
item !== this.config.sourceLanguage &&
|
|
193
|
+
!this.isExcludedLanguageDirectory(item);
|
|
194
|
+
});
|
|
181
195
|
|
|
182
196
|
return languages;
|
|
183
197
|
} catch (error) {
|
|
@@ -599,9 +613,43 @@ class ValidateCommand {
|
|
|
599
613
|
}
|
|
600
614
|
|
|
601
615
|
// Show help message
|
|
602
|
-
showHelp() {
|
|
603
|
-
console.log(t('validate.help_message'));
|
|
604
|
-
}
|
|
616
|
+
showHelp() {
|
|
617
|
+
console.log(t('validate.help_message'));
|
|
618
|
+
}
|
|
619
|
+
|
|
620
|
+
saveValidationSummaryReport(results = {}, success = true) {
|
|
621
|
+
try {
|
|
622
|
+
const outputDir = path.resolve(this.config.outputDir || './i18ntk-reports');
|
|
623
|
+
SecurityUtils.safeMkdirSync(outputDir, process.cwd(), { recursive: true });
|
|
624
|
+
|
|
625
|
+
const timestamp = new Date().toISOString();
|
|
626
|
+
const safeTimestamp = timestamp.replace(/[:.]/g, '-');
|
|
627
|
+
const reportPath = path.join(outputDir, `validation-summary-${safeTimestamp}.txt`);
|
|
628
|
+
|
|
629
|
+
const lines = [];
|
|
630
|
+
lines.push('I18NTK Validation Summary');
|
|
631
|
+
lines.push('========================');
|
|
632
|
+
lines.push(`Generated: ${timestamp}`);
|
|
633
|
+
lines.push(`Result: ${success ? 'PASS' : 'FAIL'}`);
|
|
634
|
+
lines.push(`Errors: ${this.errors.length}`);
|
|
635
|
+
lines.push(`Warnings: ${this.warnings.length}`);
|
|
636
|
+
lines.push('');
|
|
637
|
+
lines.push('Language Results');
|
|
638
|
+
lines.push('----------------');
|
|
639
|
+
|
|
640
|
+
Object.entries(results).forEach(([language, validation]) => {
|
|
641
|
+
const summary = validation?.summary || {};
|
|
642
|
+
lines.push(
|
|
643
|
+
`${language}: ${summary.percentage || 0}% (${summary.translatedKeys || 0}/${summary.totalKeys || 0})`
|
|
644
|
+
);
|
|
645
|
+
});
|
|
646
|
+
|
|
647
|
+
SecurityUtils.safeWriteFileSync(reportPath, lines.join('\n') + '\n', process.cwd(), 'utf8');
|
|
648
|
+
return reportPath;
|
|
649
|
+
} catch (error) {
|
|
650
|
+
return null;
|
|
651
|
+
}
|
|
652
|
+
}
|
|
605
653
|
|
|
606
654
|
// Main validation process
|
|
607
655
|
async validate() {
|
|
@@ -832,11 +880,16 @@ class ValidateCommand {
|
|
|
832
880
|
console.log(t('validate.considerRunningUsageAnalysis'));
|
|
833
881
|
}
|
|
834
882
|
|
|
835
|
-
// Exit with appropriate code
|
|
836
|
-
const success = !hasErrors && (!hasWarnings || !this.config.strictMode);
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
883
|
+
// Exit with appropriate code
|
|
884
|
+
const success = !hasErrors && (!hasWarnings || !this.config.strictMode);
|
|
885
|
+
const summaryReportPath = this.saveValidationSummaryReport(results, success);
|
|
886
|
+
if (summaryReportPath) {
|
|
887
|
+
console.log('');
|
|
888
|
+
console.log(`📄 Validation summary report saved: ${summaryReportPath}`);
|
|
889
|
+
}
|
|
890
|
+
|
|
891
|
+
return {
|
|
892
|
+
success,
|
|
840
893
|
errors: this.errors.length,
|
|
841
894
|
warnings: this.warnings.length,
|
|
842
895
|
results
|
|
@@ -879,8 +932,7 @@ class ValidateCommand {
|
|
|
879
932
|
// Skip admin authentication when called from menu
|
|
880
933
|
if (!fromMenu) {
|
|
881
934
|
// Check admin authentication for sensitive operations (only when called directly and not in no-prompt mode)
|
|
882
|
-
const
|
|
883
|
-
const adminAuth = new AdminAuth();
|
|
935
|
+
const adminAuth = new AdminAuth();
|
|
884
936
|
await adminAuth.initialize();
|
|
885
937
|
|
|
886
938
|
const isCalledDirectly = require.main === module;
|
|
@@ -888,8 +940,7 @@ class ValidateCommand {
|
|
|
888
940
|
if (isRequired && isCalledDirectly && !args.noPrompt) {
|
|
889
941
|
console.log('\n' + t('adminCli.authRequiredForOperation', { operation: 'validate translations' }));
|
|
890
942
|
|
|
891
|
-
const
|
|
892
|
-
const pin = await cliHelper.promptPin(t('adminCli.enterPin'));
|
|
943
|
+
const pin = await cliHelper.promptPin(t('adminCli.enterPin'));
|
|
893
944
|
|
|
894
945
|
const isValid = await adminAuth.verifyPin(pin);
|
|
895
946
|
this.closeReadline();
|
|
@@ -975,4 +1026,4 @@ class ValidateCommand {
|
|
|
975
1026
|
}
|
|
976
1027
|
}
|
|
977
1028
|
|
|
978
|
-
module.exports = ValidateCommand;
|
|
1029
|
+
module.exports = ValidateCommand;
|