Special case English translation fallback
We should not be listing this in LINGUAS as that gives the impression
that English has en explicit translation. Instead, it is a special case
that the code needs to be explicitly aware of.
This reverts 9a06058
in favour of a more robust fix.
This commit is contained in:
parent
747603c0d5
commit
a4453c9a26
|
@ -40,12 +40,6 @@ export class Localizer {
|
|||
.replace("_", "-")
|
||||
.split("-");
|
||||
|
||||
// Built-in default?
|
||||
if ((userLang[0] === 'en') &&
|
||||
((userLang[1] === undefined) || (userLang[1] === 'us'))) {
|
||||
return;
|
||||
}
|
||||
|
||||
// First pass: perfect match
|
||||
for (let j = 0; j < supportedLanguages.length; j++) {
|
||||
const supLang = supportedLanguages[j]
|
||||
|
@ -64,7 +58,12 @@ export class Localizer {
|
|||
return;
|
||||
}
|
||||
|
||||
// Second pass: fallback
|
||||
// Second pass: English fallback
|
||||
if (userLang[0] === 'en') {
|
||||
return;
|
||||
}
|
||||
|
||||
// Third pass pass: other fallback
|
||||
for (let j = 0;j < supportedLanguages.length;j++) {
|
||||
const supLang = supportedLanguages[j]
|
||||
.toLowerCase()
|
||||
|
|
|
@ -1762,7 +1762,7 @@ const UI = {
|
|||
};
|
||||
|
||||
// Set up translations
|
||||
const LINGUAS = ["cs", "de", "el", "en", "es", "fr", "it", "ja", "ko", "nl", "pl", "pt_BR", "ru", "sv", "tr", "zh_CN", "zh_TW"];
|
||||
const LINGUAS = ["cs", "de", "el", "es", "fr", "it", "ja", "ko", "nl", "pl", "pt_BR", "ru", "sv", "tr", "zh_CN", "zh_TW"];
|
||||
l10n.setup(LINGUAS);
|
||||
if (l10n.language === "en" || l10n.dictionary !== undefined) {
|
||||
UI.prime();
|
||||
|
|
|
@ -27,6 +27,16 @@ describe('Localization', function () {
|
|||
l10n.setup(["es", "fr"]);
|
||||
expect(l10n.language).to.equal('en');
|
||||
});
|
||||
it('should fall back to generic English for other English', function () {
|
||||
window.navigator.languages = ["en-AU", "de"];
|
||||
l10n.setup(["de", "fr", "en-GB"]);
|
||||
expect(l10n.language).to.equal('en');
|
||||
});
|
||||
it('should prefer specific English over generic', function () {
|
||||
window.navigator.languages = ["en-GB", "de"];
|
||||
l10n.setup(["de", "en-AU", "en-GB"]);
|
||||
expect(l10n.language).to.equal('en-GB');
|
||||
});
|
||||
it('should use the most preferred user language', function () {
|
||||
window.navigator.languages = ["nl", "de", "fr"];
|
||||
l10n.setup(["es", "fr", "de"]);
|
||||
|
|
Loading…
Reference in New Issue