@terrafirmagreg-team/translate 1.2.0 → 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.
- package/package.json +6 -6
- package/src/lib/locales.ts +11 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@terrafirmagreg-team/translate",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.2",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Localization runtime and catalogs",
|
|
6
6
|
"license": "LGPL-3.0-only",
|
|
@@ -30,12 +30,12 @@
|
|
|
30
30
|
"@fuma-translate/react": "1.0.2"
|
|
31
31
|
},
|
|
32
32
|
"peerDependencies": {
|
|
33
|
-
"react": "
|
|
33
|
+
"react": ">=19"
|
|
34
34
|
},
|
|
35
35
|
"devDependencies": {
|
|
36
|
-
"@types/node": "
|
|
37
|
-
"@types/react": "
|
|
38
|
-
"@types/react-dom": "
|
|
36
|
+
"@types/node": "^26.6.5",
|
|
37
|
+
"@types/react": "^19.3.0",
|
|
38
|
+
"@types/react-dom": "^19.3.0"
|
|
39
39
|
},
|
|
40
40
|
"repository": {
|
|
41
41
|
"type": "git",
|
|
@@ -45,4 +45,4 @@
|
|
|
45
45
|
"publishConfig": {
|
|
46
46
|
"access": "public"
|
|
47
47
|
}
|
|
48
|
-
}
|
|
48
|
+
}
|
package/src/lib/locales.ts
CHANGED
|
@@ -22,3 +22,14 @@ export function createLocaleCatalogs(
|
|
|
22
22
|
return catalogs;
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
+
export function createMergedLocaleCatalog(
|
|
26
|
+
modules: Record<string, unknown>,
|
|
27
|
+
): Record<string, unknown> {
|
|
28
|
+
const merged: Record<string, Record<string, unknown>> = {};
|
|
29
|
+
for (const [path, messages] of Object.entries(modules)) {
|
|
30
|
+
const lang = path.slice(path.lastIndexOf('/') + 1, -'.json'.length);
|
|
31
|
+
Object.assign(merged[lang] ??= {}, messages);
|
|
32
|
+
}
|
|
33
|
+
return merged;
|
|
34
|
+
}
|
|
35
|
+
|