From a79062148bbd7ad3186b4687a2004facb37c7105 Mon Sep 17 00:00:00 2001 From: nobody42 <5514211-nobody42@users.noreply.gitlab.com> Date: Sun, 29 Mar 2020 10:22:42 +0200 Subject: [PATCH] Select default language, if translation is empty --- modules/internal/helpers.js | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/modules/internal/helpers.js b/modules/internal/helpers.js index 00cdf6fe..5da35936 100644 --- a/modules/internal/helpers.js +++ b/modules/internal/helpers.js @@ -26,17 +26,24 @@ var helpers = {}; helpers.insertI18nContentIntoDocument = function (document) { - let scriptDirection, i18nElements; + let scriptDirection, defaultScriptDirection, i18nElements; scriptDirection = helpers.determineScriptDirection(navigator.language); + defaultScriptDirection = helpers.determineScriptDirection('en_US'); i18nElements = document.querySelectorAll('[data-i18n-content]'); i18nElements.forEach(function (i18nElement) { let i18nMessageName = i18nElement.getAttribute('data-i18n-content'); + if(chrome.i18n.getMessage(i18nMessageName) === '') { + // Select english if configured language is empty + i18nElement.innerText = chrome.i18n.getMessage(i18nMessageName); + i18nElement.setAttribute('dir', defaultScriptDirection); + } else { + i18nElement.innerText = chrome.i18n.getMessage(i18nMessageName); + i18nElement.setAttribute('dir', scriptDirection); + } - i18nElement.innerText = chrome.i18n.getMessage(i18nMessageName); - i18nElement.setAttribute('dir', scriptDirection); }); };