@umituz/react-native-localization 3.5.44 → 3.5.47

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-localization",
3
- "version": "3.5.44",
3
+ "version": "3.5.47",
4
4
  "description": "Generic localization system for React Native apps with i18n support",
5
5
  "main": "./src/index.ts",
6
6
  "types": "./src/index.ts",
@@ -37,11 +37,24 @@ export class ResourceBuilder {
37
37
 
38
38
  // Merge namespaces for this language
39
39
  if (value && typeof value === 'object') {
40
- for (const [namespace, translations] of Object.entries(value)) {
41
- resources[lang][namespace] = TranslationLoader.mergeTranslations(
42
- resources[lang][namespace] || {},
43
- translations
40
+ const namespaces = Object.keys(value);
41
+ const isFlatMap = namespaces.every(nsKey => typeof value[nsKey] === 'string');
42
+
43
+ if (isFlatMap) {
44
+ // It's a flat map (e.g. { hello: 'Hello' }), wrap in 'common'
45
+ const defaultNs = 'common';
46
+ resources[lang][defaultNs] = TranslationLoader.mergeTranslations(
47
+ resources[lang][defaultNs] || {},
48
+ value
44
49
  );
50
+ } else {
51
+ // It's already namespaced (e.g. { auth: {...} })
52
+ for (const [namespace, translations] of Object.entries(value)) {
53
+ resources[lang][namespace] = TranslationLoader.mergeTranslations(
54
+ resources[lang][namespace] || {},
55
+ translations as Record<string, any>
56
+ );
57
+ }
45
58
  }
46
59
  }
47
60
  } else {
@@ -87,6 +87,10 @@ export const useTranslationFunction = () => {
87
87
  }
88
88
  }
89
89
 
90
+ if (__DEV__ && !translationFound) {
91
+ console.warn(`[Localization] Translation missing for key: "${key}" in language: "${i18n.language}"`);
92
+ }
93
+
90
94
  return finalResult;
91
95
  }, [i18nextT, ready]);
92
96
 
@@ -30,7 +30,7 @@ interface LanguageSelectionScreenProps {
30
30
  clearButton?: any;
31
31
  listContent?: any;
32
32
  };
33
- searchPlaceholder: string;
33
+ searchPlaceholder?: string;
34
34
  testID?: string;
35
35
  }
36
36
 
@@ -39,7 +39,7 @@ export const LanguageSelectionScreen: React.FC<LanguageSelectionScreenProps> = (
39
39
  renderSearchInput,
40
40
  containerComponent: Container,
41
41
  styles: customStyles,
42
- searchPlaceholder,
42
+ searchPlaceholder = "settings.languageSelection.searchPlaceholder",
43
43
  testID = 'language-selection-screen',
44
44
  }) => {
45
45
  const navigation = useNavigation();