@umituz/react-native-localization 3.5.47 → 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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@umituz/react-native-localization",
3
- "version": "3.5.47",
3
+ "version": "3.5.48",
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",
@@ -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
- // Ensure initial language exists
22
- if (!resources[languageCode]) {
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,12 +29,12 @@ 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
- // Merge namespaces for this language
39
- if (value && typeof value === 'object') {
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
+ }
40
38
  const namespaces = Object.keys(value);
41
39
  const isFlatMap = namespaces.every(nsKey => typeof value[nsKey] === 'string');
42
40
 
@@ -59,7 +57,8 @@ export class ResourceBuilder {
59
57
  }
60
58
  } else {
61
59
  // It's a namespace for the default/current language (backward compatibility)
62
- if (value && typeof value === 'object') {
60
+ // Only add if the language exists in resources (to prevent creating empty resources)
61
+ if (value && typeof value === 'object' && resources[languageCode]) {
63
62
  resources[languageCode][key] = TranslationLoader.mergeTranslations(
64
63
  resources[languageCode][key] || {},
65
64
  value