@umituz/react-native-localization 2.2.0 → 2.2.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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@umituz/react-native-localization",
3
- "version": "2.2.0",
3
+ "version": "2.2.1",
4
4
  "description": "English-only localization system for React Native apps with i18n support",
5
5
  "main": "./src/index.ts",
6
6
  "types": "./src/index.ts",
@@ -14,24 +14,13 @@ import i18n from '../config/i18n';
14
14
  * Hook for translation functionality
15
15
  */
16
16
  export const useTranslationFunction = (): ((key: string, options?: any) => string) => {
17
- // Always call useTranslation hook (React hooks rules)
18
- const translationResult = useTranslation(undefined, { i18n });
19
-
20
- // Use react-i18next if available, otherwise fallback to direct i18n
21
- if (translationResult?.t && typeof translationResult.t === 'function' && i18n.isInitialized) {
22
- return (key: string, options?: any): string => {
23
- const result = translationResult.t(key, options);
17
+ // Use direct i18n.t for reliability (no React context issues)
18
+ return (key: string, options?: any): string => {
19
+ if (i18n.isInitialized && typeof i18n.t === 'function') {
20
+ const result = i18n.t(key, options);
24
21
  return typeof result === 'string' ? result : String(result);
25
- };
26
- } else {
27
- return (key: string, options?: any): string => {
28
- // Fallback to direct i18n.t
29
- if (i18n.isInitialized && typeof i18n.t === 'function') {
30
- const result = i18n.t(key, options);
31
- return typeof result === 'string' ? result : String(result);
32
- }
33
- // Final fallback: return key
34
- return key;
35
- };
36
- }
22
+ }
23
+ // Final fallback: return key
24
+ return key;
25
+ };
37
26
  };