From 2a2e6781c1346cb8b2552a521877b4608b380c5d Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Tue, 17 May 2022 17:50:22 +0100 Subject: [PATCH] Update `weblateToCounterpart` to be more resilient (#360) --- scripts/copy-res.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/scripts/copy-res.js b/scripts/copy-res.js index 2bf8ea0..a706e9c 100755 --- a/scripts/copy-res.js +++ b/scripts/copy-res.js @@ -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 {