Browse Source

Update weblateToCounterpart to be more resilient (#22247)

* Update i18n check CI to ignore RiotTranslateBot

* Update `weblateToCounterpart` to be more resilient
pull/22249/head
Michael Telatynski 1 month ago committed by GitHub
parent
commit
b3ef2c179a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 5
      .github/workflows/static_analysis.yaml
  2. 10
      scripts/copy-res.js

5
.github/workflows/static_analysis.yaml

@ -44,7 +44,10 @@ jobs:
files_ignore: |
src/i18n/strings/en_EN.json
- name: "Assert only en_EN was modified"
if: github.event_name == 'pull_request' && steps.changed_files.outputs.any_modified == 'true'
if: |
github.event_name == 'pull_request' &&
github.actor != 'RiotTranslateBot' &&
steps.changed_files.outputs.any_modified == 'true'
run: |
echo "You can only modify en_EN.json, do not touch any of the other i18n files as Weblate will be confused"
exit 1

10
scripts/copy-res.js

@ -232,8 +232,14 @@ function weblateToCounterpart(inTrs) {
if (keyParts.length === 2) {
let obj = outTrs[keyParts[0]];
if (obj === undefined) {
obj = {};
outTrs[keyParts[0]] = obj;
obj = outTrs[keyParts[0]] = {};
} else if (typeof obj === "string") {
// This is a transitional edge case if a string went from singular to pluralised and both still remain
// in the translation json file. Use the singular translation as `other` and merge pluralisation atop.
obj = outTrs[keyParts[0]] = {
"other": inTrs[key],
};
console.warn("Found entry in i18n file in both singular and pluralised form", keyParts[0]);
}
obj[keyParts[1]] = inTrs[key];
} else {

Loading…
Cancel
Save