-
Notifications
You must be signed in to change notification settings - Fork 92
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
Update dev deps and fix code smells for V3 #3130
Changes from all commits
280aa56
a3be1a8
081cbdd
d4b79f8
169f28d
afb5099
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Question for my own clarification: could we remove some of the logic in this script by defining the file suffix before looking over the entries in the JSON? E.g.: const fileSuffix = langId ? `.${langId}.json` : ".json"; Then the same file suffix could be appended to the I didn't notice much of a difference between the two branches when doing the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can create a follow up story if decided to make the updates. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,32 @@ | ||
/** | ||
* Merges package.nls.json and bundle.l10n.json into a key-value JSON file that | ||
* can be imported into POEditor. | ||
* can be imported into POEditor. Run this script without any arguments to | ||
* merge l10n templates, or specify a language ID to merge translation files. | ||
*/ | ||
|
||
const fs = require("fs"); | ||
const langId = process.argv[2]; | ||
const poeditorJson = {}; | ||
const packageNls = require(__dirname + "/../package.nls.json"); | ||
for (const [k, v] of Object.entries(packageNls)) { | ||
poeditorJson[k] = { [v]: "" }; | ||
if (!langId) { | ||
for (const [k, v] of Object.entries(packageNls)) { | ||
poeditorJson[k] = { [v]: "" }; | ||
} | ||
} else { | ||
const packageNls2 = require(__dirname + "/../package.nls." + langId + ".json"); | ||
for (const [k, v] of Object.entries(packageNls)) { | ||
poeditorJson[k] = packageNls2[k] ? { [v]: packageNls2[k] } : undefined; | ||
} | ||
} | ||
const l10nBundle = require(__dirname + "/../l10n/bundle.l10n.json"); | ||
for (const [k, v] of Object.entries(l10nBundle)) { | ||
poeditorJson[typeof v === "string" ? k : v.message] = ""; | ||
if (!langId) { | ||
for (const [k, v] of Object.entries(l10nBundle)) { | ||
poeditorJson[typeof v === "string" ? k : v.message] = ""; | ||
} | ||
} else { | ||
const l10nBundle2 = require(__dirname + "/../l10n/bundle.l10n." + langId + ".json"); | ||
for (const [k, v] of Object.entries(l10nBundle)) { | ||
poeditorJson[typeof v === "string" ? k : v.message] = l10nBundle2[k]?.message || l10nBundle2[k]; | ||
} | ||
} | ||
fs.writeFileSync(__dirname + "/../l10n/poeditor.json", JSON.stringify(poeditorJson, null, 2) + "\n"); | ||
fs.writeFileSync(__dirname + "/../l10n/poeditor." + (langId ? `${langId}.json` : "json"), JSON.stringify(poeditorJson, null, 2) + "\n"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for cleaning this logic up 😁