@umituz/react-native-localization 1.2.1 → 1.2.2

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.
@@ -1 +1 @@
1
- {"version":3,"file":"i18n.d.ts","sourceRoot":"","sources":["../../../src/infrastructure/config/i18n.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,IAAI,MAAM,SAAS,CAAC;AAmD3B,eAAe,IAAI,CAAC"}
1
+ {"version":3,"file":"i18n.d.ts","sourceRoot":"","sources":["../../../src/infrastructure/config/i18n.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,IAAI,MAAM,SAAS,CAAC;AA6F3B,eAAe,IAAI,CAAC"}
@@ -32,18 +32,61 @@ const resources = {
32
32
  };
33
33
  /**
34
34
  * Initialize i18next
35
+ * Deferred initialization to avoid React Native renderer conflicts
35
36
  */
36
- i18n.use(initReactI18next).init({
37
- resources,
38
- lng: DEFAULT_LANGUAGE,
39
- fallbackLng: DEFAULT_LANGUAGE,
40
- interpolation: {
41
- escapeValue: false, // React already escapes values
42
- },
43
- react: {
44
- useSuspense: false, // Disable suspense for React Native
45
- },
46
- compatibilityJSON: 'v4', // Use i18next v4 JSON format
47
- });
37
+ let isInitialized = false;
38
+ const initializeI18n = () => {
39
+ if (isInitialized)
40
+ return;
41
+ try {
42
+ /* eslint-disable-next-line no-console */
43
+ if (__DEV__)
44
+ console.log('[i18n] Initializing i18next...');
45
+ // Check if initReactI18next is available
46
+ if (!initReactI18next) {
47
+ throw new Error('initReactI18next is undefined');
48
+ }
49
+ /* eslint-disable-next-line no-console */
50
+ if (__DEV__)
51
+ console.log('[i18n] initReactI18next found, initializing...');
52
+ i18n.use(initReactI18next).init({
53
+ resources,
54
+ lng: DEFAULT_LANGUAGE,
55
+ fallbackLng: DEFAULT_LANGUAGE,
56
+ interpolation: {
57
+ escapeValue: false, // React already escapes values
58
+ },
59
+ react: {
60
+ useSuspense: false, // Disable suspense for React Native
61
+ },
62
+ compatibilityJSON: 'v4', // Use i18next v4 JSON format
63
+ });
64
+ isInitialized = true;
65
+ /* eslint-disable-next-line no-console */
66
+ if (__DEV__)
67
+ console.log('[i18n] i18next initialized successfully');
68
+ }
69
+ catch (error) {
70
+ /* eslint-disable-next-line no-console */
71
+ if (__DEV__)
72
+ console.error('[i18n] Initialization error:', error);
73
+ // Don't throw - allow app to continue without i18n
74
+ /* eslint-disable-next-line no-console */
75
+ if (__DEV__)
76
+ console.warn('[i18n] Continuing without i18n initialization');
77
+ }
78
+ };
79
+ // Defer initialization until React is ready
80
+ // React Native doesn't have window, so we check for global
81
+ if (typeof global !== 'undefined') {
82
+ // Use setTimeout to defer initialization
83
+ setTimeout(() => {
84
+ initializeI18n();
85
+ }, 0);
86
+ }
87
+ else {
88
+ // Fallback: initialize immediately
89
+ initializeI18n();
90
+ }
48
91
  export default i18n;
49
92
  //# sourceMappingURL=i18n.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"i18n.js","sourceRoot":"","sources":["../../../src/infrastructure/config/i18n.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,IAAI,MAAM,SAAS,CAAC;AAC3B,OAAO,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AACjD,OAAO,EAAuB,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAEpE;;;;;;;;;;GAUG;AAEH,yDAAyD;AACzD,OAAO,gBAAgB,MAAM,kBAAkB,CAAC;AAEhD;;;;GAIG;AACH,MAAM,SAAS,GAAG;IAChB,OAAO,EAAE;QACP,WAAW,EAAE;YACX,GAAG,gBAAgB;SACpB;KACF;CACF,CAAC;AAEF;;GAEG;AACH,IAAI,CAAC,GAAG,CAAC,gBAAgB,CAAC,CAAC,IAAI,CAAC;IAC9B,SAAS;IACT,GAAG,EAAE,gBAAgB;IACrB,WAAW,EAAE,gBAAgB;IAE7B,aAAa,EAAE;QACb,WAAW,EAAE,KAAK,EAAE,+BAA+B;KACpD;IAED,KAAK,EAA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,iBAAiB,EAAE,IAAI,EAAE,6BAA6B;SACvD,CAAC,CAAC;QAEH,aAAa,GAAG,IAAI,CAAC;QACrB,yCAAyC;QACzC,IAAI,OAAO;YAAE,OAAO,CAAC,GAAG,CAAC,yCAAyC,CAAC,CAAC;IACtE,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,yCAAyC;QACzC,IAAI,OAAO;YAAE,OAAO,CAAC,KAAK,CAAC,8BAA8B,EAAE,KAAK,CAAC,CAAC;QAClE,mDAAmD;QACnD,yCAAyC;QACzC,IAAI,OAAO;YAAE,OAAO,CAAC,IAAI,CAAC,+CAA+C,CAAC,CAAC;IAC7E,CAAC;AACH,CAAC,CAAC;AAEF,4CAA4C;AAC5C,2DAA2D;AAC3D,IAAI,OAAO,MAAM,KAAK,WAAW,EAAE,CAAC;IAClC,yCAAyC;IACzC,UAAU,CAAC,GAAG,EAAE;QACd,cAAc,EAAE,CAAC;IACnB,CAAC,EAAE,CAAC,CAAC,CAAC;AACR,CAAC;KAAM,CAAC;IACN,mCAAmC;IACnC,cAAc,EAAE,CAAC;AACnB,CAAC;AAED,eAAe,IAAI,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@umituz/react-native-localization",
3
- "version": "1.2.1",
3
+ "version": "1.2.2",
4
4
  "description": "Universal localization system for React Native apps with i18n support",
5
5
  "main": "./lib/index.js",
6
6
  "types": "./lib/index.d.ts",
@@ -37,21 +37,63 @@ const resources = {
37
37
 
38
38
  /**
39
39
  * Initialize i18next
40
+ * Deferred initialization to avoid React Native renderer conflicts
40
41
  */
41
- i18n.use(initReactI18next).init({
42
- resources,
43
- lng: DEFAULT_LANGUAGE,
44
- fallbackLng: DEFAULT_LANGUAGE,
42
+ let isInitialized = false;
45
43
 
46
- interpolation: {
47
- escapeValue: false, // React already escapes values
48
- },
44
+ const initializeI18n = () => {
45
+ if (isInitialized) return;
49
46
 
50
- react: {
51
- useSuspense: false, // Disable suspense for React Native
52
- },
47
+ try {
48
+ /* eslint-disable-next-line no-console */
49
+ if (__DEV__) console.log('[i18n] Initializing i18next...');
50
+
51
+ // Check if initReactI18next is available
52
+ if (!initReactI18next) {
53
+ throw new Error('initReactI18next is undefined');
54
+ }
55
+
56
+ /* eslint-disable-next-line no-console */
57
+ if (__DEV__) console.log('[i18n] initReactI18next found, initializing...');
58
+
59
+ i18n.use(initReactI18next).init({
60
+ resources,
61
+ lng: DEFAULT_LANGUAGE,
62
+ fallbackLng: DEFAULT_LANGUAGE,
63
+
64
+ interpolation: {
65
+ escapeValue: false, // React already escapes values
66
+ },
67
+
68
+ react: {
69
+ useSuspense: false, // Disable suspense for React Native
70
+ },
71
+
72
+ compatibilityJSON: 'v4', // Use i18next v4 JSON format
73
+ });
74
+
75
+ isInitialized = true;
76
+ /* eslint-disable-next-line no-console */
77
+ if (__DEV__) console.log('[i18n] i18next initialized successfully');
78
+ } catch (error) {
79
+ /* eslint-disable-next-line no-console */
80
+ if (__DEV__) console.error('[i18n] Initialization error:', error);
81
+ // Don't throw - allow app to continue without i18n
82
+ /* eslint-disable-next-line no-console */
83
+ if (__DEV__) console.warn('[i18n] Continuing without i18n initialization');
84
+ }
85
+ };
53
86
 
54
- compatibilityJSON: 'v4', // Use i18next v4 JSON format
55
- });
87
+ // Defer initialization until React is ready
88
+ // React Native doesn't have window, so we check for global
89
+ if (typeof global !== 'undefined') {
90
+ // Use setTimeout to defer initialization
91
+ setTimeout(() => {
92
+ initializeI18n();
93
+ }, 0);
94
+ } else {
95
+ // Fallback: initialize immediately
96
+ initializeI18n();
97
+ }
56
98
 
57
99
  export default i18n;