1
0
Fork 0
mirror of https://github.com/jellyfin/jellyfin-web synced 2025-03-30 19:56:21 +00:00

Refactor translation method

This commit is contained in:
Bill Thornton 2021-09-08 13:11:20 -04:00
parent 1c663b7675
commit 172e06ed3f

View file

@ -187,18 +187,22 @@ import * as userSettings from './settings/userSettings';
function translateKeyFromModule(key, module) { function translateKeyFromModule(key, module) {
let dictionary = getDictionary(module, getCurrentLocale()); let dictionary = getDictionary(module, getCurrentLocale());
if (!dictionary || !dictionary[key]) { if (dictionary && dictionary[key]) {
dictionary = getDictionary(module, fallbackCulture); return dictionary[key];
} }
if (!dictionary || !dictionary[key]) {
if (dictionary && isEmpty(dictionary)) { dictionary = getDictionary(module, fallbackCulture);
console.warn('Translation dictionary is empty.'); if (dictionary && dictionary[key]) {
} else { return dictionary[key];
console.error(`Translation key is missing from dictionary: ${key}`);
}
return key;
} }
return dictionary[key];
if (!dictionary || isEmpty(dictionary)) {
console.warn('Translation dictionary is empty.');
} else {
console.error(`Translation key is missing from dictionary: ${key}`);
}
return key;
} }
function replaceAll(str, find, replace) { function replaceAll(str, find, replace) {