From 3f7fd2f035209e0b916216f9a980eae228041a79 Mon Sep 17 00:00:00 2001 From: Jonas Jenwald Date: Mon, 13 Nov 2023 09:44:01 +0100 Subject: [PATCH] [GENERIC viewer] Fallback to the short-format of the language code (issue 17269) This shouldn't cause any issues, since `GenericL10n.#createBundle` has an early return for languages that don't exist in the `locale.json` file. --- web/genericl10n.js | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/web/genericl10n.js b/web/genericl10n.js index 87feb67fe4230..05ac48209d9ee 100644 --- a/web/genericl10n.js +++ b/web/genericl10n.js @@ -45,8 +45,18 @@ class GenericL10n extends L10n { */ static async *#generateBundles(defaultLang, baseLang) { const { baseURL, paths } = await this.#getPaths(); - const langs = - baseLang === defaultLang ? [baseLang] : [baseLang, defaultLang]; + + const langs = [baseLang]; + if (defaultLang !== baseLang) { + // Also fallback to the short-format of the base language + // (see issue 17269). + const shortLang = baseLang.split("-", 1)[0]; + + if (shortLang !== baseLang) { + langs.push(shortLang); + } + langs.push(defaultLang); + } for (const lang of langs) { const bundle = await this.#createBundle(lang, baseURL, paths); if (bundle) {