Skip to content

Commit

Permalink
Improve process to build l10n bundle without comments
Browse files Browse the repository at this point in the history
Signed-off-by: Timothy Johnson <timothy.johnson@broadcom.com>
  • Loading branch information
t1m0thyj committed Oct 4, 2024
1 parent 77235a3 commit 00e96ab
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 @@ -1796,8 +1796,7 @@
"createTestProfileData": "tsx ./scripts/createTestProfileData.ts",
"createDemoNodes": "tsx ./scripts/createDemoNodes.ts",
"generateLocalization": "pnpm dlx @vscode/l10n-dev export --o ./l10n ./src && node ./scripts/generatePoeditorJson.js",
"copy-secrets": "tsx ./scripts/getSecretsPrebuilds.ts",
"strip-l10n": "node ./scripts/stripL10nComments.js"
"copy-secrets": "tsx ./scripts/getSecretsPrebuilds.ts"
},
"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 00e96ab

Please sign in to comment.