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

Add debug mode to translations s.t. only translation keys are shown in debug mode

parent 7a664a85
Branches
Tags
No related merge requests found
Pipeline #198481 passed
......@@ -179,12 +179,18 @@ export async function setOverridesByGlobalCache(i18n, element) {
for (let lng of i18n.languages) {
// check if cacheOverrides throws error
try {
// in debug mode, remove all translations
if (window.location.hash.includes('debug')) {
i18n.removeResourceBundle(lng, namespace);
}
// else only add new override translations and remove old overrides
else {
cacheOverrides(element.langDir, lng);
translationCache[lng] = await translationCache[lng];
}
i18n.removeResourceBundle(lng, overrideNamespace);
if (translationCache[lng] === undefined || translationCache[lng][tagName] === undefined) {
console.warn("Object with tagname " + tagName + " does not exist!");
//continue;
if (translationCache[lng] === undefined) {
console.warn("Translations for language " + lng + " do not exist!");
}
let resources = translationCache[lng];
hasOverrides = true;
......
......@@ -88,8 +88,10 @@ export class Translation extends DBPLitElement {
// check if overrides have been loaded with overrideNamespace
// and then check if given key exists in overrideNS
// if in debug mode, show keys without errors and warning
let keyComment = "";
if (this._i18n.exists(overrideNamespace + ":" + this.key) && this._i18n.hasResourceBundle(this.lang, overrideNamespace)) {
if ((this._i18n.exists(overrideNamespace + ":" + this.key) && this._i18n.hasResourceBundle(this.lang, overrideNamespace))
|| window.location.hash.includes('debug')) {
keyComment = unsafeHTML("<!-- key: " + this.key + "-->");
} else if (this._i18n.hasResourceBundle(this.lang, overrideNamespace)){
keyComment = unsafeHTML("<!-- key '" + this.key + "' not found! -->");
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment