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.
Files changed (73) hide show
  1. package/README.md +87 -50
  2. package/main/i18ntk-analyze.js +63 -63
  3. package/main/i18ntk-backup-class.js +37 -41
  4. package/main/i18ntk-backup.js +28 -30
  5. package/main/i18ntk-complete.js +75 -74
  6. package/main/i18ntk-doctor.js +7 -6
  7. package/main/i18ntk-fixer.js +3 -3
  8. package/main/i18ntk-init.js +49 -13
  9. package/main/i18ntk-scanner.js +2 -2
  10. package/main/i18ntk-sizing.js +36 -37
  11. package/main/i18ntk-summary.js +4 -4
  12. package/main/i18ntk-ui.js +95 -96
  13. package/main/i18ntk-usage.js +31 -19
  14. package/main/i18ntk-validate.js +78 -27
  15. package/main/manage/commands/AnalyzeCommand.js +71 -73
  16. package/main/manage/commands/CommandRouter.js +15 -12
  17. package/main/manage/commands/FixerCommand.js +94 -38
  18. package/main/manage/commands/ScannerCommand.js +2 -2
  19. package/main/manage/commands/ValidateCommand.js +87 -36
  20. package/main/manage/index.js +165 -152
  21. package/main/manage/managers/DebugMenu.js +6 -6
  22. package/main/manage/managers/InteractiveMenu.js +6 -6
  23. package/main/manage/managers/LanguageMenu.js +12 -6
  24. package/main/manage/managers/SettingsMenu.js +6 -6
  25. package/main/manage/services/AuthenticationService.js +5 -6
  26. package/main/manage/services/ConfigurationService.js +22 -34
  27. package/main/manage/services/FileManagementService.js +6 -6
  28. package/main/manage/services/InitService.js +44 -8
  29. package/main/manage/services/UsageService.js +24 -12
  30. package/package.json +21 -42
  31. package/settings/settings-cli.js +5 -5
  32. package/settings/settings-manager.js +984 -968
  33. package/ui-locales/de.json +12 -11
  34. package/ui-locales/en.json +12 -11
  35. package/ui-locales/es.json +12 -11
  36. package/ui-locales/fr.json +12 -11
  37. package/ui-locales/ja.json +12 -11
  38. package/ui-locales/ru.json +12 -11
  39. package/ui-locales/zh.json +12 -11
  40. package/utils/config-helper.js +27 -16
  41. package/utils/config-manager.js +8 -7
  42. package/utils/i18n-helper.js +161 -166
  43. package/utils/init-helper.js +3 -2
  44. package/utils/json-output.js +11 -10
  45. package/{scripts → utils}/locale-optimizer.js +61 -60
  46. package/utils/logger.js +4 -4
  47. package/utils/safe-json.js +3 -3
  48. package/utils/secure-backup.js +8 -7
  49. package/utils/setup-enforcer.js +63 -98
  50. package/main/i18ntk-go.js +0 -283
  51. package/main/i18ntk-java.js +0 -380
  52. package/main/i18ntk-js.js +0 -512
  53. package/main/i18ntk-manage.js +0 -1694
  54. package/main/i18ntk-php.js +0 -462
  55. package/main/i18ntk-py.js +0 -379
  56. package/main/i18ntk-settings.js +0 -23
  57. package/main/manage/index-fixed.js +0 -1447
  58. package/scripts/build-lite.js +0 -279
  59. package/scripts/deprecate-versions.js +0 -317
  60. package/scripts/export-translations.js +0 -84
  61. package/scripts/fix-all-i18n.js +0 -236
  62. package/scripts/fix-and-purify-i18n.js +0 -233
  63. package/scripts/fix-locale-control-chars.js +0 -110
  64. package/scripts/lint-locales.js +0 -80
  65. package/scripts/prepublish-dev.js +0 -221
  66. package/scripts/prepublish.js +0 -362
  67. package/scripts/security-check.js +0 -117
  68. package/scripts/sync-translations.js +0 -151
  69. package/scripts/sync-ui-locales.js +0 -20
  70. package/scripts/validate-all-translations.js +0 -195
  71. package/scripts/verify-deprecations.js +0 -157
  72. package/scripts/verify-translations.js +0 -63
  73. 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 watchLocales = require('../../../utils/watch-locales');
17
- const { getGlobalReadline, closeGlobalReadline } = require('../../../utils/cli');
18
- const { getUnifiedConfig, parseCommonArgs, displayHelp, validateSourceDir, displayPaths } = require('../../../utils/config-helper');
19
- const I18nInitializer = require('../../i18ntk-init');
20
- const JsonOutput = require('../../../utils/json-output');
21
- const ExitCodes = require('../../../utils/exit-codes');
22
-
23
- loadTranslations('en', path.resolve(__dirname, '../../../resources', 'i18n', 'ui-locales'));
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, '../../../resources', 'i18n', 'ui-locales'));
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
- getAvailableLanguages() {
171
- try {
172
- if (!SecurityUtils.safeExistsSync(this.sourceDir)) {
173
- throw new Error(`Source directory not found: ${this.sourceDir}`);
174
- }
175
-
176
- const languages = fs.readdirSync(this.sourceDir)
177
- .filter(item => {
178
- const itemPath = path.join(this.sourceDir, item);
179
- return fs.statSync(itemPath).isDirectory() && item !== this.config.sourceLanguage;
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
- return {
839
- success,
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 AdminAuth = require('../../../utils/admin-auth');
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 cliHelper = require('../../../utils/cli-helper');
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;