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:
parent
1c663b7675
commit
172e06ed3f
1 changed files with 14 additions and 10 deletions
|
@ -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) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue