Skip to content

Commit

Permalink
Improve process to build l10n bundle without comments (#3191)
Browse files Browse the repository at this point in the history
Signed-off-by: Timothy Johnson <timothy.johnson@broadcom.com>
Co-authored-by: Billie Simmons <BillieJean.Simmons@ibm.com>
  • Loading branch information
t1m0thyj and JillieBeanSim authored Oct 11, 2024
1 parent 647e1f9 commit 525d29d
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 14 deletions.
3 changes: 1 addition & 2 deletions packages/zowe-explorer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -1794,8 +1794,7 @@
"madge": "madge -c --no-color --no-spinner --exclude __mocks__ --extensions js,ts src/",
"pretty": "prettier --write .",
"generateLocalization": "pnpm dlx @vscode/l10n-dev export --o ./l10n ./src && node ./scripts/generatePoeditorJson.js",
"copy-secrets": "node ./scripts/getSecretsPrebuilds.js",
"strip-l10n": "node ./scripts/stripL10nComments.js"
"copy-secrets": "node ./scripts/getSecretsPrebuilds.js"
},
"engines": {
"vscode": "^1.79.0"
Expand Down
15 changes: 14 additions & 1 deletion packages/zowe-explorer/scripts/generatePoeditorJson.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*/

const fs = require("fs");
const langId = process.argv[2];
const langId = process.argv.slice(2).find(arg => !arg.startsWith("-"));
const fileSuffix = langId ? `${langId}.json` : "json";
const poeditorJson = {};
const packageNls = require(__dirname + "/../package.nls." + fileSuffix);
Expand All @@ -25,3 +25,16 @@ for (const [k, v] of Object.entries(l10nBundle)) {
}
}
fs.writeFileSync(__dirname + "/../l10n/poeditor." + fileSuffix, JSON.stringify(poeditorJson, null, 2) + "\n");

if (process.argv.includes("--strip")) {
// Strip comments out of bundle.l10n.json and sort properties by key
const jsonFilePath = __dirname + "/../l10n/bundle.l10n.json";
let l10nBundle = JSON.parse(fs.readFileSync(jsonFilePath, "utf-8"));
for (const [k, v] of Object.entries(l10nBundle)) {
if (typeof v === "object") {
l10nBundle[k] = l10nBundle[k].message;
}
}
l10nBundle = Object.fromEntries(Object.entries(l10nBundle).sort(([a], [b]) => a.localeCompare(b)));
fs.writeFileSync(jsonFilePath, JSON.stringify(l10nBundle, null, 2) + "\n");
}
11 changes: 0 additions & 11 deletions packages/zowe-explorer/scripts/stripL10nComments.js

This file was deleted.

0 comments on commit 525d29d

Please sign in to comment.