summaryrefslogtreecommitdiff
path: root/resources/js/helpers.js
diff options
context:
space:
mode:
Diffstat (limited to 'resources/js/helpers.js')
-rw-r--r--resources/js/helpers.js15
1 files changed, 10 insertions, 5 deletions
diff --git a/resources/js/helpers.js b/resources/js/helpers.js
index aa149b1..cee9166 100644
--- a/resources/js/helpers.js
+++ b/resources/js/helpers.js
@@ -68,14 +68,19 @@ function randomString () {
/**
* @param {string} msgid
+ * @param {boolean} useFallback
*
* @returns {string}
*/
-function translate (msgid, showTranslationMissing = false) {
+function translate (msgid, useFallback = true) {
let translation = DB.translations[Memory.state.Settings.language][msgid];
- if (!translation && showTranslationMissing) {
- translation = (translate('translation_missing') || 'translation_missing') + `: ${msgid}`;
+ if (!translation && useFallback) {
+ translation = DB.translations['en_US'][msgid];
+
+ if (!translation) {
+ translation = (translate('translation_missing', false) || 'translation_missing') + `: ${msgid}`;
+ }
}
return translation;
@@ -89,7 +94,7 @@ function applyTranslation () {
}
parentNode.querySelectorAll('[data-i18n-msgid]').forEach((node) => {
- node.innerHTML = translate(node.dataset.i18nMsgid, true);
+ node.innerHTML = translate(node.dataset.i18nMsgid);
});
parentNode.querySelectorAll('[data-i18n-properties]').forEach((node) => {
@@ -99,7 +104,7 @@ function applyTranslation () {
const property = properties[idx];
const msgid = msgids[idx];
- node.setAttribute(property, translate(msgid, true))
+ node.setAttribute(property, translate(msgid))
}
});
});