diff --git a/src/scripts/globalize.js b/src/scripts/globalize.js index c66ed2b7f..6bffd8e55 100644 --- a/src/scripts/globalize.js +++ b/src/scripts/globalize.js @@ -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) {