Merge pull request #2939 from thornbill/translation-error-log

Log warning instead of error when dictionary has not loaded
This commit is contained in:
Bill Thornton 2021-09-09 10:39:58 -04:00 committed by GitHub
commit 8dd6516024
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1,5 +1,7 @@
import * as userSettings from './settings/userSettings';
import { Events } from 'jellyfin-apiclient';
import isEmpty from 'lodash-es/isEmpty';
import * as userSettings from './settings/userSettings';
/* eslint-disable indent */
@ -185,14 +187,22 @@ import { Events } from 'jellyfin-apiclient';
function translateKeyFromModule(key, module) {
let dictionary = getDictionary(module, getCurrentLocale());
if (!dictionary || !dictionary[key]) {
dictionary = getDictionary(module, fallbackCulture);
if (dictionary && dictionary[key]) {
return dictionary[key];
}
if (!dictionary || !dictionary[key]) {
dictionary = getDictionary(module, fallbackCulture);
if (dictionary && dictionary[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;
}
return dictionary[key];
return key;
}
function replaceAll(str, find, replace) {