From 24e30af4b3c243a76a1d11ae530e198fb855a6f9 Mon Sep 17 00:00:00 2001
From: Manuel Kocher <manuel.kocher@tugraz.at>
Date: Wed, 17 Aug 2022 11:34:36 +0200
Subject: [PATCH] Add missing langDir properties to components

---
 packages/app-shell/src/app-shell.js              |  6 +++++-
 packages/app-shell/src/auth-menu-button.js       |  8 +++++++-
 packages/app-shell/src/dbp-activity-example.js   | 12 +++++++++++-
 packages/app-shell/src/dbp-app-shell-welcome.js  |  8 +++++++-
 packages/app-shell/src/i18n.js                   |  4 +++-
 packages/app-shell/src/tugraz-logo.js            | 12 +++++++++++-
 packages/auth/src/auth-keycloak.js               |  8 +++++++-
 packages/auth/src/dbp-auth-demo.js               | 12 +++++++++++-
 packages/auth/src/i18n.js                        |  4 ++--
 packages/auth/src/login-button.js                |  8 +++++++-
 packages/common/dbp-common-demo.js               |  2 +-
 packages/common/src/translation.js               |  1 +
 packages/data-table-view/src/data-table-view.js  |  1 +
 .../src/dbp-data-table-view-demo.js              |  1 +
 packages/file-handling/src/clipboard.js          |  1 +
 packages/file-handling/src/demo.js               |  8 +++++++-
 packages/file-handling/src/file-sink.js          |  1 +
 packages/file-handling/src/file-source.js        |  1 +
 .../file-handling/src/nextcloud-file-picker.js   |  1 +
 ...-knowledge-base-web-page-element-view-demo.js |  1 +
 .../src/knowledge-base-web-page-element-view.js  |  1 +
 packages/language-select/src/i18n.js             |  4 ++--
 packages/language-select/src/language-select.js  | 16 +++++++++++++---
 packages/matomo/src/dbp-matomo-demo.js           |  1 +
 .../notification/src/dbp-notification-demo.js    |  1 +
 packages/notification/src/notification.js        |  1 +
 .../src/dbp-person-profile-demo.js               |  1 +
 packages/person-profile/src/person-profile.js    |  1 +
 .../person-select/src/dbp-person-select-demo.js  |  1 +
 packages/person-select/src/person-select.js      |  1 +
 packages/provider/src/dbp-provider-demo.js       |  1 +
 .../src/dbp-qr-code-scanner-demo.js              |  1 +
 packages/qr-code-scanner/src/qr-code-scanner.js  |  1 +
 .../src/dbp-resource-select-demo.js              |  1 +
 packages/resource-select/src/resource-select.js  |  1 +
 packages/theme-switcher/src/theme-switcher.js    |  1 +
 packages/tooltip/src/dbp-tooltip-demo.js         |  1 +
 37 files changed, 117 insertions(+), 18 deletions(-)

diff --git a/packages/app-shell/src/app-shell.js b/packages/app-shell/src/app-shell.js
index 0c7d2a88..bd04cc86 100644
--- a/packages/app-shell/src/app-shell.js
+++ b/packages/app-shell/src/app-shell.js
@@ -1,4 +1,4 @@
-import {createInstance} from './i18n.js';
+import {createInstance, setOverridesByGlobalCache} from './i18n.js';
 import {html, css} from 'lit';
 import {ScopedElementsMixin} from '@open-wc/scoped-elements';
 import {LanguageSelect} from '@dbp-toolkit/language-select';
@@ -283,6 +283,10 @@ export class AppShell extends ScopedElementsMixin(DBPLitElement) {
         if (this.src) {
             this.fetchMetadata(this.src);
         }
+
+        if (this.langDir != '') {
+          setOverridesByGlobalCache(this._i18n, this);
+        }
     }
 
     /**
diff --git a/packages/app-shell/src/auth-menu-button.js b/packages/app-shell/src/auth-menu-button.js
index f7e8d506..051e92c7 100644
--- a/packages/app-shell/src/auth-menu-button.js
+++ b/packages/app-shell/src/auth-menu-button.js
@@ -1,4 +1,4 @@
-import {createInstance} from './i18n.js';
+import {createInstance, setOverridesByGlobalCache} from './i18n.js';
 import {html, css} from 'lit';
 import {unsafeHTML} from 'lit/directives/unsafe-html.js';
 import {ScopedElementsMixin} from '@open-wc/scoped-elements';
@@ -12,6 +12,7 @@ export class AuthMenuButton extends ScopedElementsMixin(AdapterLitElement) {
         super();
         this._i18n = createInstance();
         this.lang = this._i18n.language;
+        this.langDir = '';
         this.auth = {};
 
         this.closeDropdown = this.closeDropdown.bind(this);
@@ -28,6 +29,7 @@ export class AuthMenuButton extends ScopedElementsMixin(AdapterLitElement) {
         return {
             ...super.properties,
             lang: {type: String},
+            langDir: {type: String},
             auth: {type: Object},
         };
     }
@@ -41,6 +43,10 @@ export class AuthMenuButton extends ScopedElementsMixin(AdapterLitElement) {
 
         window.addEventListener('resize', this.onWindowResize);
         document.addEventListener('click', this.closeDropdown);
+
+        if (this.langDir != '') {
+          setOverridesByGlobalCache(this._i18n, this);
+        }
     }
 
     disconnectedCallback() {
diff --git a/packages/app-shell/src/dbp-activity-example.js b/packages/app-shell/src/dbp-activity-example.js
index 6c75ee4c..da3862ab 100644
--- a/packages/app-shell/src/dbp-activity-example.js
+++ b/packages/app-shell/src/dbp-activity-example.js
@@ -1,5 +1,5 @@
 import {html, LitElement} from 'lit';
-import {createInstance} from './i18n.js';
+import {createInstance, setOverridesByGlobalCache} from './i18n.js';
 import * as commonUtils from '@dbp-toolkit/common/utils';
 
 class ActivityExample extends LitElement {
@@ -7,14 +7,24 @@ class ActivityExample extends LitElement {
         super();
         this._i18n = createInstance();
         this.lang = this._i18n.language;
+        this.langDir = '';
     }
 
     static get properties() {
         return {
             lang: {type: String},
+            langDir: {type: String},
         };
     }
 
+    connectedCallback() {
+      super.connectedCallback();
+
+      if (this.langDir != '') {
+        setOverridesByGlobalCache(this._i18n, this);
+      }
+    }
+
     update(changedProperties) {
         changedProperties.forEach((oldValue, propName) => {
             switch (propName) {
diff --git a/packages/app-shell/src/dbp-app-shell-welcome.js b/packages/app-shell/src/dbp-app-shell-welcome.js
index dbe30f7b..fcbb238a 100644
--- a/packages/app-shell/src/dbp-app-shell-welcome.js
+++ b/packages/app-shell/src/dbp-app-shell-welcome.js
@@ -1,4 +1,4 @@
-import {createInstance} from './i18n.js';
+import {createInstance, setOverridesByGlobalCache} from './i18n.js';
 import {css, html, LitElement} from 'lit';
 import {ScopedElementsMixin} from '@open-wc/scoped-elements';
 import * as commonUtils from '@dbp-toolkit/common/utils';
@@ -9,6 +9,7 @@ class AppShellWelcome extends ScopedElementsMixin(LitElement) {
         super();
         this._i18n = createInstance();
         this.lang = this._i18n.language;
+        this.langDir = '';
 
         this._onVisibilityChanged = this._onVisibilityChanged.bind(this);
     }
@@ -16,6 +17,7 @@ class AppShellWelcome extends ScopedElementsMixin(LitElement) {
     static get properties() {
         return {
             lang: {type: String},
+            langDir: {type: String},
         };
     }
 
@@ -99,6 +101,10 @@ class AppShellWelcome extends ScopedElementsMixin(LitElement) {
 
         const app = AppShellWelcome._app;
         app.addEventListener('visibility-changed', this._onVisibilityChanged);
+
+        if (this.langDir != '') {
+          setOverridesByGlobalCache(this._i18n, this);
+        }
     }
 
     disconnectedCallback() {
diff --git a/packages/app-shell/src/i18n.js b/packages/app-shell/src/i18n.js
index 0c6fedc8..930f3538 100644
--- a/packages/app-shell/src/i18n.js
+++ b/packages/app-shell/src/i18n.js
@@ -1,4 +1,4 @@
-import {createInstance as _createInstance} from '@dbp-toolkit/common/i18next.js';
+import {createInstance as _createInstance, setOverridesByGlobalCache} from '@dbp-toolkit/common/i18next.js';
 
 import de from './i18n/de/translation.json';
 import en from './i18n/en/translation.json';
@@ -6,3 +6,5 @@ import en from './i18n/en/translation.json';
 export function createInstance() {
     return _createInstance({en: en, de: de}, 'de', 'en');
 }
+
+export {setOverridesByGlobalCache};
diff --git a/packages/app-shell/src/tugraz-logo.js b/packages/app-shell/src/tugraz-logo.js
index bc1bb741..8f1d1bf8 100644
--- a/packages/app-shell/src/tugraz-logo.js
+++ b/packages/app-shell/src/tugraz-logo.js
@@ -1,6 +1,6 @@
 import {html, css} from 'lit';
 import * as commonStyles from '@dbp-toolkit/common/styles';
-import {createInstance} from './i18n.js';
+import {createInstance, setOverridesByGlobalCache} from './i18n.js';
 import {AdapterLitElement} from '@dbp-toolkit/common';
 
 export class TUGrazLogo extends AdapterLitElement {
@@ -9,15 +9,25 @@ export class TUGrazLogo extends AdapterLitElement {
 
         this._i18n = createInstance();
         this.lang = this._i18n.language;
+        this.langDir = '';
     }
 
     static get properties() {
         return {
             ...super.properties,
             lang: {type: String},
+            langDir: {type: String},
         };
     }
 
+    connectedCallback() {
+      super.connectedCallback();
+
+      if (this.langDir != '') {
+        setOverridesByGlobalCache(this._i18n, this);
+      }
+    }
+
     update(changedProperties) {
         changedProperties.forEach((oldValue, propName) => {
             if (propName === 'lang') {
diff --git a/packages/auth/src/auth-keycloak.js b/packages/auth/src/auth-keycloak.js
index 61bd6865..f190cfaa 100644
--- a/packages/auth/src/auth-keycloak.js
+++ b/packages/auth/src/auth-keycloak.js
@@ -1,4 +1,4 @@
-import {createInstance} from './i18n.js';
+import {createInstance, setOverridesByGlobalCache} from './i18n.js';
 import JSONLD from '@dbp-toolkit/common/jsonld';
 import {KeycloakWrapper} from './keycloak.js';
 import {LoginStatus} from './util.js';
@@ -32,6 +32,7 @@ export class AuthKeycloak extends AdapterLitElement {
         this.requestedLoginStatus = LoginStatus.UNKNOWN;
         this._i18n = createInstance();
         this.lang = this._i18n.language;
+        this.langDir = '';
 
         // Keycloak config
         this.keycloakUrl = null;
@@ -185,6 +186,7 @@ export class AuthKeycloak extends AdapterLitElement {
         return {
             ...super.properties,
             lang: {type: String},
+            langDir: {type: String},
             forceLogin: {type: Boolean, attribute: 'force-login'},
             tryLogin: {type: Boolean, attribute: 'try-login'},
             entryPointUrl: {type: String, attribute: 'entry-point-url'},
@@ -246,6 +248,10 @@ export class AuthKeycloak extends AdapterLitElement {
         };
 
         handleLogin();
+
+        if (this.langDir != '') {
+          setOverridesByGlobalCache(this._i18n, this);
+        }
     }
 
     disconnectedCallback() {
diff --git a/packages/auth/src/dbp-auth-demo.js b/packages/auth/src/dbp-auth-demo.js
index 22a2f7ea..4116fbd8 100644
--- a/packages/auth/src/dbp-auth-demo.js
+++ b/packages/auth/src/dbp-auth-demo.js
@@ -1,4 +1,4 @@
-import {createInstance} from './i18n.js';
+import {createInstance, setOverridesByGlobalCache} from './i18n.js';
 import {html} from 'lit';
 import {ScopedElementsMixin} from '@open-wc/scoped-elements';
 import {AuthKeycloak} from './auth-keycloak.js';
@@ -15,6 +15,7 @@ export class DbpAuthDemo extends ScopedElementsMixin(DBPLitElement) {
         this.noAuth = false;
         this._i18n = createInstance();
         this.lang = this._i18n.language;
+        this.langDir = '';
     }
 
     static get scopedElements() {
@@ -28,12 +29,21 @@ export class DbpAuthDemo extends ScopedElementsMixin(DBPLitElement) {
         return {
             ...super.properties,
             lang: {type: String},
+            langDir: {type: String},
             entryPointUrl: {type: String, attribute: 'entry-point-url'},
             auth: {type: Object},
             noAuth: {type: Boolean, attribute: 'no-auth'},
         };
     }
 
+    connectedCallback() {
+      super.connectedCallback();
+
+      if (this.langDir != '') {
+        setOverridesByGlobalCache(this._i18n, this);
+      }
+    }
+
     update(changedProperties) {
         changedProperties.forEach((oldValue, propName) => {
             if (propName === 'lang') {
diff --git a/packages/auth/src/i18n.js b/packages/auth/src/i18n.js
index fe81f7a9..930f3538 100644
--- a/packages/auth/src/i18n.js
+++ b/packages/auth/src/i18n.js
@@ -1,4 +1,4 @@
-import {createInstance as _createInstance, setOverrides} from '@dbp-toolkit/common/i18next.js';
+import {createInstance as _createInstance, setOverridesByGlobalCache} from '@dbp-toolkit/common/i18next.js';
 
 import de from './i18n/de/translation.json';
 import en from './i18n/en/translation.json';
@@ -7,4 +7,4 @@ export function createInstance() {
     return _createInstance({en: en, de: de}, 'de', 'en');
 }
 
-export {setOverrides};
+export {setOverridesByGlobalCache};
diff --git a/packages/auth/src/login-button.js b/packages/auth/src/login-button.js
index 26210f48..db3580ab 100644
--- a/packages/auth/src/login-button.js
+++ b/packages/auth/src/login-button.js
@@ -1,4 +1,4 @@
-import {createInstance} from './i18n.js';
+import {createInstance, setOverridesByGlobalCache} from './i18n.js';
 import {html, css} from 'lit';
 import {unsafeHTML} from 'lit/directives/unsafe-html.js';
 import {ScopedElementsMixin} from '@open-wc/scoped-elements';
@@ -56,6 +56,7 @@ export class LoginButton extends ScopedElementsMixin(AdapterLitElement) {
         super();
         this._i18n = createInstance();
         this.lang = this._i18n.language;
+        this.langDir = '';
         this.auth = {};
     }
 
@@ -68,12 +69,17 @@ export class LoginButton extends ScopedElementsMixin(AdapterLitElement) {
     static get properties() {
         return {
             lang: {type: String},
+            langDir: {type: String},
             auth: {type: Object},
         };
     }
 
     connectedCallback() {
         super.connectedCallback();
+
+        if (this.langDir != '') {
+          setOverridesByGlobalCache(this._i18n, this);
+        }
     }
 
     disconnectedCallback() {
diff --git a/packages/common/dbp-common-demo.js b/packages/common/dbp-common-demo.js
index cc34c35f..5726fd11 100644
--- a/packages/common/dbp-common-demo.js
+++ b/packages/common/dbp-common-demo.js
@@ -59,7 +59,7 @@ export class DbpCommonDemo extends ScopedElementsMixin(LitElement) {
         super.connectedCallback();
         this._i18n.changeLanguage(this.lang);
 
-        // necessary because activity does not extend adapter
+        // set translation overrides if requested
         if (this.langDir) {
           setOverridesByGlobalCache(this._i18n, this);
         }
diff --git a/packages/common/src/translation.js b/packages/common/src/translation.js
index 58eb373e..e79afe4c 100644
--- a/packages/common/src/translation.js
+++ b/packages/common/src/translation.js
@@ -23,6 +23,7 @@ export class Translation extends DBPLitElement {
             ...super.properties,
             key: {type: String},
             lang: {type: String},
+            langDir: {type: String},
             interpolation: {type: Object, attribute: 'var'},
             unsafe: {type: Boolean, attribute: 'unsafe'},
         };
diff --git a/packages/data-table-view/src/data-table-view.js b/packages/data-table-view/src/data-table-view.js
index aff9e74e..7c477ae1 100644
--- a/packages/data-table-view/src/data-table-view.js
+++ b/packages/data-table-view/src/data-table-view.js
@@ -54,6 +54,7 @@ export class DataTableView extends AdapterLitElement {
         return {
             ...super.properties,
             lang: {type: String},
+            langDir: {type: String},
             table: {type: Object, attribute: false},
             paging: {type: Boolean},
             searching: {type: Boolean},
diff --git a/packages/data-table-view/src/dbp-data-table-view-demo.js b/packages/data-table-view/src/dbp-data-table-view-demo.js
index 6cea37cc..f8589ac2 100644
--- a/packages/data-table-view/src/dbp-data-table-view-demo.js
+++ b/packages/data-table-view/src/dbp-data-table-view-demo.js
@@ -28,6 +28,7 @@ export class DataTableViewDemo extends ScopedElementsMixin(DBPLitElement) {
         return {
             ...super.properties,
             lang: {type: String},
+            langDir: {type: String},
             entryPointUrl: {type: String, attribute: 'entry-point-url'},
             noAuth: {type: Boolean, attribute: 'no-auth'},
         };
diff --git a/packages/file-handling/src/clipboard.js b/packages/file-handling/src/clipboard.js
index a607d0dc..2f9de306 100644
--- a/packages/file-handling/src/clipboard.js
+++ b/packages/file-handling/src/clipboard.js
@@ -66,6 +66,7 @@ export class Clipboard extends ScopedElementsMixin(AdapterLitElement) {
         return {
             ...super.properties,
             lang: {type: String},
+            langDir: {type: String},
             allowedMimeTypes: {type: String, attribute: 'allowed-mime-types'},
             clipboardSelectBtnDisabled: {type: Boolean},
             clipboardFiles: {type: Object, attribute: 'clipboard-files'},
diff --git a/packages/file-handling/src/demo.js b/packages/file-handling/src/demo.js
index 207aed30..35304eef 100644
--- a/packages/file-handling/src/demo.js
+++ b/packages/file-handling/src/demo.js
@@ -1,4 +1,4 @@
-import {createInstance} from './i18n';
+import {createInstance, setOverridesByGlobalCache} from './i18n';
 import {html, LitElement} from 'lit';
 import {ScopedElementsMixin} from '@open-wc/scoped-elements';
 import {FileSource} from './file-source';
@@ -10,6 +10,7 @@ export class FileSourceDemo extends ScopedElementsMixin(LitElement) {
         super();
         this._i18n = createInstance();
         this.lang = this._i18n.language;
+        this.langDir = '';
         this.url = '';
         this.selectedFiles = [];
         this.selectedFilesCount = 0;
@@ -25,6 +26,7 @@ export class FileSourceDemo extends ScopedElementsMixin(LitElement) {
     static get properties() {
         return {
             lang: {type: String},
+            langDir: {type: String},
             url: {type: String},
             selectedFiles: {type: Array, attribute: false},
             selectedFilesCount: {type: Number, attribute: false},
@@ -43,6 +45,10 @@ export class FileSourceDemo extends ScopedElementsMixin(LitElement) {
                 );
             });
         });
+
+        if (this.langDir != '') {
+          setOverridesByGlobalCache(this._i18n, this);
+        }
     }
 
     update(changedProperties) {
diff --git a/packages/file-handling/src/file-sink.js b/packages/file-handling/src/file-sink.js
index 6b0b75af..dfa8a1d6 100644
--- a/packages/file-handling/src/file-sink.js
+++ b/packages/file-handling/src/file-sink.js
@@ -59,6 +59,7 @@ export class FileSink extends ScopedElementsMixin(DbpFileHandlingLitElement) {
             ...super.properties,
             context: {type: String, attribute: 'context'},
             lang: {type: String},
+            langDir: {type: String},
             filename: {type: String},
             files: {type: Array, attribute: false},
             enabledTargets: {type: String, attribute: 'enabled-targets'},
diff --git a/packages/file-handling/src/file-source.js b/packages/file-handling/src/file-source.js
index 73839baf..74c90a2b 100644
--- a/packages/file-handling/src/file-source.js
+++ b/packages/file-handling/src/file-source.js
@@ -80,6 +80,7 @@ export class FileSource extends ScopedElementsMixin(DbpFileHandlingLitElement) {
             ...super.properties,
             context: {type: String, attribute: 'context'},
             lang: {type: String},
+            langDir: {type: String},
             allowedMimeTypes: {type: String, attribute: 'allowed-mime-types'},
             enabledTargets: {type: String, attribute: 'enabled-targets'},
             nextcloudAuthUrl: {type: String, attribute: 'nextcloud-auth-url'},
diff --git a/packages/file-handling/src/nextcloud-file-picker.js b/packages/file-handling/src/nextcloud-file-picker.js
index 6ee29370..9027911d 100644
--- a/packages/file-handling/src/nextcloud-file-picker.js
+++ b/packages/file-handling/src/nextcloud-file-picker.js
@@ -94,6 +94,7 @@ export class NextcloudFilePicker extends ScopedElementsMixin(DBPLitElement) {
         return {
             ...super.properties,
             lang: {type: String},
+            langDir: {type: String},
             auth: {type: Object},
             authUrl: {type: String, attribute: 'auth-url'},
             webDavUrl: {type: String, attribute: 'web-dav-url'},
diff --git a/packages/knowledge-base-web-page-element-view/src/dbp-knowledge-base-web-page-element-view-demo.js b/packages/knowledge-base-web-page-element-view/src/dbp-knowledge-base-web-page-element-view-demo.js
index b65aaf9a..57a175f5 100644
--- a/packages/knowledge-base-web-page-element-view/src/dbp-knowledge-base-web-page-element-view-demo.js
+++ b/packages/knowledge-base-web-page-element-view/src/dbp-knowledge-base-web-page-element-view-demo.js
@@ -29,6 +29,7 @@ export class KnowledgeBaseWebPageElementViewDemo extends ScopedElementsMixin(DBP
         return {
             ...super.properties,
             lang: {type: String},
+            langDir: {type: String},
             entryPointUrl: {type: String, attribute: 'entry-point-url'},
             noAuth: {type: Boolean, attribute: 'no-auth'},
         };
diff --git a/packages/knowledge-base-web-page-element-view/src/knowledge-base-web-page-element-view.js b/packages/knowledge-base-web-page-element-view/src/knowledge-base-web-page-element-view.js
index 9bf0ddd5..7cf24825 100644
--- a/packages/knowledge-base-web-page-element-view/src/knowledge-base-web-page-element-view.js
+++ b/packages/knowledge-base-web-page-element-view/src/knowledge-base-web-page-element-view.js
@@ -47,6 +47,7 @@ export class KnowledgeBaseWebPageElementView extends ScopedElementsMixin(Adapter
     static get properties() {
         return {
             lang: {type: String},
+            langDir: {type: String},
             value: {type: String},
             html: {type: String, attribute: false},
             entryPointUrl: {type: String, attribute: 'entry-point-url'},
diff --git a/packages/language-select/src/i18n.js b/packages/language-select/src/i18n.js
index fbc1b032..d861a3c4 100644
--- a/packages/language-select/src/i18n.js
+++ b/packages/language-select/src/i18n.js
@@ -1,4 +1,4 @@
-import {createInstance as _createInstance, setOverrides} from '@dbp-toolkit/common/i18next.js';
+import {createInstance as _createInstance, setOverrides, setOverridesByGlobalCache} from '@dbp-toolkit/common/i18next.js';
 
 import de from './i18n/de/translation.json';
 import en from './i18n/en/translation.json';
@@ -7,4 +7,4 @@ export function createInstance() {
     return _createInstance({en: en, de: de}, 'de', 'en');
 }
 
-export {setOverrides};
\ No newline at end of file
+export {setOverrides, setOverridesByGlobalCache};
diff --git a/packages/language-select/src/language-select.js b/packages/language-select/src/language-select.js
index 2a63dda6..a1324778 100644
--- a/packages/language-select/src/language-select.js
+++ b/packages/language-select/src/language-select.js
@@ -1,5 +1,5 @@
 import {html, css} from 'lit';
-import {createInstance} from './i18n.js';
+import {createInstance, setOverridesByGlobalCache} from './i18n.js';
 import * as commonStyles from '@dbp-toolkit/common/styles';
 import {AdapterLitElement} from '@dbp-toolkit/common';
 
@@ -12,6 +12,7 @@ export class LanguageSelect extends AdapterLitElement {
     constructor() {
         super();
         this._lang = 'de';
+        this.langDir = '';
         this.languages = ['de', 'en'];
 
         this._i18n = createInstance();
@@ -41,11 +42,20 @@ export class LanguageSelect extends AdapterLitElement {
     static get properties() {
         return {
             lang: {type: String},
+            langDir: {type: String},
             next: {type: String},
             languages: {type: Array},
         };
     }
 
+    connectedCallback() {
+      super.connectedCallback();
+
+      if (this.langDir != '') {
+        setOverridesByGlobalCache(this._i18n, this);
+      }
+    }
+
     set lang(value) {
         const oldValue = this.lang;
         const oldNext = this.next;
@@ -108,7 +118,7 @@ export class LanguageSelect extends AdapterLitElement {
                 -webkit-box-shadow: none;
                 box-shadow: 0px 0px 4px 2px var(--dbp-primary);
             }
-            
+
             `
         ;
     }
@@ -124,4 +134,4 @@ export class LanguageSelect extends AdapterLitElement {
             <a href="#" title="${linkTitle}" @click=${this.onClick}>${this.next.toUpperCase()}</a>
         `;
     }
-}
\ No newline at end of file
+}
diff --git a/packages/matomo/src/dbp-matomo-demo.js b/packages/matomo/src/dbp-matomo-demo.js
index 0af5ce76..735f69cd 100644
--- a/packages/matomo/src/dbp-matomo-demo.js
+++ b/packages/matomo/src/dbp-matomo-demo.js
@@ -32,6 +32,7 @@ export class MatomoDemo extends ScopedElementsMixin(DBPLitElement) {
         return {
             ...super.properties,
             lang: {type: String},
+            langDir: {type: String},
             entryPointUrl: {type: String, attribute: 'entry-point-url'},
             matomoUrl: {type: String, attribute: 'matomo-url'},
             matomoSiteId: {type: Number, attribute: 'matomo-site-id'},
diff --git a/packages/notification/src/dbp-notification-demo.js b/packages/notification/src/dbp-notification-demo.js
index f0bfa34b..f60d0383 100644
--- a/packages/notification/src/dbp-notification-demo.js
+++ b/packages/notification/src/dbp-notification-demo.js
@@ -23,6 +23,7 @@ export class NotificationDemo extends ScopedElementsMixin(LitElement) {
     static get properties() {
         return {
             lang: {type: String},
+            langDir: {type: String},
         };
     }
 
diff --git a/packages/notification/src/notification.js b/packages/notification/src/notification.js
index 78e81ab9..62bb22f7 100644
--- a/packages/notification/src/notification.js
+++ b/packages/notification/src/notification.js
@@ -22,6 +22,7 @@ export class Notification extends DBPLitElement {
         return {
             ...super.properties,
             lang: {type: String},
+            langDir: {type: String},
         };
     }
 
diff --git a/packages/person-profile/src/dbp-person-profile-demo.js b/packages/person-profile/src/dbp-person-profile-demo.js
index f6c07f3d..06103df6 100644
--- a/packages/person-profile/src/dbp-person-profile-demo.js
+++ b/packages/person-profile/src/dbp-person-profile-demo.js
@@ -35,6 +35,7 @@ export class PersonProfileDemo extends ScopedElementsMixin(DBPLitElement) {
         return {
             ...super.properties,
             lang: {type: String},
+            langDir: {type: String},
             entryPointUrl: {type: String, attribute: 'entry-point-url'},
             person: {type: String, attribute: false},
             selectedPerson: {type: String, attribute: false},
diff --git a/packages/person-profile/src/person-profile.js b/packages/person-profile/src/person-profile.js
index f073d4f5..33349c57 100644
--- a/packages/person-profile/src/person-profile.js
+++ b/packages/person-profile/src/person-profile.js
@@ -20,6 +20,7 @@ export class PersonProfile extends DBPLitElement {
     static get properties() {
         return {
             lang: {type: String},
+            langDir: {type: String},
             active: {type: Boolean, attribute: false},
             entryPointUrl: {type: String, attribute: 'entry-point-url'},
             value: {type: String},
diff --git a/packages/person-select/src/dbp-person-select-demo.js b/packages/person-select/src/dbp-person-select-demo.js
index 363f40dc..ec93df76 100644
--- a/packages/person-select/src/dbp-person-select-demo.js
+++ b/packages/person-select/src/dbp-person-select-demo.js
@@ -29,6 +29,7 @@ export class PersonSelectDemo extends ScopedElementsMixin(DBPLitElement) {
         return {
             ...super.properties,
             lang: {type: String},
+            langDir: {type: String},
             entryPointUrl: {type: String, attribute: 'entry-point-url'},
             noAuth: {type: Boolean, attribute: 'no-auth'},
         };
diff --git a/packages/person-select/src/person-select.js b/packages/person-select/src/person-select.js
index cd0bed53..6b409454 100644
--- a/packages/person-select/src/person-select.js
+++ b/packages/person-select/src/person-select.js
@@ -63,6 +63,7 @@ export class PersonSelect extends ScopedElementsMixin(AdapterLitElement) {
         return {
             ...super.properties,
             lang: {type: String},
+            langDir: {type: String},
             active: {type: Boolean, attribute: false},
             entryPointUrl: {type: String, attribute: 'entry-point-url'},
             value: {type: String},
diff --git a/packages/provider/src/dbp-provider-demo.js b/packages/provider/src/dbp-provider-demo.js
index f2d0d982..21e482ea 100644
--- a/packages/provider/src/dbp-provider-demo.js
+++ b/packages/provider/src/dbp-provider-demo.js
@@ -32,6 +32,7 @@ class ProviderDemo extends ScopedElementsMixin(DBPLitElement) {
         return {
             ...super.properties,
             lang: {type: String},
+            langDir: {type: String},
         };
     }
 
diff --git a/packages/qr-code-scanner/src/dbp-qr-code-scanner-demo.js b/packages/qr-code-scanner/src/dbp-qr-code-scanner-demo.js
index df27f246..a46517a9 100644
--- a/packages/qr-code-scanner/src/dbp-qr-code-scanner-demo.js
+++ b/packages/qr-code-scanner/src/dbp-qr-code-scanner-demo.js
@@ -22,6 +22,7 @@ export class QrCodeScannerDemo extends ScopedElementsMixin(LitElement) {
     static get properties() {
         return {
             lang: {type: String},
+            langDir: {type: String},
         };
     }
 
diff --git a/packages/qr-code-scanner/src/qr-code-scanner.js b/packages/qr-code-scanner/src/qr-code-scanner.js
index bf50eb9a..1ba8e2ab 100644
--- a/packages/qr-code-scanner/src/qr-code-scanner.js
+++ b/packages/qr-code-scanner/src/qr-code-scanner.js
@@ -153,6 +153,7 @@ export class QrCodeScanner extends ScopedElementsMixin(DBPLitElement) {
     static get properties() {
         return {
             lang: {type: String},
+            langDir: {type: String},
             showOutput: {type: Boolean, attribute: 'show-output'},
             stopScan: {type: Boolean, attribute: 'stop-scan'},
             matchRegex: {type: String, attribute: 'match-regex'},
diff --git a/packages/resource-select/src/dbp-resource-select-demo.js b/packages/resource-select/src/dbp-resource-select-demo.js
index 4c550238..bde2203d 100644
--- a/packages/resource-select/src/dbp-resource-select-demo.js
+++ b/packages/resource-select/src/dbp-resource-select-demo.js
@@ -29,6 +29,7 @@ export class ResourceSelectDemo extends ScopedElementsMixin(DBPLitElement) {
         return {
             ...super.properties,
             lang: {type: String},
+            langDir: {type: String},
             entryPointUrl: {type: String, attribute: 'entry-point-url'},
             noAuth: {type: Boolean, attribute: 'no-auth'},
         };
diff --git a/packages/resource-select/src/resource-select.js b/packages/resource-select/src/resource-select.js
index 151e3408..c5ee3c0c 100644
--- a/packages/resource-select/src/resource-select.js
+++ b/packages/resource-select/src/resource-select.js
@@ -35,6 +35,7 @@ export class ResourceSelect extends AdapterLitElement {
         return {
             ...super.properties,
             lang: {type: String},
+            langDir: {type: String},
             auth: {type: Object},
             entryPointUrl: {type: String, attribute: 'entry-point-url'},
             resourcePath: {type: String, attribute: 'resource-path'},
diff --git a/packages/theme-switcher/src/theme-switcher.js b/packages/theme-switcher/src/theme-switcher.js
index 2370f803..a162d8ba 100644
--- a/packages/theme-switcher/src/theme-switcher.js
+++ b/packages/theme-switcher/src/theme-switcher.js
@@ -24,6 +24,7 @@ export class ThemeSwitcher extends ScopedElementsMixin(AdapterLitElement) {
         return {
             ...super.properties,
             lang: {type: String},
+            langDir: {type: String},
             themes: {type: Array, attribute: 'themes'},
             darkModeThemeOverride: {type: String, attribute: 'dark-mode-theme-override'},
             dropdownRight: {type: Boolean, attribute: 'dropdown-right'},
diff --git a/packages/tooltip/src/dbp-tooltip-demo.js b/packages/tooltip/src/dbp-tooltip-demo.js
index c6f86e70..d62fc27f 100644
--- a/packages/tooltip/src/dbp-tooltip-demo.js
+++ b/packages/tooltip/src/dbp-tooltip-demo.js
@@ -28,6 +28,7 @@ export class TooltipDemo extends ScopedElementsMixin(DBPLitElement) {
         return {
             ...super.properties,
             lang: {type: String},
+            langDir: {type: String},
         };
     }
 
-- 
GitLab