@remvst/localization 1.0.0 → 1.0.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.
|
@@ -48,11 +48,11 @@ class TranslationSet {
|
|
|
48
48
|
generatedFileContent += `export type LocalizationItem = {[key in Locale]?: string};\n\n`;
|
|
49
49
|
generatedFileContent += 'export const LOCALIZATION: {[key in LocalizedKey]: LocalizationItem} = {\n';
|
|
50
50
|
for (const [key, localizedItem] of this.translations.entries()) {
|
|
51
|
-
generatedFileContent += ` ${key}: {\n`;
|
|
51
|
+
generatedFileContent += ` ${JSON.stringify(key)}: {\n`;
|
|
52
52
|
for (const [locale, translation] of localizedItem.entries()) {
|
|
53
53
|
if (!translation)
|
|
54
54
|
continue;
|
|
55
|
-
generatedFileContent += ` ${locale}: ${JSON.stringify(translation)},\n`;
|
|
55
|
+
generatedFileContent += ` ${JSON.stringify(locale)}: ${JSON.stringify(translation)},\n`;
|
|
56
56
|
}
|
|
57
57
|
generatedFileContent += ` },\n`;
|
|
58
58
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@remvst/localization",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.1",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"bin": {
|
|
@@ -10,10 +10,10 @@
|
|
|
10
10
|
"build": "rm -rf lib && tsc",
|
|
11
11
|
"prepublishOnly": "npm i && npm run build",
|
|
12
12
|
"test:polyglot": "ts-node src/index.ts index -i test/polyglot.csv -o testOut/polyglot.json -l 1",
|
|
13
|
-
"test:
|
|
14
|
-
"test:
|
|
15
|
-
"test:to-typescript": "ts-node src/index.ts to-typescript -i testOut/localization-
|
|
16
|
-
"test": "npm run test:polyglot && npm run test:
|
|
13
|
+
"test:combine-json": "ts-node src/index.ts combine-json --main=test/localization.json --out=testOut/localization-combined.json --fallback=testOut/polyglot.json -l en -l fr -l es",
|
|
14
|
+
"test:google-translate": "ts-node src/index.ts google-translate --in=testOut/localization-combined.json --out=testOut/localization-backfilled-google-translate.json -l en -l fr -l es",
|
|
15
|
+
"test:to-typescript": "ts-node src/index.ts to-typescript -i testOut/localization-combined.json -o testOut/localization.ts",
|
|
16
|
+
"test": "npm run test:polyglot && npm run test:combine-json && npm run test:to-typescript"
|
|
17
17
|
},
|
|
18
18
|
"author": "Rémi Vansteelandt",
|
|
19
19
|
"license": "UNLICENSED",
|
|
@@ -65,11 +65,11 @@ export class TranslationSet {
|
|
|
65
65
|
generatedFileContent += 'export const LOCALIZATION: {[key in LocalizedKey]: LocalizationItem} = {\n';
|
|
66
66
|
|
|
67
67
|
for (const [key, localizedItem] of this.translations.entries()) {
|
|
68
|
-
generatedFileContent += ` ${key}: {\n`;
|
|
68
|
+
generatedFileContent += ` ${JSON.stringify(key)}: {\n`;
|
|
69
69
|
|
|
70
70
|
for (const [locale, translation] of localizedItem.entries()) {
|
|
71
71
|
if (!translation) continue;
|
|
72
|
-
generatedFileContent += ` ${locale}: ${JSON.stringify(translation)},\n`;
|
|
72
|
+
generatedFileContent += ` ${JSON.stringify(locale)}: ${JSON.stringify(translation)},\n`;
|
|
73
73
|
}
|
|
74
74
|
|
|
75
75
|
generatedFileContent += ` },\n`;
|
package/test/localization.json
CHANGED
|
@@ -5,5 +5,11 @@
|
|
|
5
5
|
"back": { "en": "Back" },
|
|
6
6
|
"play": { "en": "Play" },
|
|
7
7
|
"time": { "en": "Time" },
|
|
8
|
-
"
|
|
8
|
+
"some-Fancy-Key?": { "en": "Fancy key" },
|
|
9
|
+
"backToMainMenu": { "en": "Back To Main Menu", "fr": "Retour au menu principal" },
|
|
10
|
+
"difficulty": { "en": "Difficulty" },
|
|
11
|
+
"difficultyNormal": { "en": "Normal" },
|
|
12
|
+
"difficultyHard": { "en": "Hard" },
|
|
13
|
+
"difficultyEasy": { "en": "Easy" },
|
|
14
|
+
"difficultyVeryEasy": { "en": "Very Easy" }
|
|
9
15
|
}
|