diff --git a/packages/common/src/translation.js b/packages/common/src/translation.js index ebf230a7eae1e3e3bb2b96968719478a27fb3bb0..9e6bb5f876b5bcb1fccaad09927d293755012a79 100644 --- a/packages/common/src/translation.js +++ b/packages/common/src/translation.js @@ -10,7 +10,6 @@ export class Translation extends DBPLitElement { this.key = ''; this.lang = ''; this.interpolation = ''; - this.langDir = ''; this.unsafe = false; } @@ -21,47 +20,32 @@ export class Translation extends DBPLitElement { lang: {type: String}, interpolation: {type: Object, attribute: 'var'}, unsafe: {type: Boolean, attribute: 'unsafe'}, - langDir: {type: String, attribute: 'lang-dir'}, }; } static get styles() { // language=css return [ - commonStyles.getThemeCSS(), commonStyles.getGeneralCSS(), - css` - .hidden { - display: none; - } - .links { - border-bottom: var(--dbp-border); - border-color: var(--dbp-content); - padding: 0; - transition: background-color 0.15s ease 0s, color 0.15s ease 0s; - color: var(--dbp-content); - cursor: pointer; - text-decoration: none; - } - `, + commonStyles.getLinkCss(), ]; } connectedCallback() { - super.connectedCallback(); + // init objects with empty string as value for key const de = {}; const en = {}; de[this.key] = ""; en[this.key] = ""; - // create i18n instance with given translations + // create i18n instance with empty translations as default this._i18n = createInstanceGivenResources(en, de); - if (this.langDir) { - setOverridesByGlobalCache(this._i18n, this); - } + // supercall after default i18n init to override translations only + // if a override with this tagname is given + super.connectedCallback(); } update(changedProperties) { diff --git a/packages/theme-switcher/src/theme-switcher.js b/packages/theme-switcher/src/theme-switcher.js index fc2dd9822427bf8b719cec234e6cc6a1d5097dfd..4d7374e9d40ca5abf4803bce4563cdc912c94c10 100644 --- a/packages/theme-switcher/src/theme-switcher.js +++ b/packages/theme-switcher/src/theme-switcher.js @@ -1,4 +1,4 @@ -import {createInstance, setOverridesByGlobalCache} from './i18n.js'; +import {createInstance} from './i18n.js'; import {html, css} from 'lit'; import {ScopedElementsMixin} from '@open-wc/scoped-elements'; import {AdapterLitElement, Icon} from '@dbp-toolkit/common'; @@ -15,7 +15,6 @@ export class ThemeSwitcher extends ScopedElementsMixin(AdapterLitElement) { this.boundCloseAdditionalMenuHandler = this.hideModeMenu.bind(this); this.detectBrowserDarkMode = false; this.darkModeClass = 'dark-theme'; - this.langDir = ''; this.dropdownRight = false; } @@ -26,7 +25,6 @@ export class ThemeSwitcher extends ScopedElementsMixin(AdapterLitElement) { themes: {type: Array, attribute: 'themes'}, darkModeThemeOverride: {type: String, attribute: 'dark-mode-theme-override'}, dropdownRight: {type: Boolean, attribute: 'dropdown-right'}, - langDir: {type: String, attribute: 'lang-dir'}, }; } @@ -59,9 +57,6 @@ export class ThemeSwitcher extends ScopedElementsMixin(AdapterLitElement) { this.loadTheme('light-theme'); this.detectInitialMode(); }); - if (this.langDir) { - setOverridesByGlobalCache(this._i18n, this); - } } detectInitialMode() { @@ -225,12 +220,12 @@ export class ThemeSwitcher extends ScopedElementsMixin(AdapterLitElement) { .icon { margin-right: 10px; } - + #theme-menu{ position: relative; } - - + + .ul-right{ right: 0px; }; diff --git a/toolkit-showcase/assets/translation-overrides/de/translation.json b/toolkit-showcase/assets/translation-overrides/de/translation.json index 5a89e9d1d3a788c37f8c61658c74d8a3b0a1d0be..727ad0917125599979ba52abe115d2a26d47cb04 100644 --- a/toolkit-showcase/assets/translation-overrides/de/translation.json +++ b/toolkit-showcase/assets/translation-overrides/de/translation.json @@ -1,7 +1,7 @@ { "dbp-translation": { "toolkit-showcase": "Dieser Text wird mithilfe von i18n aus einer benutzerdefinierten Sprachdatei gelesen und ins Englische übersetzt wenn man die Sprache auf Englisch stellt.", - "toolkit-showcase-link": "Es können sogar links mittels <a href=\"{{- link1}}\" class=\"links\">interpolation</a> und escaping dargestellt werden.", + "toolkit-showcase-link": "Es können sogar links mittels <a href=\"{{- link1}}\" class=\"link\">interpolation</a> und escaping dargestellt werden.", "color-mode": "Sollte nicht angezeigt werden. Dieser Text ist nur als test vorhanden.", "intro": "Sollte nicht angezeigt werden. Dieser Text ist nur als test vorhanden." }, diff --git a/toolkit-showcase/assets/translation-overrides/en/translation.json b/toolkit-showcase/assets/translation-overrides/en/translation.json index fa7eaaa94b6942af6030d3d765813b23f940942c..ac573073ec811343ac82a3b95a195e084a5bcc04 100644 --- a/toolkit-showcase/assets/translation-overrides/en/translation.json +++ b/toolkit-showcase/assets/translation-overrides/en/translation.json @@ -1,7 +1,7 @@ { "dbp-translation": { "toolkit-showcase": "This text will be translated to german using i18n with a user defined language file when the language is changed to german.", - "toolkit-showcase-link": "Furthermore its possible to display links through <a href=\"{{- link1}}\" class=\"links\">interpolation</a> and escaping.", + "toolkit-showcase-link": "Furthermore its possible to display links through <a href=\"{{- link1}}\" class=\"link\">interpolation</a> and escaping.", "color-mode": "This text is not supposed to be displayed. It is only here for testing.", "intro": "This text is not supposed to be displayed. It is only here for testing." },