mirror of
https://github.com/jellyfin/jellyfin-web
synced 2025-03-30 19:56:21 +00:00
Remove language normalization - use original language
Otherwise `pt-PT` is replaced by `pt`, but they have different translations.
This commit is contained in:
parent
aa418cbf41
commit
3badb21b00
2 changed files with 12 additions and 24 deletions
|
@ -60,7 +60,7 @@ const dateLocales = (locale) => ({
|
||||||
})[locale];
|
})[locale];
|
||||||
|
|
||||||
export function getLocale() {
|
export function getLocale() {
|
||||||
return dateLocales(globalize.getCurrentLocale()) || enUS;
|
return dateLocales(globalize.getCurrentLocale()) || dateLocales(globalize.getCurrentLocale().replace(/-.*/, '')) || enUS;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const localeWithSuffix = { addSuffix: true, locale: getLocale() };
|
export const localeWithSuffix = { addSuffix: true, locale: getLocale() };
|
||||||
|
|
|
@ -86,28 +86,7 @@ import * as userSettings from './settings/userSettings';
|
||||||
}
|
}
|
||||||
|
|
||||||
function normalizeLocaleName(culture) {
|
function normalizeLocaleName(culture) {
|
||||||
// TODO remove normalizations
|
return culture.replace('_', '-').toLowerCase();
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function getDictionary(module, locale) {
|
function getDictionary(module, locale) {
|
||||||
|
@ -147,15 +126,24 @@ import * as userSettings from './settings/userSettings';
|
||||||
|
|
||||||
function loadTranslation(translations, lang) {
|
function loadTranslation(translations, lang) {
|
||||||
lang = normalizeLocaleName(lang);
|
lang = normalizeLocaleName(lang);
|
||||||
|
|
||||||
let filtered = translations.filter(function (t) {
|
let filtered = translations.filter(function (t) {
|
||||||
return normalizeLocaleName(t.lang) === lang;
|
return normalizeLocaleName(t.lang) === lang;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (!filtered.length) {
|
||||||
|
lang = lang.replace(/-.*/, '');
|
||||||
|
|
||||||
|
filtered = translations.filter(function (t) {
|
||||||
|
return normalizeLocaleName(t.lang) === lang;
|
||||||
|
});
|
||||||
|
|
||||||
if (!filtered.length) {
|
if (!filtered.length) {
|
||||||
filtered = translations.filter(function (t) {
|
filtered = translations.filter(function (t) {
|
||||||
return normalizeLocaleName(t.lang) === fallbackCulture;
|
return normalizeLocaleName(t.lang) === fallbackCulture;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return new Promise(function (resolve) {
|
return new Promise(function (resolve) {
|
||||||
if (!filtered.length) {
|
if (!filtered.length) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue