mirror of https://github.com/vector-im/riot-web
Update weblateToCounterpart to be more resilient (#22247)
* Update i18n check CI to ignore RiotTranslateBot * Update `weblateToCounterpart` to be more resilientpull/22249/head
parent
aca0346f4e
commit
b3ef2c179a
|
@ -44,7 +44,10 @@ jobs:
|
||||||
files_ignore: |
|
files_ignore: |
|
||||||
src/i18n/strings/en_EN.json
|
src/i18n/strings/en_EN.json
|
||||||
- name: "Assert only en_EN was modified"
|
- 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: |
|
run: |
|
||||||
echo "You can only modify en_EN.json, do not touch any of the other i18n files as Weblate will be confused"
|
echo "You can only modify en_EN.json, do not touch any of the other i18n files as Weblate will be confused"
|
||||||
exit 1
|
exit 1
|
||||||
|
|
|
@ -232,8 +232,14 @@ function weblateToCounterpart(inTrs) {
|
||||||
if (keyParts.length === 2) {
|
if (keyParts.length === 2) {
|
||||||
let obj = outTrs[keyParts[0]];
|
let obj = outTrs[keyParts[0]];
|
||||||
if (obj === undefined) {
|
if (obj === undefined) {
|
||||||
obj = {};
|
obj = outTrs[keyParts[0]] = {};
|
||||||
outTrs[keyParts[0]] = obj;
|
} 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];
|
obj[keyParts[1]] = inTrs[key];
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in New Issue