@umituz/react-native-localization 3.5.17 → 3.5.19
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.
|
|
3
|
+
"version": "3.5.19",
|
|
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",
|
|
@@ -61,25 +61,25 @@
|
|
|
61
61
|
"@expo/vector-icons": "^15.0.3",
|
|
62
62
|
"@react-native-async-storage/async-storage": "^2.2.0",
|
|
63
63
|
"@react-native-community/datetimepicker": "^8.5.1",
|
|
64
|
-
"@react-navigation/native": "^6.1.
|
|
64
|
+
"@react-navigation/native": "^6.1.18",
|
|
65
65
|
"@testing-library/jest-native": "^5.4.3",
|
|
66
66
|
"@testing-library/react": "^16.3.0",
|
|
67
67
|
"@testing-library/react-hooks": "^8.0.1",
|
|
68
68
|
"@testing-library/react-native": "^13.3.3",
|
|
69
69
|
"@types/react": "^18.2.45",
|
|
70
70
|
"@types/react-native": "^0.73.0",
|
|
71
|
-
"@umituz/react-native-design-system": "
|
|
71
|
+
"@umituz/react-native-design-system": "^2.0.4",
|
|
72
72
|
"@umituz/react-native-filesystem": "^1.4.0",
|
|
73
73
|
"@umituz/react-native-icons": "^1.1.2",
|
|
74
|
-
"@umituz/react-native-storage": "^2.4.
|
|
74
|
+
"@umituz/react-native-storage": "^2.4.1",
|
|
75
75
|
"expo-localization": "~15.0.0",
|
|
76
|
-
"i18next": "^23.
|
|
76
|
+
"i18next": "^23.16.8",
|
|
77
77
|
"jest": "^30.2.0",
|
|
78
78
|
"jest-environment-jsdom": "^30.2.0",
|
|
79
79
|
"jest-transform-stub": "^2.0.0",
|
|
80
80
|
"react": ">=18.2.0",
|
|
81
|
-
"react-i18next": "^14.
|
|
82
|
-
"react-native": "
|
|
81
|
+
"react-i18next": "^14.1.3",
|
|
82
|
+
"react-native": "^0.83.1",
|
|
83
83
|
"react-native-gesture-handler": "^2.29.1",
|
|
84
84
|
"react-native-safe-area-context": "^5.6.2",
|
|
85
85
|
"react-test-renderer": "^19.2.0",
|
|
@@ -96,4 +96,4 @@
|
|
|
96
96
|
"README.md",
|
|
97
97
|
"LICENSE"
|
|
98
98
|
]
|
|
99
|
-
}
|
|
99
|
+
}
|
|
@@ -28,10 +28,11 @@ export const getDeviceLocale = (): string => {
|
|
|
28
28
|
|
|
29
29
|
// Extract language code
|
|
30
30
|
const languageCode = deviceLocale.split('-')[0];
|
|
31
|
+
const mappedByCode = languageCode ? LOCALE_MAPPING[languageCode] : undefined;
|
|
31
32
|
|
|
32
33
|
// Check language code
|
|
33
|
-
if (
|
|
34
|
-
return
|
|
34
|
+
if (mappedByCode) {
|
|
35
|
+
return mappedByCode;
|
|
35
36
|
}
|
|
36
37
|
|
|
37
38
|
// Check if directly supported
|
|
@@ -17,7 +17,10 @@ export const isLanguageSupported = (code: string): boolean => {
|
|
|
17
17
|
};
|
|
18
18
|
|
|
19
19
|
export const getDefaultLanguage = (): Language => {
|
|
20
|
-
|
|
20
|
+
const langs = languageRegistry.getLanguages();
|
|
21
|
+
const firstLang = langs[0];
|
|
22
|
+
if (firstLang) return firstLang;
|
|
23
|
+
throw new Error('No languages registered');
|
|
21
24
|
};
|
|
22
25
|
|
|
23
26
|
export const searchLanguages = (query: string): Language[] => {
|
|
@@ -118,7 +118,12 @@ class LanguageRegistry {
|
|
|
118
118
|
*/
|
|
119
119
|
getDefaultLanguage(): Language {
|
|
120
120
|
const en = this.languages.find(l => l.code === 'en-US');
|
|
121
|
-
|
|
121
|
+
if (en) return en;
|
|
122
|
+
const first = this.languages[0];
|
|
123
|
+
if (first) return first;
|
|
124
|
+
const systemDefault = DEFAULT_LANGUAGES[0];
|
|
125
|
+
if (systemDefault) return systemDefault;
|
|
126
|
+
throw new Error('No languages registered in registry or defaults');
|
|
122
127
|
}
|
|
123
128
|
}
|
|
124
129
|
|