diff --git a/web/genericl10n.js b/web/genericl10n.js index 323e430aef3e4a..d075d59586d05c 100644 --- a/web/genericl10n.js +++ b/web/genericl10n.js @@ -16,9 +16,31 @@ /** @typedef {import("./interfaces").IL10n} IL10n */ import "../external/webL10n/l10n.js"; -import { fixupLangCode, getL10nFallback } from "./l10n_utils.js"; +import { getL10nFallback } from "./l10n_utils.js"; -const webL10n = document.webL10n; +const { webL10n } = document; + +const PARTIAL_LANG_CODES = { + en: "en-US", + es: "es-ES", + fy: "fy-NL", + ga: "ga-IE", + gu: "gu-IN", + hi: "hi-IN", + hy: "hy-AM", + nb: "nb-NO", + ne: "ne-NP", + nn: "nn-NO", + pa: "pa-IN", + pt: "pt-PT", + sv: "sv-SE", + zh: "zh-CN", +}; + +// Try to support "incompletely" specified language codes (see issue 13689). +function fixupLangCode(langCode) { + return PARTIAL_LANG_CODES[langCode?.toLowerCase()] || langCode; +} /** * @implements {IL10n} diff --git a/web/l10n_utils.js b/web/l10n_utils.js index c4931135be9c04..11663c22ff08c1 100644 --- a/web/l10n_utils.js +++ b/web/l10n_utils.js @@ -99,28 +99,6 @@ function getL10nFallback(key, args) { return DEFAULT_L10N_STRINGS[key] || ""; } -const PARTIAL_LANG_CODES = { - en: "en-US", - es: "es-ES", - fy: "fy-NL", - ga: "ga-IE", - gu: "gu-IN", - hi: "hi-IN", - hy: "hy-AM", - nb: "nb-NO", - ne: "ne-NP", - nn: "nn-NO", - pa: "pa-IN", - pt: "pt-PT", - sv: "sv-SE", - zh: "zh-CN", -}; - -// Try to support "incompletely" specified language codes (see issue 13689). -function fixupLangCode(langCode) { - return PARTIAL_LANG_CODES[langCode?.toLowerCase()] || langCode; -} - // Replaces {{arguments}} with their values. function formatL10nValue(text, args) { if (!args) { @@ -151,4 +129,4 @@ const NullL10n = { async translate(element) {}, }; -export { fixupLangCode, getL10nFallback, NullL10n }; +export { getL10nFallback, NullL10n };