@umituz/react-native-localization 1.6.5 → 1.6.6
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
|
@@ -197,27 +197,33 @@ const buildResources = (): Record<string, { translation: any }> => {
|
|
|
197
197
|
|
|
198
198
|
const resources = buildResources();
|
|
199
199
|
|
|
200
|
-
// Debug: Log loaded resources in development
|
|
201
|
-
|
|
202
|
-
if (typeof
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
200
|
+
// Debug: Log loaded resources in development (only once to prevent spam)
|
|
201
|
+
// Use global flag to prevent multiple logs when module is imported multiple times
|
|
202
|
+
if (typeof global !== 'undefined' && !(global as any).__i18n_resources_logged) {
|
|
203
|
+
/* eslint-disable-next-line no-console */
|
|
204
|
+
if (typeof __DEV__ !== 'undefined' && __DEV__) {
|
|
205
|
+
console.log('🌍 i18n Resources loaded:', {
|
|
206
|
+
languages: Object.keys(resources),
|
|
207
|
+
enUSKeys: resources['en-US']?.translation ? Object.keys(resources['en-US'].translation) : [],
|
|
208
|
+
hasGoals: !!resources['en-US']?.translation?.goals,
|
|
209
|
+
navigationKeys: resources['en-US']?.translation?.navigation ? Object.keys(resources['en-US'].translation.navigation) : [],
|
|
210
|
+
hasMilestones: !!resources['en-US']?.translation?.navigation?.milestones,
|
|
211
|
+
hasStatistics: !!resources['en-US']?.translation?.navigation?.statistics,
|
|
212
|
+
});
|
|
213
|
+
(global as any).__i18n_resources_logged = true;
|
|
214
|
+
}
|
|
211
215
|
}
|
|
212
216
|
|
|
213
217
|
/**
|
|
214
218
|
* Initialize i18next
|
|
215
|
-
*
|
|
219
|
+
* CRITICAL: Check i18n.isInitialized to prevent multiple initializations
|
|
220
|
+
* This prevents "i18next is already initialized" warnings when module is imported multiple times
|
|
216
221
|
*/
|
|
217
|
-
let isInitialized = false;
|
|
218
|
-
|
|
219
222
|
const initializeI18n = () => {
|
|
220
|
-
if (
|
|
223
|
+
// CRITICAL: Check if i18n is already initialized (prevents multiple init calls)
|
|
224
|
+
if (i18n.isInitialized) {
|
|
225
|
+
return;
|
|
226
|
+
}
|
|
221
227
|
|
|
222
228
|
try {
|
|
223
229
|
// Check if initReactI18next is available
|
|
@@ -246,8 +252,6 @@ const initializeI18n = () => {
|
|
|
246
252
|
debug: typeof __DEV__ !== 'undefined' && __DEV__,
|
|
247
253
|
});
|
|
248
254
|
|
|
249
|
-
isInitialized = true;
|
|
250
|
-
|
|
251
255
|
// Debug: Verify initialization
|
|
252
256
|
/* eslint-disable-next-line no-console */
|
|
253
257
|
if (typeof __DEV__ !== 'undefined' && __DEV__) {
|
|
@@ -269,6 +273,7 @@ const initializeI18n = () => {
|
|
|
269
273
|
// Initialize immediately - no need to defer
|
|
270
274
|
// React Native and React are ready when this module loads
|
|
271
275
|
// Deferring causes race conditions with useTranslation hook
|
|
276
|
+
// CRITICAL: i18n.isInitialized check prevents multiple initializations
|
|
272
277
|
initializeI18n();
|
|
273
278
|
|
|
274
279
|
export default i18n;
|