Update weblateToCounterpart to be more resilient (#360)

This commit is contained in:
Michael Telatynski 2022-05-17 17:50:22 +01:00 committed by GitHub
parent 970832ccfe
commit 2a2e6781c1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -74,8 +74,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 {