[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.
This commit is contained in:
Jonas Jenwald 2023-11-13 09:44:01 +01:00
parent 7884119975
commit 3f7fd2f035

View File

@ -45,8 +45,18 @@ class GenericL10n extends L10n {
*/ */
static async *#generateBundles(defaultLang, baseLang) { static async *#generateBundles(defaultLang, baseLang) {
const { baseURL, paths } = await this.#getPaths(); 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) { for (const lang of langs) {
const bundle = await this.#createBundle(lang, baseURL, paths); const bundle = await this.#createBundle(lang, baseURL, paths);
if (bundle) { if (bundle) {