Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve process to build l10n bundle without comments #3191

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.

Loading