@umituz/react-native-localization 1.16.0 → 1.16.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@umituz/react-native-localization",
3
- "version": "1.16.0",
3
+ "version": "1.16.2",
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",
@@ -1,24 +1,73 @@
1
1
  /**
2
- * Auto-loader for en-US translation modules
2
+ * en-US Translation Module
3
3
  *
4
- * Uses @umituz/react-native-filesystem for professional module loading
5
- * - Auto-discovers all .json files in this directory
6
- * - Zero manual updates needed when adding new translation files
7
- * - Type-safe with TypeScript
8
- *
9
- * USAGE:
10
- * 1. Create new translation file: my_domain.json
11
- * 2. File is auto-discovered and loaded
12
- * 3. Access via t('my_domain.key')
4
+ * Direct loading for maximum compatibility across platforms
5
+ * - Explicit imports for reliable bundling
6
+ * - Flattened with dot notation
7
+ * - Production-ready and tested
8
+ */
9
+
10
+ import alerts from './alerts.json';
11
+ import auth from './auth.json';
12
+ import branding from './branding.json';
13
+ import clipboard from './clipboard.json';
14
+ import datetime from './datetime.json';
15
+ import device from './device.json';
16
+ import editor from './editor.json';
17
+ import errors from './errors.json';
18
+ import general from './general.json';
19
+ import goals from './goals.json';
20
+ import haptics from './haptics.json';
21
+ import home from './home.json';
22
+ import navigation from './navigation.json';
23
+ import onboarding from './onboarding.json';
24
+ import projects from './projects.json';
25
+ import settings from './settings.json';
26
+ import sharing from './sharing.json';
27
+ import templates from './templates.json';
28
+
29
+ /**
30
+ * Flatten nested objects with dot notation
13
31
  */
32
+ const flattenObject = (
33
+ obj: Record<string, any>,
34
+ prefix = '',
35
+ ): Record<string, string> => {
36
+ const flattened: Record<string, string> = {};
37
+
38
+ Object.keys(obj).forEach((key) => {
39
+ const newKey = prefix ? `${prefix}.${key}` : key;
14
40
 
15
- import { loadJsonModules } from '@umituz/react-native-filesystem';
41
+ if (obj[key] && typeof obj[key] === 'object' && !Array.isArray(obj[key])) {
42
+ Object.assign(flattened, flattenObject(obj[key], newKey));
43
+ } else {
44
+ flattened[newKey] = obj[key];
45
+ }
46
+ });
16
47
 
17
- // Metro bundler require.context - auto-discover all .json files
18
- // eslint-disable-next-line @typescript-eslint/no-require-imports
19
- const translationContext = (require as any).context('./', false, /\.json$/);
48
+ return flattened;
49
+ };
20
50
 
21
- // Load all JSON modules automatically using filesystem utility
22
- const translations = loadJsonModules(translationContext);
51
+ // Create flattened translations object
52
+ const translations = {
53
+ ...flattenObject(alerts, 'alerts'),
54
+ ...flattenObject(auth, 'auth'),
55
+ ...flattenObject(branding, 'branding'),
56
+ ...flattenObject(clipboard, 'clipboard'),
57
+ ...flattenObject(datetime, 'datetime'),
58
+ ...flattenObject(device, 'device'),
59
+ ...flattenObject(editor, 'editor'),
60
+ ...flattenObject(errors, 'errors'),
61
+ ...flattenObject(general, 'general'),
62
+ ...flattenObject(goals, 'goals'),
63
+ ...flattenObject(haptics, 'haptics'),
64
+ ...flattenObject(home, 'home'),
65
+ ...flattenObject(navigation, 'navigation'),
66
+ ...flattenObject(onboarding, 'onboarding'),
67
+ ...flattenObject(projects, 'projects'),
68
+ ...flattenObject(settings, 'settings'),
69
+ ...flattenObject(sharing, 'sharing'),
70
+ ...flattenObject(templates, 'templates'),
71
+ };
23
72
 
24
73
  export default translations;