From 8ca5f78523f1079d8b92c21afe926145e315c7a4 Mon Sep 17 00:00:00 2001 From: Manuel Kocher <manuel.kocher@tugraz.at> Date: Thu, 10 Nov 2022 09:07:15 +0100 Subject: [PATCH] Move i18n.t override from debug mode to normal frontend and change it from error to warning --- packages/common/i18next.js | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/packages/common/i18next.js b/packages/common/i18next.js index 2ece798c..4f3db695 100644 --- a/packages/common/i18next.js +++ b/packages/common/i18next.js @@ -125,19 +125,16 @@ export function createInstance(languages, lng, fallback, namespace) { i18n.init(options); console.assert(i18n.isInitialized); - // if debug mode is activated, override i18n.t() to print errors if keys are missing - if (window.location.hash.includes('debug')) { - const translate = i18n.t; - const that = i18n; - - i18n.t = function (keys, options) { - if (!that.exists(keys)) { - console.error("Error: Translation key " + keys + " does not exist!"); - } - - return translate(keys, options); - }; - } + // override i18n.t() to print warnings if keys are missing + const translate = i18n.t; + const that = i18n; + i18n.t = function (keys, options) { + if (!that.exists(keys)) { + console.warn("Translation warning: Default key " + keys + " does not exist!"); + } + + return translate(keys, options); + }; return i18n; } -- GitLab