Skip to content
Snippets Groups Projects
Commit 4673875e authored by Kocher, Manuel's avatar Kocher, Manuel
Browse files

Move i18n.t override function used for testing to frontend debug mode

parent 1e885aee
No related branches found
No related tags found
No related merge requests found
Pipeline #202838 passed
......@@ -125,16 +125,19 @@ export function createInstance(languages, lng, fallback, namespace) {
i18n.init(options);
console.assert(i18n.isInitialized);
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);
};
// 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);
};
}
return i18n;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment