Move the fixupLangCode helper function into the web/genericl10n.js file

This helper function was added almost two years ago, in PR 13696, and it still has only a single call-site. Furthermore, with the changes made in PR 16572 it also cannot hurt to reduce the size of the `web/l10n_utils.js` file slightly.
This commit is contained in:
Jonas Jenwald 2023-06-20 21:26:59 +02:00
parent 24b2c3a5e3
commit fe1c36a0ed
2 changed files with 25 additions and 25 deletions

View File

@ -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}

View File

@ -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 };