Skip to content

Commit

Permalink
[GENERIC viewer] Fallback to the short-format of the language code (i…
Browse files Browse the repository at this point in the history
…ssue 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.
  • Loading branch information
Snuffleupagus committed Nov 13, 2023
1 parent 7884119 commit 3f7fd2f
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions web/genericl10n.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 3f7fd2f

Please sign in to comment.