Merge pull request #17270 from Snuffleupagus/issue-17269

[GENERIC viewer] Fallback to the short-format of the language code (issue 17269)
This commit is contained in:
Jonas Jenwald 2023-11-13 11:10:33 +01:00 committed by GitHub
commit 7b89e7e0d2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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) {