@umituz/react-native-localization 1.5.0 → 1.5.1
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 +1 -6
- package/src/infrastructure/config/i18n.ts +2 -34
- package/src/infrastructure/config/languages.ts +0 -1
- package/src/infrastructure/storage/AsyncStorageWrapper.ts +1 -2
- package/src/infrastructure/storage/LocalizationStore.ts +0 -62
- package/lib/domain/repositories/ILocalizationRepository.d.ts +0 -17
- package/lib/domain/repositories/ILocalizationRepository.d.ts.map +0 -1
- package/lib/domain/repositories/ILocalizationRepository.js +0 -6
- package/lib/domain/repositories/ILocalizationRepository.js.map +0 -1
- package/lib/index.d.ts +0 -13
- package/lib/index.d.ts.map +0 -1
- package/lib/index.js +0 -15
- package/lib/index.js.map +0 -1
- package/lib/infrastructure/components/LanguageSwitcher.d.ts +0 -12
- package/lib/infrastructure/components/LanguageSwitcher.d.ts.map +0 -1
- package/lib/infrastructure/components/LanguageSwitcher.js +0 -49
- package/lib/infrastructure/components/LanguageSwitcher.js.map +0 -1
- package/lib/infrastructure/components/LocalizationProvider.d.ts +0 -11
- package/lib/infrastructure/components/LocalizationProvider.d.ts.map +0 -1
- package/lib/infrastructure/components/LocalizationProvider.js +0 -14
- package/lib/infrastructure/components/LocalizationProvider.js.map +0 -1
- package/lib/infrastructure/components/useLanguageNavigation.d.ts +0 -6
- package/lib/infrastructure/components/useLanguageNavigation.d.ts.map +0 -1
- package/lib/infrastructure/components/useLanguageNavigation.js +0 -16
- package/lib/infrastructure/components/useLanguageNavigation.js.map +0 -1
- package/lib/infrastructure/config/i18n.d.ts +0 -12
- package/lib/infrastructure/config/i18n.d.ts.map +0 -1
- package/lib/infrastructure/config/i18n.js +0 -269
- package/lib/infrastructure/config/i18n.js.map +0 -1
- package/lib/infrastructure/config/languages.d.ts +0 -39
- package/lib/infrastructure/config/languages.d.ts.map +0 -1
- package/lib/infrastructure/config/languages.js +0 -210
- package/lib/infrastructure/config/languages.js.map +0 -1
- package/lib/infrastructure/config/languagesData.d.ts +0 -26
- package/lib/infrastructure/config/languagesData.d.ts.map +0 -1
- package/lib/infrastructure/config/languagesData.js +0 -58
- package/lib/infrastructure/config/languagesData.js.map +0 -1
- package/lib/infrastructure/locales/en-US/index.d.ts +0 -29
- package/lib/infrastructure/locales/en-US/index.d.ts.map +0 -1
- package/lib/infrastructure/locales/en-US/index.js +0 -40
- package/lib/infrastructure/locales/en-US/index.js.map +0 -1
- package/lib/infrastructure/storage/AsyncStorageWrapper.d.ts +0 -12
- package/lib/infrastructure/storage/AsyncStorageWrapper.d.ts.map +0 -1
- package/lib/infrastructure/storage/AsyncStorageWrapper.js +0 -29
- package/lib/infrastructure/storage/AsyncStorageWrapper.js.map +0 -1
- package/lib/infrastructure/storage/LocalizationStore.d.ts +0 -31
- package/lib/infrastructure/storage/LocalizationStore.d.ts.map +0 -1
- package/lib/infrastructure/storage/LocalizationStore.js +0 -192
- package/lib/infrastructure/storage/LocalizationStore.js.map +0 -1
package/package.json
CHANGED
|
@@ -1,16 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@umituz/react-native-localization",
|
|
3
|
-
"version": "1.5.
|
|
3
|
+
"version": "1.5.1",
|
|
4
4
|
"description": "Universal localization system for React Native apps with i18n support",
|
|
5
5
|
"main": "./src/index.ts",
|
|
6
6
|
"types": "./src/index.ts",
|
|
7
7
|
"scripts": {
|
|
8
|
-
"build": "tsc",
|
|
9
8
|
"typecheck": "tsc --noEmit",
|
|
10
9
|
"lint": "tsc --noEmit",
|
|
11
|
-
"clean": "rm -rf lib",
|
|
12
|
-
"prebuild": "npm run clean",
|
|
13
|
-
"prepublishOnly": "npm run build",
|
|
14
10
|
"locales:generate": "node scripts/createLocaleLoaders.js",
|
|
15
11
|
"locales:generate:lang": "node scripts/createLocaleLoaders.js",
|
|
16
12
|
"version:patch": "npm version patch -m 'chore: release v%s'",
|
|
@@ -71,7 +67,6 @@
|
|
|
71
67
|
"access": "public"
|
|
72
68
|
},
|
|
73
69
|
"files": [
|
|
74
|
-
"lib",
|
|
75
70
|
"src",
|
|
76
71
|
"scripts",
|
|
77
72
|
"README.md",
|
|
@@ -46,11 +46,8 @@ const loadPackageTranslations = (): Record<string, any> => {
|
|
|
46
46
|
try {
|
|
47
47
|
const translations = packageLocalesContext(key);
|
|
48
48
|
packageTranslations[languageCode] = translations.default || translations;
|
|
49
|
-
/* eslint-disable-next-line no-console */
|
|
50
|
-
if (__DEV__) console.log(`[i18n] ✅ Loaded package translations: ${languageCode}`);
|
|
51
49
|
} catch (error) {
|
|
52
|
-
|
|
53
|
-
if (__DEV__) console.warn(`[i18n] ⚠️ Failed to load package translations for ${languageCode}:`, error);
|
|
50
|
+
// Ignore individual language loading errors
|
|
54
51
|
}
|
|
55
52
|
}
|
|
56
53
|
});
|
|
@@ -84,17 +81,11 @@ try {
|
|
|
84
81
|
projectTranslations[languageCode] = {};
|
|
85
82
|
}
|
|
86
83
|
projectTranslations[languageCode] = translations.default || translations;
|
|
87
|
-
/* eslint-disable-next-line no-console */
|
|
88
|
-
if (__DEV__) console.log(`[i18n] ✅ Loaded project translations: ${languageCode}`);
|
|
89
84
|
} catch (error) {
|
|
90
|
-
|
|
91
|
-
if (__DEV__) console.warn(`[i18n] ⚠️ Failed to load project translations for ${languageCode}:`, error);
|
|
85
|
+
// Ignore individual language loading errors
|
|
92
86
|
}
|
|
93
87
|
}
|
|
94
88
|
});
|
|
95
|
-
|
|
96
|
-
/* eslint-disable-next-line no-console */
|
|
97
|
-
if (__DEV__) console.log('[i18n] ✅ Loaded project translations from DDD structure');
|
|
98
89
|
} catch (e1) {
|
|
99
90
|
try {
|
|
100
91
|
// Try alternative DDD structure path
|
|
@@ -116,9 +107,6 @@ try {
|
|
|
116
107
|
}
|
|
117
108
|
}
|
|
118
109
|
});
|
|
119
|
-
|
|
120
|
-
/* eslint-disable-next-line no-console */
|
|
121
|
-
if (__DEV__) console.log('[i18n] ✅ Loaded project translations from alternative DDD structure');
|
|
122
110
|
} catch (e2) {
|
|
123
111
|
try {
|
|
124
112
|
// Try simple structure path
|
|
@@ -140,13 +128,8 @@ try {
|
|
|
140
128
|
}
|
|
141
129
|
}
|
|
142
130
|
});
|
|
143
|
-
|
|
144
|
-
/* eslint-disable-next-line no-console */
|
|
145
|
-
if (__DEV__) console.log('[i18n] ✅ Loaded project translations from simple structure');
|
|
146
131
|
} catch (e3) {
|
|
147
132
|
// No project translations found - this is OK, use package defaults only
|
|
148
|
-
/* eslint-disable-next-line no-console */
|
|
149
|
-
if (__DEV__) console.log('[i18n] ℹ️ No project-specific translations found, using package defaults only');
|
|
150
133
|
}
|
|
151
134
|
}
|
|
152
135
|
}
|
|
@@ -209,9 +192,6 @@ const buildResources = (): Record<string, { translation: any }> => {
|
|
|
209
192
|
};
|
|
210
193
|
});
|
|
211
194
|
|
|
212
|
-
/* eslint-disable-next-line no-console */
|
|
213
|
-
if (__DEV__) console.log(`[i18n] 📦 Loaded ${Object.keys(resources).length} languages:`, Object.keys(resources).join(', '));
|
|
214
|
-
|
|
215
195
|
return resources;
|
|
216
196
|
};
|
|
217
197
|
|
|
@@ -227,17 +207,11 @@ const initializeI18n = () => {
|
|
|
227
207
|
if (isInitialized) return;
|
|
228
208
|
|
|
229
209
|
try {
|
|
230
|
-
/* eslint-disable-next-line no-console */
|
|
231
|
-
if (__DEV__) console.log('[i18n] Initializing i18next...');
|
|
232
|
-
|
|
233
210
|
// Check if initReactI18next is available
|
|
234
211
|
if (!initReactI18next) {
|
|
235
212
|
throw new Error('initReactI18next is undefined');
|
|
236
213
|
}
|
|
237
214
|
|
|
238
|
-
/* eslint-disable-next-line no-console */
|
|
239
|
-
if (__DEV__) console.log('[i18n] initReactI18next found, initializing...');
|
|
240
|
-
|
|
241
215
|
i18n.use(initReactI18next).init({
|
|
242
216
|
resources,
|
|
243
217
|
lng: DEFAULT_LANGUAGE,
|
|
@@ -257,14 +231,8 @@ const initializeI18n = () => {
|
|
|
257
231
|
});
|
|
258
232
|
|
|
259
233
|
isInitialized = true;
|
|
260
|
-
/* eslint-disable-next-line no-console */
|
|
261
|
-
if (__DEV__) console.log('[i18n] i18next initialized successfully');
|
|
262
234
|
} catch (error) {
|
|
263
|
-
/* eslint-disable-next-line no-console */
|
|
264
|
-
if (__DEV__) console.error('[i18n] Initialization error:', error);
|
|
265
235
|
// Don't throw - allow app to continue without i18n
|
|
266
|
-
/* eslint-disable-next-line no-console */
|
|
267
|
-
if (__DEV__) console.warn('[i18n] Continuing without i18n initialization');
|
|
268
236
|
}
|
|
269
237
|
};
|
|
270
238
|
|
|
@@ -242,7 +242,6 @@ export const getDeviceLocale = (): string => {
|
|
|
242
242
|
return DEFAULT_LANGUAGE;
|
|
243
243
|
} catch (error) {
|
|
244
244
|
// If any error occurs, fallback to default
|
|
245
|
-
console.warn('[Localization] Failed to detect device locale:', error);
|
|
246
245
|
return DEFAULT_LANGUAGE;
|
|
247
246
|
}
|
|
248
247
|
};
|
|
@@ -15,7 +15,6 @@ export const StorageWrapper = {
|
|
|
15
15
|
const value = await AsyncStorage.getItem(key);
|
|
16
16
|
return value ?? defaultValue;
|
|
17
17
|
} catch (error) {
|
|
18
|
-
console.warn('[Localization] Failed to get storage value:', error);
|
|
19
18
|
return defaultValue;
|
|
20
19
|
}
|
|
21
20
|
},
|
|
@@ -24,7 +23,7 @@ export const StorageWrapper = {
|
|
|
24
23
|
try {
|
|
25
24
|
await AsyncStorage.setItem(key, value);
|
|
26
25
|
} catch (error) {
|
|
27
|
-
|
|
26
|
+
// Ignore storage errors
|
|
28
27
|
}
|
|
29
28
|
},
|
|
30
29
|
};
|
|
@@ -33,84 +33,42 @@ export const useLocalizationStore = create<LocalizationState>((set, get) => ({
|
|
|
33
33
|
* - Fallback: English (en-US) if device locale not supported
|
|
34
34
|
*/
|
|
35
35
|
initialize: async () => {
|
|
36
|
-
/* eslint-disable-next-line no-console */
|
|
37
|
-
if (__DEV__) console.log('[LocalizationStore] Starting initialization...');
|
|
38
|
-
|
|
39
36
|
try {
|
|
40
37
|
// ✅ CRITICAL FIX: Don't reset isInitialized if already initialized
|
|
41
38
|
// This prevents UI flash on re-initialization
|
|
42
39
|
const { isInitialized: alreadyInitialized } = get();
|
|
43
40
|
if (alreadyInitialized) {
|
|
44
|
-
/* eslint-disable-next-line no-console */
|
|
45
|
-
if (__DEV__) console.log('[LocalizationStore] Already initialized, skipping...');
|
|
46
41
|
return;
|
|
47
42
|
}
|
|
48
43
|
|
|
49
|
-
/* eslint-disable-next-line no-console */
|
|
50
|
-
if (__DEV__) console.log('[LocalizationStore] Getting saved language preference...');
|
|
51
44
|
// Get saved language preference
|
|
52
45
|
const savedLanguage = await StorageWrapper.getString(STORAGE_KEYS.LANGUAGE, DEFAULT_LANGUAGE);
|
|
53
|
-
/* eslint-disable-next-line no-console */
|
|
54
|
-
if (__DEV__) console.log('[LocalizationStore] Saved language:', savedLanguage);
|
|
55
46
|
|
|
56
47
|
// ✅ DEVICE LOCALE DETECTION: Use device locale on first launch
|
|
57
48
|
let languageCode: string;
|
|
58
49
|
if (savedLanguage && savedLanguage !== DEFAULT_LANGUAGE) {
|
|
59
50
|
// User has previously selected a language → Use their choice
|
|
60
|
-
/* eslint-disable-next-line no-console */
|
|
61
|
-
if (__DEV__) console.log('[LocalizationStore] Using saved language preference:', savedLanguage);
|
|
62
51
|
languageCode = savedLanguage;
|
|
63
52
|
} else {
|
|
64
53
|
// First launch → Detect device locale automatically
|
|
65
|
-
/* eslint-disable-next-line no-console */
|
|
66
|
-
if (__DEV__) console.log('[LocalizationStore] First launch, detecting device locale...');
|
|
67
54
|
languageCode = getDeviceLocale();
|
|
68
|
-
/* eslint-disable-next-line no-console */
|
|
69
|
-
if (__DEV__) console.log('[LocalizationStore] Detected device locale:', languageCode);
|
|
70
55
|
// Save detected locale for future launches
|
|
71
56
|
await StorageWrapper.setString(STORAGE_KEYS.LANGUAGE, languageCode);
|
|
72
|
-
/* eslint-disable-next-line no-console */
|
|
73
|
-
if (__DEV__) console.log('[LocalizationStore] Saved detected locale to storage');
|
|
74
57
|
}
|
|
75
58
|
|
|
76
59
|
// ✅ DEFENSIVE: Validate language exists, fallback to default
|
|
77
|
-
/* eslint-disable-next-line no-console */
|
|
78
|
-
if (__DEV__) console.log('[LocalizationStore] Validating language code:', languageCode);
|
|
79
60
|
const language = getLanguageByCode(languageCode);
|
|
80
61
|
const finalLanguage = language ? languageCode : DEFAULT_LANGUAGE;
|
|
81
62
|
const finalLanguageObj = getLanguageByCode(finalLanguage);
|
|
82
|
-
|
|
83
|
-
if (!language) {
|
|
84
|
-
/* eslint-disable-next-line no-console */
|
|
85
|
-
console.warn('[LocalizationStore] ⚠️ Language not found:', languageCode, 'falling back to:', DEFAULT_LANGUAGE);
|
|
86
|
-
}
|
|
87
63
|
|
|
88
|
-
/* eslint-disable-next-line no-console */
|
|
89
|
-
if (__DEV__) console.log('[LocalizationStore] Changing i18n language to:', finalLanguage);
|
|
90
64
|
await i18n.changeLanguage(finalLanguage);
|
|
91
65
|
|
|
92
|
-
/* eslint-disable-next-line no-console */
|
|
93
|
-
if (__DEV__) console.log('[LocalizationStore] Setting store state...');
|
|
94
66
|
set({
|
|
95
67
|
currentLanguage: finalLanguage,
|
|
96
68
|
isRTL: finalLanguageObj?.rtl || false,
|
|
97
69
|
isInitialized: true, // ✅ Always set true to unblock UI
|
|
98
70
|
});
|
|
99
|
-
|
|
100
|
-
/* eslint-disable-next-line no-console */
|
|
101
|
-
if (__DEV__) console.log('[LocalizationStore] ✅ Initialization complete. Language:', finalLanguage, 'RTL:', finalLanguageObj?.rtl || false);
|
|
102
71
|
} catch (error) {
|
|
103
|
-
/* eslint-disable-next-line no-console */
|
|
104
|
-
console.error('[LocalizationStore] ❌ FATAL: Initialization failed:', error);
|
|
105
|
-
/* eslint-disable-next-line no-console */
|
|
106
|
-
if (error instanceof Error) {
|
|
107
|
-
/* eslint-disable-next-line no-console */
|
|
108
|
-
console.error('[LocalizationStore] Error name:', error.name);
|
|
109
|
-
/* eslint-disable-next-line no-console */
|
|
110
|
-
console.error('[LocalizationStore] Error message:', error.message);
|
|
111
|
-
/* eslint-disable-next-line no-console */
|
|
112
|
-
console.error('[LocalizationStore] Error stack:', error.stack);
|
|
113
|
-
}
|
|
114
72
|
// Set to default language even on error to prevent app from breaking
|
|
115
73
|
try {
|
|
116
74
|
await i18n.changeLanguage(DEFAULT_LANGUAGE);
|
|
@@ -119,11 +77,7 @@ export const useLocalizationStore = create<LocalizationState>((set, get) => ({
|
|
|
119
77
|
isRTL: false,
|
|
120
78
|
isInitialized: true, // Set true even on error to unblock UI
|
|
121
79
|
});
|
|
122
|
-
/* eslint-disable-next-line no-console */
|
|
123
|
-
console.warn('[LocalizationStore] ⚠️ Fallback to default language due to error');
|
|
124
80
|
} catch (fallbackError) {
|
|
125
|
-
/* eslint-disable-next-line no-console */
|
|
126
|
-
console.error('[LocalizationStore] ❌ CRITICAL: Even fallback failed:', fallbackError);
|
|
127
81
|
throw fallbackError;
|
|
128
82
|
}
|
|
129
83
|
}
|
|
@@ -134,42 +88,26 @@ export const useLocalizationStore = create<LocalizationState>((set, get) => ({
|
|
|
134
88
|
* Updates i18n, state, and persists to AsyncStorage
|
|
135
89
|
*/
|
|
136
90
|
setLanguage: async (languageCode: string) => {
|
|
137
|
-
/* eslint-disable-next-line no-console */
|
|
138
|
-
if (__DEV__) console.log('[LocalizationStore] Changing language to:', languageCode);
|
|
139
|
-
|
|
140
91
|
try {
|
|
141
92
|
const language = getLanguageByCode(languageCode);
|
|
142
93
|
|
|
143
94
|
// ✅ DEFENSIVE: Early return if unsupported language
|
|
144
95
|
if (!language) {
|
|
145
|
-
/* eslint-disable-next-line no-console */
|
|
146
|
-
console.warn('[LocalizationStore] ⚠️ Unsupported language code:', languageCode);
|
|
147
96
|
return;
|
|
148
97
|
}
|
|
149
98
|
|
|
150
|
-
/* eslint-disable-next-line no-console */
|
|
151
|
-
if (__DEV__) console.log('[LocalizationStore] Updating i18n language...');
|
|
152
99
|
// Update i18n
|
|
153
100
|
await i18n.changeLanguage(languageCode);
|
|
154
101
|
|
|
155
|
-
/* eslint-disable-next-line no-console */
|
|
156
|
-
if (__DEV__) console.log('[LocalizationStore] Updating store state...');
|
|
157
102
|
// Update state
|
|
158
103
|
set({
|
|
159
104
|
currentLanguage: languageCode,
|
|
160
105
|
isRTL: language.rtl || false,
|
|
161
106
|
});
|
|
162
107
|
|
|
163
|
-
/* eslint-disable-next-line no-console */
|
|
164
|
-
if (__DEV__) console.log('[LocalizationStore] Persisting language preference...');
|
|
165
108
|
// Persist language preference
|
|
166
109
|
await StorageWrapper.setString(STORAGE_KEYS.LANGUAGE, languageCode);
|
|
167
|
-
|
|
168
|
-
/* eslint-disable-next-line no-console */
|
|
169
|
-
if (__DEV__) console.log('[LocalizationStore] ✅ Language changed successfully to:', languageCode);
|
|
170
110
|
} catch (error) {
|
|
171
|
-
/* eslint-disable-next-line no-console */
|
|
172
|
-
console.error('[LocalizationStore] ❌ Error changing language:', error);
|
|
173
111
|
throw error;
|
|
174
112
|
}
|
|
175
113
|
},
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Localization Repository Interface
|
|
3
|
-
* Defines language configuration and types
|
|
4
|
-
*/
|
|
5
|
-
export interface Language {
|
|
6
|
-
code: string;
|
|
7
|
-
name: string;
|
|
8
|
-
nativeName: string;
|
|
9
|
-
flag: string;
|
|
10
|
-
rtl?: boolean;
|
|
11
|
-
}
|
|
12
|
-
export interface ILocalizationRepository {
|
|
13
|
-
getSupportedLanguages(): Language[];
|
|
14
|
-
getLanguageByCode(code: string): Language | undefined;
|
|
15
|
-
isLanguageSupported(code: string): boolean;
|
|
16
|
-
}
|
|
17
|
-
//# sourceMappingURL=ILocalizationRepository.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ILocalizationRepository.d.ts","sourceRoot":"","sources":["../../../src/domain/repositories/ILocalizationRepository.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,MAAM,WAAW,QAAQ;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,CAAC,EAAE,OAAO,CAAC;CACf;AAED,MAAM,WAAW,uBAAuB;IACtC,qBAAqB,IAAI,QAAQ,EAAE,CAAC;IACpC,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG,QAAQ,GAAG,SAAS,CAAC;IACtD,mBAAmB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC;CAC5C"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ILocalizationRepository.js","sourceRoot":"","sources":["../../../src/domain/repositories/ILocalizationRepository.ts"],"names":[],"mappings":"AAAA;;;GAGG"}
|
package/lib/index.d.ts
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* React Native Localization
|
|
3
|
-
* Universal localization system with i18n support for React Native apps
|
|
4
|
-
*/
|
|
5
|
-
export { useLocalization, useLocalizationStore } from './infrastructure/storage/LocalizationStore';
|
|
6
|
-
export { LocalizationProvider } from './infrastructure/components/LocalizationProvider';
|
|
7
|
-
export { LanguageSwitcher } from './infrastructure/components/LanguageSwitcher';
|
|
8
|
-
export { useLanguageNavigation } from './infrastructure/components/useLanguageNavigation';
|
|
9
|
-
export { default as i18n } from './infrastructure/config/i18n';
|
|
10
|
-
export { SUPPORTED_LANGUAGES, LANGUAGES, // Alias for SUPPORTED_LANGUAGES (backward compatibility)
|
|
11
|
-
DEFAULT_LANGUAGE, getLanguageByCode, isLanguageSupported, getDefaultLanguage, getDeviceLocale, searchLanguages, } from './infrastructure/config/languages';
|
|
12
|
-
export type { Language, ILocalizationRepository } from './domain/repositories/ILocalizationRepository';
|
|
13
|
-
//# sourceMappingURL=index.d.ts.map
|
package/lib/index.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,eAAe,EAAE,oBAAoB,EAAE,MAAM,4CAA4C,CAAC;AAGnG,OAAO,EAAE,oBAAoB,EAAE,MAAM,kDAAkD,CAAC;AACxF,OAAO,EAAE,gBAAgB,EAAE,MAAM,8CAA8C,CAAC;AAChF,OAAO,EAAE,qBAAqB,EAAE,MAAM,mDAAmD,CAAC;AAG1F,OAAO,EAAE,OAAO,IAAI,IAAI,EAAE,MAAM,8BAA8B,CAAC;AAC/D,OAAO,EACL,mBAAmB,EACnB,SAAS,EAAE,yDAAyD;AACpE,gBAAgB,EAChB,iBAAiB,EACjB,mBAAmB,EACnB,kBAAkB,EAClB,eAAe,EACf,eAAe,GAChB,MAAM,mCAAmC,CAAC;AAG3C,YAAY,EAAE,QAAQ,EAAE,uBAAuB,EAAE,MAAM,+CAA+C,CAAC"}
|
package/lib/index.js
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* React Native Localization
|
|
3
|
-
* Universal localization system with i18n support for React Native apps
|
|
4
|
-
*/
|
|
5
|
-
// Hooks
|
|
6
|
-
export { useLocalization, useLocalizationStore } from './infrastructure/storage/LocalizationStore';
|
|
7
|
-
// Components
|
|
8
|
-
export { LocalizationProvider } from './infrastructure/components/LocalizationProvider';
|
|
9
|
-
export { LanguageSwitcher } from './infrastructure/components/LanguageSwitcher';
|
|
10
|
-
export { useLanguageNavigation } from './infrastructure/components/useLanguageNavigation';
|
|
11
|
-
// Configuration
|
|
12
|
-
export { default as i18n } from './infrastructure/config/i18n';
|
|
13
|
-
export { SUPPORTED_LANGUAGES, LANGUAGES, // Alias for SUPPORTED_LANGUAGES (backward compatibility)
|
|
14
|
-
DEFAULT_LANGUAGE, getLanguageByCode, isLanguageSupported, getDefaultLanguage, getDeviceLocale, searchLanguages, } from './infrastructure/config/languages';
|
|
15
|
-
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,QAAQ;AACR,OAAO,EAAE,eAAe,EAAE,oBAAoB,EAAE,MAAM,4CAA4C,CAAC;AAEnG,aAAa;AACb,OAAO,EAAE,oBAAoB,EAAE,MAAM,kDAAkD,CAAC;AACxF,OAAO,EAAE,gBAAgB,EAAE,MAAM,8CAA8C,CAAC;AAChF,OAAO,EAAE,qBAAqB,EAAE,MAAM,mDAAmD,CAAC;AAE1F,gBAAgB;AAChB,OAAO,EAAE,OAAO,IAAI,IAAI,EAAE,MAAM,8BAA8B,CAAC;AAC/D,OAAO,EACL,mBAAmB,EACnB,SAAS,EAAE,yDAAyD;AACpE,gBAAgB,EAChB,iBAAiB,EACjB,mBAAmB,EACnB,kBAAkB,EAClB,eAAe,EACf,eAAe,GAChB,MAAM,mCAAmC,CAAC"}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
interface LanguageSwitcherProps {
|
|
3
|
-
showName?: boolean;
|
|
4
|
-
showFlag?: boolean;
|
|
5
|
-
color?: string;
|
|
6
|
-
navigationScreen?: string;
|
|
7
|
-
style?: any;
|
|
8
|
-
textStyle?: any;
|
|
9
|
-
}
|
|
10
|
-
export declare const LanguageSwitcher: React.FC<LanguageSwitcherProps>;
|
|
11
|
-
export default LanguageSwitcher;
|
|
12
|
-
//# sourceMappingURL=LanguageSwitcher.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"LanguageSwitcher.d.ts","sourceRoot":"","sources":["../../../src/infrastructure/components/LanguageSwitcher.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAQ1B,UAAU,qBAAqB;IAC7B,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,KAAK,CAAC,EAAE,GAAG,CAAC;IACZ,SAAS,CAAC,EAAE,GAAG,CAAC;CACjB;AAQD,eAAO,MAAM,gBAAgB,EAAE,KAAK,CAAC,EAAE,CAAC,qBAAqB,CAwC5D,CAAC;AAqBF,eAAe,gBAAgB,CAAC"}
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { TouchableOpacity, Text, StyleSheet } from 'react-native';
|
|
3
|
-
// @ts-ignore - Optional peer dependency
|
|
4
|
-
import { useNavigation } from '@react-navigation/native';
|
|
5
|
-
import { useLocalization } from '../storage/LocalizationStore';
|
|
6
|
-
import { getLanguageByCode, getDefaultLanguage } from '../config/languages';
|
|
7
|
-
const languageSwitcherConfig = {
|
|
8
|
-
defaultIconSize: 20,
|
|
9
|
-
defaultNavigationScreen: 'LanguageSelection',
|
|
10
|
-
hitSlop: { top: 10, bottom: 10, left: 10, right: 10 },
|
|
11
|
-
};
|
|
12
|
-
export const LanguageSwitcher = ({ showName = false, showFlag = true, color, navigationScreen = languageSwitcherConfig.defaultNavigationScreen, style, textStyle, }) => {
|
|
13
|
-
const navigation = useNavigation();
|
|
14
|
-
const { currentLanguage } = useLocalization();
|
|
15
|
-
const currentLang = getLanguageByCode(currentLanguage) || getDefaultLanguage();
|
|
16
|
-
const navigateToLanguageSelection = () => {
|
|
17
|
-
if (navigation && navigationScreen) {
|
|
18
|
-
navigation.navigate(navigationScreen);
|
|
19
|
-
}
|
|
20
|
-
};
|
|
21
|
-
const iconColor = color || '#000000';
|
|
22
|
-
return (<TouchableOpacity style={[styles.container, style]} onPress={navigateToLanguageSelection} activeOpacity={0.7} hitSlop={languageSwitcherConfig.hitSlop}>
|
|
23
|
-
{showFlag && (<Text style={[styles.flag, textStyle]}>{currentLang.flag}</Text>)}
|
|
24
|
-
{showName && (<Text style={[styles.languageName, { color: iconColor }, textStyle]}>
|
|
25
|
-
{currentLang.nativeName}
|
|
26
|
-
</Text>)}
|
|
27
|
-
{!showName && !showFlag && (<Text style={[styles.icon, { color: iconColor }]}>🌐</Text>)}
|
|
28
|
-
</TouchableOpacity>);
|
|
29
|
-
};
|
|
30
|
-
const styles = StyleSheet.create({
|
|
31
|
-
container: {
|
|
32
|
-
flexDirection: 'row',
|
|
33
|
-
alignItems: 'center',
|
|
34
|
-
gap: 8,
|
|
35
|
-
paddingHorizontal: 4,
|
|
36
|
-
},
|
|
37
|
-
flag: {
|
|
38
|
-
fontSize: 20,
|
|
39
|
-
},
|
|
40
|
-
languageName: {
|
|
41
|
-
fontSize: 14,
|
|
42
|
-
fontWeight: '600',
|
|
43
|
-
},
|
|
44
|
-
icon: {
|
|
45
|
-
fontSize: 20,
|
|
46
|
-
},
|
|
47
|
-
});
|
|
48
|
-
export default LanguageSwitcher;
|
|
49
|
-
//# sourceMappingURL=LanguageSwitcher.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"LanguageSwitcher.js","sourceRoot":"","sources":["../../../src/infrastructure/components/LanguageSwitcher.tsx"],"names":[],"mappings":"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"}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* LocalizationProvider Component
|
|
3
|
-
* Initializes localization system on mount
|
|
4
|
-
*/
|
|
5
|
-
import React, { ReactNode } from 'react';
|
|
6
|
-
interface LocalizationProviderProps {
|
|
7
|
-
children: ReactNode;
|
|
8
|
-
}
|
|
9
|
-
export declare const LocalizationProvider: React.FC<LocalizationProviderProps>;
|
|
10
|
-
export {};
|
|
11
|
-
//# sourceMappingURL=LocalizationProvider.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"LocalizationProvider.d.ts","sourceRoot":"","sources":["../../../src/infrastructure/components/LocalizationProvider.tsx"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,EAAa,SAAS,EAAE,MAAM,OAAO,CAAC;AAGpD,UAAU,yBAAyB;IACjC,QAAQ,EAAE,SAAS,CAAC;CACrB;AAED,eAAO,MAAM,oBAAoB,EAAE,KAAK,CAAC,EAAE,CAAC,yBAAyB,CAQpE,CAAC"}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* LocalizationProvider Component
|
|
3
|
-
* Initializes localization system on mount
|
|
4
|
-
*/
|
|
5
|
-
import React, { useEffect } from 'react';
|
|
6
|
-
import { useLocalizationStore } from '../storage/LocalizationStore';
|
|
7
|
-
export const LocalizationProvider = ({ children }) => {
|
|
8
|
-
const initialize = useLocalizationStore((state) => state.initialize);
|
|
9
|
-
useEffect(() => {
|
|
10
|
-
initialize();
|
|
11
|
-
}, [initialize]);
|
|
12
|
-
return <>{children}</>;
|
|
13
|
-
};
|
|
14
|
-
//# sourceMappingURL=LocalizationProvider.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"LocalizationProvider.js","sourceRoot":"","sources":["../../../src/infrastructure/components/LocalizationProvider.tsx"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,EAAE,SAAS,EAAa,MAAM,OAAO,CAAC;AACpD,OAAO,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AAMpE,MAAM,CAAC,MAAM,oBAAoB,GAAwC,CAAC,EAAE,QAAQ,EAAE,EAAE,EAAE;IACxF,MAAM,UAAU,GAAG,oBAAoB,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC;IAErE,SAAS,CAAC,GAAG,EAAE;QACb,UAAU,EAAE,CAAC;IACf,CAAC,EAAE,CAAC,UAAU,CAAC,CAAC,CAAC;IAEjB,OAAO,EAAE,CAAC,QAAQ,CAAC,GAAG,CAAC;AACzB,CAAC,CAAC"}
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { Language } from '../../domain/repositories/ILocalizationRepository';
|
|
2
|
-
export declare const useLanguageNavigation: (navigationScreen: string) => {
|
|
3
|
-
currentLang: Language;
|
|
4
|
-
navigateToLanguageSelection: () => void;
|
|
5
|
-
};
|
|
6
|
-
//# sourceMappingURL=useLanguageNavigation.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useLanguageNavigation.d.ts","sourceRoot":"","sources":["../../../src/infrastructure/components/useLanguageNavigation.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,QAAQ,EAAE,MAAM,mDAAmD,CAAC;AAE7E,eAAO,MAAM,qBAAqB,GAAI,kBAAkB,MAAM;;;CAY7D,CAAC"}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
// @ts-ignore - Optional peer dependency
|
|
2
|
-
import { useNavigation } from '@react-navigation/native';
|
|
3
|
-
import { useLocalization } from '../storage/LocalizationStore';
|
|
4
|
-
import { getLanguageByCode, getDefaultLanguage } from '../config/languages';
|
|
5
|
-
export const useLanguageNavigation = (navigationScreen) => {
|
|
6
|
-
const navigation = useNavigation();
|
|
7
|
-
const { currentLanguage } = useLocalization();
|
|
8
|
-
const currentLang = getLanguageByCode(currentLanguage) || getDefaultLanguage();
|
|
9
|
-
const navigateToLanguageSelection = () => {
|
|
10
|
-
if (navigation && navigationScreen) {
|
|
11
|
-
navigation.navigate(navigationScreen);
|
|
12
|
-
}
|
|
13
|
-
};
|
|
14
|
-
return { currentLang, navigateToLanguageSelection };
|
|
15
|
-
};
|
|
16
|
-
//# sourceMappingURL=useLanguageNavigation.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useLanguageNavigation.js","sourceRoot":"","sources":["../../../src/infrastructure/components/useLanguageNavigation.ts"],"names":[],"mappings":"AAAA,wCAAwC;AACxC,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AACzD,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAC/D,OAAO,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAG5E,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAC,gBAAwB,EAAE,EAAE;IAChE,MAAM,UAAU,GAAG,aAAa,EAAE,CAAC;IACnC,MAAM,EAAE,eAAe,EAAE,GAAG,eAAe,EAAE,CAAC;IAC9C,MAAM,WAAW,GAAG,iBAAiB,CAAC,eAAe,CAAC,IAAI,kBAAkB,EAAE,CAAC;IAE/E,MAAM,2BAA2B,GAAG,GAAG,EAAE;QACvC,IAAI,UAAU,IAAI,gBAAgB,EAAE,CAAC;YACnC,UAAU,CAAC,QAAQ,CAAC,gBAAyB,CAAC,CAAC;QACjD,CAAC;IACH,CAAC,CAAC;IAEF,OAAO,EAAE,WAAW,EAAE,2BAA2B,EAAE,CAAC;AACtD,CAAC,CAAC"}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* i18next Configuration
|
|
3
|
-
* Nested translation structure - common translations spread, domain translations nested
|
|
4
|
-
*
|
|
5
|
-
* AUTOMATIC LANGUAGE LOADING:
|
|
6
|
-
* - Uses require.context to auto-discover all language directories
|
|
7
|
-
* - No manual imports needed - all languages loaded automatically
|
|
8
|
-
* - Project translations merged with package defaults
|
|
9
|
-
*/
|
|
10
|
-
import i18n from 'i18next';
|
|
11
|
-
export default i18n;
|
|
12
|
-
//# sourceMappingURL=i18n.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"i18n.d.ts","sourceRoot":"","sources":["../../../src/infrastructure/config/i18n.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,IAAI,MAAM,SAAS,CAAC;AAgR3B,eAAe,IAAI,CAAC"}
|