@umituz/react-native-localization 3.5.44 → 3.5.48
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
|
@@ -38,7 +38,6 @@ export class I18nInitializer {
|
|
|
38
38
|
fallbackLng: DEFAULT_LANGUAGE,
|
|
39
39
|
ns: namespaces,
|
|
40
40
|
defaultNS: defaultNamespace,
|
|
41
|
-
|
|
42
41
|
fallbackNS: defaultNamespace,
|
|
43
42
|
interpolation: { escapeValue: false },
|
|
44
43
|
react: { useSuspense: false },
|
|
@@ -49,6 +48,8 @@ export class I18nInitializer {
|
|
|
49
48
|
saveMissing: false,
|
|
50
49
|
missingKeyHandler: false,
|
|
51
50
|
debug: false,
|
|
51
|
+
returnEmptyString: false,
|
|
52
|
+
returnNull: false,
|
|
52
53
|
});
|
|
53
54
|
} catch {
|
|
54
55
|
// Silent error handling
|
|
@@ -18,10 +18,8 @@ export class ResourceBuilder {
|
|
|
18
18
|
// Initialize with package translations
|
|
19
19
|
const resources: Record<string, Record<string, any>> = { ...packageTranslations };
|
|
20
20
|
|
|
21
|
-
//
|
|
22
|
-
|
|
23
|
-
resources[languageCode] = {};
|
|
24
|
-
}
|
|
21
|
+
// Note: Do NOT create empty resources for unsupported languages
|
|
22
|
+
// i18next will properly fallback to fallbackLng when language not in resources
|
|
25
23
|
|
|
26
24
|
// Process app translations
|
|
27
25
|
for (const [key, value] of Object.entries(appTranslations)) {
|
|
@@ -31,22 +29,36 @@ export class ResourceBuilder {
|
|
|
31
29
|
if (isLanguageKey) {
|
|
32
30
|
// It's a language key (e.g., "en-US")
|
|
33
31
|
const lang = key;
|
|
34
|
-
if (!resources[lang]) {
|
|
35
|
-
resources[lang] = {};
|
|
36
|
-
}
|
|
37
32
|
|
|
38
|
-
//
|
|
39
|
-
if (value && typeof value === 'object') {
|
|
40
|
-
|
|
41
|
-
resources[lang]
|
|
42
|
-
|
|
43
|
-
|
|
33
|
+
// Only process if value has actual content
|
|
34
|
+
if (value && typeof value === 'object' && Object.keys(value).length > 0) {
|
|
35
|
+
if (!resources[lang]) {
|
|
36
|
+
resources[lang] = {};
|
|
37
|
+
}
|
|
38
|
+
const namespaces = Object.keys(value);
|
|
39
|
+
const isFlatMap = namespaces.every(nsKey => typeof value[nsKey] === 'string');
|
|
40
|
+
|
|
41
|
+
if (isFlatMap) {
|
|
42
|
+
// It's a flat map (e.g. { hello: 'Hello' }), wrap in 'common'
|
|
43
|
+
const defaultNs = 'common';
|
|
44
|
+
resources[lang][defaultNs] = TranslationLoader.mergeTranslations(
|
|
45
|
+
resources[lang][defaultNs] || {},
|
|
46
|
+
value
|
|
44
47
|
);
|
|
48
|
+
} else {
|
|
49
|
+
// It's already namespaced (e.g. { auth: {...} })
|
|
50
|
+
for (const [namespace, translations] of Object.entries(value)) {
|
|
51
|
+
resources[lang][namespace] = TranslationLoader.mergeTranslations(
|
|
52
|
+
resources[lang][namespace] || {},
|
|
53
|
+
translations as Record<string, any>
|
|
54
|
+
);
|
|
55
|
+
}
|
|
45
56
|
}
|
|
46
57
|
}
|
|
47
58
|
} else {
|
|
48
59
|
// It's a namespace for the default/current language (backward compatibility)
|
|
49
|
-
if (
|
|
60
|
+
// Only add if the language exists in resources (to prevent creating empty resources)
|
|
61
|
+
if (value && typeof value === 'object' && resources[languageCode]) {
|
|
50
62
|
resources[languageCode][key] = TranslationLoader.mergeTranslations(
|
|
51
63
|
resources[languageCode][key] || {},
|
|
52
64
|
value
|
|
@@ -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
|
|
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();
|