1
0
mirror of https://codeberg.org/nobody/LocalCDN.git synced 2024-12-28 19:09:57 +01:00

Select default language, if translation is empty

This commit is contained in:
nobody42 2020-03-29 10:22:42 +02:00
parent e1061eaa34
commit a79062148b
No known key found for this signature in database
GPG Key ID: AB5145CF05BFE119

View File

@ -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);
});
};