* Tweak the script to use `en-us` `.ftl` files as the source of truth. * Update `ftl-tx` to a version that can handle referencing terms with arguments.
This commit is contained in:
parent
88d4598fce
commit
7c1eb0c3f1
3 changed files with 10 additions and 21 deletions
|
@ -40,15 +40,6 @@ async function getFTL() {
|
||||||
}
|
}
|
||||||
|
|
||||||
for (let sourceFileBaseName of sourceFileBaseNames) {
|
for (let sourceFileBaseName of sourceFileBaseNames) {
|
||||||
const ftlFilePath = join(getLocaleDir(locale), sourceFileBaseName + '.ftl');
|
|
||||||
let jsonFromLocalFTL = {};
|
|
||||||
try {
|
|
||||||
const ftl = await fs.readFile(ftlFilePath, 'utf8');
|
|
||||||
jsonFromLocalFTL = ftlToJSON(ftl);
|
|
||||||
}
|
|
||||||
catch (e) {
|
|
||||||
// no local .ftl file
|
|
||||||
}
|
|
||||||
let baseFTL;
|
let baseFTL;
|
||||||
let jsonFromEnUSFTL = {};
|
let jsonFromEnUSFTL = {};
|
||||||
|
|
||||||
|
@ -61,8 +52,7 @@ async function getFTL() {
|
||||||
throw new Error(`No en-US .ftl file for ${sourceFileBaseName}.ftl`);
|
throw new Error(`No en-US .ftl file for ${sourceFileBaseName}.ftl`);
|
||||||
}
|
}
|
||||||
|
|
||||||
const mergedSourceJSON = { ...jsonFromEnUSFTL, ...jsonFromLocalFTL };
|
const sourceKeys = Object.keys(jsonFromEnUSFTL);
|
||||||
const sourceKeys = Object.keys(mergedSourceJSON);
|
|
||||||
const translated = new Map();
|
const translated = new Map();
|
||||||
|
|
||||||
for (let key of sourceKeys) {
|
for (let key of sourceKeys) {
|
||||||
|
@ -71,7 +61,7 @@ async function getFTL() {
|
||||||
translated.set(key, jsonFromTransifex[key]);
|
translated.set(key, jsonFromTransifex[key]);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
translated.set(key, mergedSourceJSON[key]);
|
translated.set(key, jsonFromEnUSFTL[key]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
15
package-lock.json
generated
15
package-lock.json
generated
|
@ -40,7 +40,7 @@
|
||||||
"eslint-plugin-react": "^7.28.0",
|
"eslint-plugin-react": "^7.28.0",
|
||||||
"eslint-plugin-react-hooks": "^4.0.4",
|
"eslint-plugin-react-hooks": "^4.0.4",
|
||||||
"fs-extra": "^3.0.1",
|
"fs-extra": "^3.0.1",
|
||||||
"ftl-tx": "^0.15.1",
|
"ftl-tx": "^0.16.0",
|
||||||
"globby": "^6.1.0",
|
"globby": "^6.1.0",
|
||||||
"jspath": "^0.4.0",
|
"jspath": "^0.4.0",
|
||||||
"mocha": "^10.4.0",
|
"mocha": "^10.4.0",
|
||||||
|
@ -3667,11 +3667,10 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/ftl-tx": {
|
"node_modules/ftl-tx": {
|
||||||
"version": "0.15.1",
|
"version": "0.16.0",
|
||||||
"resolved": "https://registry.npmjs.org/ftl-tx/-/ftl-tx-0.15.1.tgz",
|
"resolved": "https://registry.npmjs.org/ftl-tx/-/ftl-tx-0.16.0.tgz",
|
||||||
"integrity": "sha512-NEaZVw0nVGy+TK7GpZx8q4u99eUbkg0Yhsh9c9r/kgnPIfHFrS/v9kn8YBDYxwBe/CqmnGPmOuuwXUGdILjSNQ==",
|
"integrity": "sha512-vQgx4oRtBCoVhoda5vSwRF50ukR1+U027on3ncehFsNFAehNfZfe6WzJZpyMXip1IbswPcoF4haAtlLkbvubcA==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "AGPL-3.0",
|
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@fluent/syntax": "^0.19.0"
|
"@fluent/syntax": "^0.19.0"
|
||||||
}
|
}
|
||||||
|
@ -10586,9 +10585,9 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"ftl-tx": {
|
"ftl-tx": {
|
||||||
"version": "0.15.1",
|
"version": "0.16.0",
|
||||||
"resolved": "https://registry.npmjs.org/ftl-tx/-/ftl-tx-0.15.1.tgz",
|
"resolved": "https://registry.npmjs.org/ftl-tx/-/ftl-tx-0.16.0.tgz",
|
||||||
"integrity": "sha512-NEaZVw0nVGy+TK7GpZx8q4u99eUbkg0Yhsh9c9r/kgnPIfHFrS/v9kn8YBDYxwBe/CqmnGPmOuuwXUGdILjSNQ==",
|
"integrity": "sha512-vQgx4oRtBCoVhoda5vSwRF50ukR1+U027on3ncehFsNFAehNfZfe6WzJZpyMXip1IbswPcoF4haAtlLkbvubcA==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
"@fluent/syntax": "^0.19.0"
|
"@fluent/syntax": "^0.19.0"
|
||||||
|
|
|
@ -49,7 +49,7 @@
|
||||||
"eslint-plugin-react": "^7.28.0",
|
"eslint-plugin-react": "^7.28.0",
|
||||||
"eslint-plugin-react-hooks": "^4.0.4",
|
"eslint-plugin-react-hooks": "^4.0.4",
|
||||||
"fs-extra": "^3.0.1",
|
"fs-extra": "^3.0.1",
|
||||||
"ftl-tx": "^0.15.1",
|
"ftl-tx": "^0.16.0",
|
||||||
"globby": "^6.1.0",
|
"globby": "^6.1.0",
|
||||||
"jspath": "^0.4.0",
|
"jspath": "^0.4.0",
|
||||||
"mocha": "^10.4.0",
|
"mocha": "^10.4.0",
|
||||||
|
|
Loading…
Add table
Reference in a new issue