mirror of
https://github.com/jellyfin/jellyfin-web
synced 2025-03-30 19:56:21 +00:00
Merge pull request #3114 from jellyfin/fix-lang-loading
Remove language normalization - use original language
This commit is contained in:
commit
1ddcb97fcf
2 changed files with 12 additions and 24 deletions
|
@ -60,7 +60,7 @@ const dateLocales = (locale) => ({
|
|||
})[locale];
|
||||
|
||||
export function getLocale() {
|
||||
return dateLocales(globalize.getCurrentLocale()) || enUS;
|
||||
return dateLocales(globalize.getCurrentLocale()) || dateLocales(globalize.getCurrentLocale().replace(/-.*/, '')) || enUS;
|
||||
}
|
||||
|
||||
export const localeWithSuffix = { addSuffix: true, locale: getLocale() };
|
||||
|
|
|
@ -86,28 +86,7 @@ import * as userSettings from './settings/userSettings';
|
|||
}
|
||||
|
||||
function normalizeLocaleName(culture) {
|
||||
// TODO remove normalizations
|
||||
culture = culture.replace('_', '-');
|
||||
|
||||
// convert de-DE to de
|
||||
const parts = culture.split('-');
|
||||
if (parts.length === 2) {
|
||||
if (parts[0].toLowerCase() === parts[1].toLowerCase()) {
|
||||
culture = parts[0].toLowerCase();
|
||||
}
|
||||
}
|
||||
|
||||
const lower = culture.toLowerCase();
|
||||
if (lower === 'ca-es') {
|
||||
return 'ca';
|
||||
}
|
||||
|
||||
// normalize Swedish
|
||||
if (lower === 'sv-se') {
|
||||
return 'sv';
|
||||
}
|
||||
|
||||
return lower;
|
||||
return culture.replace('_', '-').toLowerCase();
|
||||
}
|
||||
|
||||
function getDictionary(module, locale) {
|
||||
|
@ -147,14 +126,23 @@ import * as userSettings from './settings/userSettings';
|
|||
|
||||
function loadTranslation(translations, lang) {
|
||||
lang = normalizeLocaleName(lang);
|
||||
|
||||
let filtered = translations.filter(function (t) {
|
||||
return normalizeLocaleName(t.lang) === lang;
|
||||
});
|
||||
|
||||
if (!filtered.length) {
|
||||
lang = lang.replace(/-.*/, '');
|
||||
|
||||
filtered = translations.filter(function (t) {
|
||||
return normalizeLocaleName(t.lang) === fallbackCulture;
|
||||
return normalizeLocaleName(t.lang) === lang;
|
||||
});
|
||||
|
||||
if (!filtered.length) {
|
||||
filtered = translations.filter(function (t) {
|
||||
return normalizeLocaleName(t.lang) === fallbackCulture;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
return new Promise(function (resolve) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue