@umituz/react-native-localization 1.3.1 → 1.3.3
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/lib/infrastructure/config/i18n.d.ts.map +1 -1
- package/lib/infrastructure/config/i18n.js +3 -1
- package/lib/infrastructure/config/i18n.js.map +1 -1
- package/package.json +1 -1
- package/scripts/setup-languages.js +4 -34
- package/scripts/utils/findLocalesDir.js +12 -9
- package/src/infrastructure/config/i18n.ts +3 -1
|
@@ -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;
|
|
1
|
+
{"version":3,"file":"i18n.d.ts","sourceRoot":"","sources":["../../../src/infrastructure/config/i18n.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,IAAI,MAAM,SAAS,CAAC;AA+F3B,eAAe,IAAI,CAAC"}
|
|
@@ -59,7 +59,9 @@ const initializeI18n = () => {
|
|
|
59
59
|
react: {
|
|
60
60
|
useSuspense: false, // Disable suspense for React Native
|
|
61
61
|
},
|
|
62
|
-
compatibilityJSON: '
|
|
62
|
+
compatibilityJSON: 'v3', // Use v3 format for React Native (no Intl.PluralRules support)
|
|
63
|
+
pluralSeparator: '_', // Use underscore separator for plural keys
|
|
64
|
+
keySeparator: '.', // Use dot separator for nested keys
|
|
63
65
|
});
|
|
64
66
|
isInitialized = true;
|
|
65
67
|
/* eslint-disable-next-line no-console */
|
|
@@ -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,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,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
|
@@ -54,40 +54,11 @@ async function setupLanguages() {
|
|
|
54
54
|
|
|
55
55
|
console.log("🚀 Setting up language directories and files...\n");
|
|
56
56
|
|
|
57
|
-
//
|
|
57
|
+
// Check if en-US directory exists
|
|
58
58
|
if (!fs.existsSync(enUSDir)) {
|
|
59
|
-
|
|
60
|
-
console.
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
// Get default files from localization package
|
|
64
|
-
const packageRoot = path.dirname(require.resolve('@umituz/react-native-localization/package.json'));
|
|
65
|
-
const packageEnUSDir = path.join(packageRoot, 'src/infrastructure/locales/en-US');
|
|
66
|
-
const defaultFiles = [
|
|
67
|
-
'auth.json',
|
|
68
|
-
'branding.json',
|
|
69
|
-
'datetime.json',
|
|
70
|
-
'errors.json',
|
|
71
|
-
'general.json',
|
|
72
|
-
'navigation.json',
|
|
73
|
-
'onboarding.json',
|
|
74
|
-
'settings.json',
|
|
75
|
-
];
|
|
76
|
-
|
|
77
|
-
// Copy default files from package if they don't exist in project
|
|
78
|
-
let copiedFiles = 0;
|
|
79
|
-
if (fs.existsSync(packageEnUSDir)) {
|
|
80
|
-
for (const file of defaultFiles) {
|
|
81
|
-
const packageFile = path.join(packageEnUSDir, file);
|
|
82
|
-
const projectFile = path.join(enUSDir, file);
|
|
83
|
-
|
|
84
|
-
if (fs.existsSync(packageFile) && !fs.existsSync(projectFile)) {
|
|
85
|
-
const content = fs.readFileSync(packageFile, "utf8");
|
|
86
|
-
fs.writeFileSync(projectFile, content);
|
|
87
|
-
console.log(`📄 Copied default file: en-US/${file}`);
|
|
88
|
-
copiedFiles++;
|
|
89
|
-
}
|
|
90
|
-
}
|
|
59
|
+
console.error("❌ en-US directory not found!");
|
|
60
|
+
console.error(" Expected path:", enUSDir);
|
|
61
|
+
process.exit(1);
|
|
91
62
|
}
|
|
92
63
|
|
|
93
64
|
// Automatically discover all JSON files in en-US directory
|
|
@@ -98,7 +69,6 @@ async function setupLanguages() {
|
|
|
98
69
|
|
|
99
70
|
if (files.length === 0) {
|
|
100
71
|
console.error("❌ No JSON files found in en-US directory!");
|
|
101
|
-
console.error(" Please add translation files to:", enUSDir);
|
|
102
72
|
process.exit(1);
|
|
103
73
|
}
|
|
104
74
|
|
|
@@ -14,16 +14,16 @@ const path = require('path');
|
|
|
14
14
|
function findLocalesDir() {
|
|
15
15
|
const projectRoot = process.cwd();
|
|
16
16
|
|
|
17
|
-
// Common paths to search
|
|
17
|
+
// Common paths to search
|
|
18
18
|
const possiblePaths = [
|
|
19
|
-
// Simple structure (preferred)
|
|
20
|
-
path.join(projectRoot, 'src/locales'),
|
|
21
|
-
path.join(projectRoot, 'locales'),
|
|
22
|
-
path.join(projectRoot, 'translations'),
|
|
23
19
|
// DDD structure
|
|
24
20
|
path.join(projectRoot, 'src/domains/localization/infrastructure/locales'),
|
|
25
21
|
path.join(projectRoot, 'src/domains/i18n/infrastructure/locales'),
|
|
26
22
|
path.join(projectRoot, 'src/infrastructure/localization/locales'),
|
|
23
|
+
// Simple structure
|
|
24
|
+
path.join(projectRoot, 'src/locales'),
|
|
25
|
+
path.join(projectRoot, 'locales'),
|
|
26
|
+
path.join(projectRoot, 'translations'),
|
|
27
27
|
// Alternative DDD
|
|
28
28
|
path.join(projectRoot, 'src/features/localization/locales'),
|
|
29
29
|
];
|
|
@@ -49,22 +49,25 @@ function getLocalesDir(createIfNotExists = false) {
|
|
|
49
49
|
|
|
50
50
|
if (!localesDir) {
|
|
51
51
|
if (createIfNotExists) {
|
|
52
|
-
// Try to create in most common location
|
|
52
|
+
// Try to create in most common location
|
|
53
53
|
const projectRoot = process.cwd();
|
|
54
|
-
|
|
55
|
-
|
|
54
|
+
localesDir = path.join(projectRoot, 'src/domains/localization/infrastructure/locales');
|
|
55
|
+
const enUSDir = path.join(localesDir, 'en-US');
|
|
56
|
+
|
|
56
57
|
if (!fs.existsSync(localesDir)) {
|
|
57
58
|
fs.mkdirSync(localesDir, { recursive: true });
|
|
59
|
+
fs.mkdirSync(enUSDir, { recursive: true });
|
|
58
60
|
console.log(`✅ Created locales directory: ${localesDir}`);
|
|
59
61
|
}
|
|
62
|
+
|
|
60
63
|
return localesDir;
|
|
61
64
|
}
|
|
62
65
|
|
|
63
66
|
console.error('❌ Locales directory not found!');
|
|
64
67
|
console.error('\nPlease create a locales directory in one of these locations:');
|
|
68
|
+
console.error(' - src/domains/localization/infrastructure/locales');
|
|
65
69
|
console.error(' - src/locales');
|
|
66
70
|
console.error(' - locales');
|
|
67
|
-
console.error(' - src/domains/localization/infrastructure/locales');
|
|
68
71
|
console.error('\nOr run: npm run i18n:setup');
|
|
69
72
|
process.exit(1);
|
|
70
73
|
}
|
|
@@ -69,7 +69,9 @@ const initializeI18n = () => {
|
|
|
69
69
|
useSuspense: false, // Disable suspense for React Native
|
|
70
70
|
},
|
|
71
71
|
|
|
72
|
-
compatibilityJSON: '
|
|
72
|
+
compatibilityJSON: 'v3', // Use v3 format for React Native (no Intl.PluralRules support)
|
|
73
|
+
pluralSeparator: '_', // Use underscore separator for plural keys
|
|
74
|
+
keySeparator: '.', // Use dot separator for nested keys
|
|
73
75
|
});
|
|
74
76
|
|
|
75
77
|
isInitialized = true;
|