@umituz/react-native-settings 4.23.132 → 4.23.133

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@umituz/react-native-settings",
3
- "version": "4.23.132",
3
+ "version": "4.23.133",
4
4
  "description": "Complete settings hub for React Native apps - consolidated package with settings, localization, about, legal, appearance, feedback, FAQs, rating, and gamification",
5
5
  "main": "./src/index.ts",
6
6
  "types": "./src/index.ts",
@@ -19,6 +19,11 @@ async function translateMissing(targetDir, srcDir) {
19
19
 
20
20
  // Integrated Workflow: Ensure setup and sync
21
21
  const skipSync = process.argv.includes('--no-sync');
22
+ const forceRetranslate = process.argv.includes('--force');
23
+
24
+ if (forceRetranslate) {
25
+ console.log('⚠️ Force re-translation mode enabled. All keys will be re-translated.\n');
26
+ }
22
27
 
23
28
  if (!fs.existsSync(path.join(localesDir, 'index.ts'))) {
24
29
  console.log('🔄 Initializing localization setup...');
@@ -48,28 +53,28 @@ async function translateMissing(targetDir, srcDir) {
48
53
  if (!targetLang || targetLang === 'en') continue;
49
54
 
50
55
  console.log(`🌍 Translating ${langCode} (${langName})...`);
51
-
56
+
52
57
  const targetPath = path.join(localesDir, file);
53
58
  const target = parseTypeScriptFile(targetPath);
54
-
59
+
55
60
  const stats = { count: 0, checked: 0, translatedKeys: [] };
56
- await translateObject(enUS, target, targetLang, '', stats);
57
-
61
+ await translateObject(enUS, target, targetLang, '', stats, { forceRetranslate });
62
+
58
63
  // Clear progress line
59
64
  process.stdout.write('\r' + ' '.repeat(80) + '\r');
60
65
 
61
66
  if (stats.count > 0) {
62
67
  const content = generateTypeScriptContent(target, langCode);
63
68
  fs.writeFileSync(targetPath, content);
64
-
69
+
65
70
  console.log(` ✅ Successfully translated ${stats.count} keys:`);
66
-
71
+
67
72
  // Detailed logging of translated keys
68
73
  const displayCount = Math.min(stats.translatedKeys.length, 15);
69
74
  stats.translatedKeys.slice(0, displayCount).forEach(item => {
70
75
  console.log(` • ${item.key}: "${item.from}" → "${item.to}"`);
71
76
  });
72
-
77
+
73
78
  if (stats.translatedKeys.length > displayCount) {
74
79
  console.log(` ... and ${stats.translatedKeys.length - displayCount} more.`);
75
80
  }
@@ -32,7 +32,7 @@ async function translateText(text, targetLang) {
32
32
  }
33
33
  }
34
34
 
35
- function needsTranslation(value, enValue) {
35
+ function needsTranslation(value, enValue, forceRetranslate = false) {
36
36
  if (typeof enValue !== 'string' || !enValue.trim()) return false;
37
37
  if (shouldSkipWord(enValue)) return false;
38
38
 
@@ -49,13 +49,25 @@ function needsTranslation(value, enValue) {
49
49
  return !isSingleWord;
50
50
  }
51
51
 
52
+ // Force re-translation if flag is set
53
+ if (forceRetranslate) return true;
54
+
55
+ // Detect outdated template patterns (e.g., {{appName}}, {{variable}})
56
+ if (value && typeof value === 'string') {
57
+ const hasTemplatePattern = value.includes('{{') && value.includes('}}');
58
+ if (hasTemplatePattern && !enValue.includes('{{')) {
59
+ return true;
60
+ }
61
+ }
62
+
52
63
  return false;
53
64
  }
54
65
 
55
- export async function translateObject(enObj, targetObj, targetLang, path = '', stats = { count: 0, checked: 0, translatedKeys: [] }) {
66
+ export async function translateObject(enObj, targetObj, targetLang, path = '', stats = { count: 0, checked: 0, translatedKeys: [] }, options = {}) {
56
67
  const keys = Object.keys(enObj);
57
-
68
+
58
69
  if (!stats.translatedKeys) stats.translatedKeys = [];
70
+ const { forceRetranslate = false } = options;
59
71
 
60
72
  for (const key of keys) {
61
73
  const enValue = enObj[key];
@@ -64,13 +76,13 @@ export async function translateObject(enObj, targetObj, targetLang, path = '', s
64
76
 
65
77
  if (typeof enValue === 'object' && enValue !== null) {
66
78
  if (!targetObj[key] || typeof targetObj[key] !== 'object') targetObj[key] = {};
67
- await translateObject(enValue, targetObj[key], targetLang, currentPath, stats);
79
+ await translateObject(enValue, targetObj[key], targetLang, currentPath, stats, options);
68
80
  } else if (typeof enValue === 'string') {
69
81
  stats.checked++;
70
- if (needsTranslation(targetValue, enValue)) {
82
+ if (needsTranslation(targetValue, enValue, forceRetranslate)) {
71
83
  // Show progress for translations
72
84
  process.stdout.write(` \r Progress: ${stats.checked} keys checked, ${stats.count} translated...`);
73
-
85
+
74
86
  const translated = await translateText(enValue, targetLang);
75
87
  if (translated !== enValue) {
76
88
  targetObj[key] = translated;