diff --git a/packages/check-in-place-select/i18next-scanner.config.js b/packages/check-in-place-select/i18next-scanner.config.js index 8c277798414be902846c6eb4f0e95a19750cda39..aeb8fdb6532e6c951401ba91424e2a256353d391 100644 --- a/packages/check-in-place-select/i18next-scanner.config.js +++ b/packages/check-in-place-select/i18next-scanner.config.js @@ -6,6 +6,7 @@ module.exports = { options: { debug: false, removeUnusedKeys: true, + func: {list: ['i18n.t', '_i18n.t']}, lngs: ['en','de'], resource: { loadPath: 'src/i18n/{{lng}}/{{ns}}.json', diff --git a/packages/check-in-place-select/src/check-in-place-select.js b/packages/check-in-place-select/src/check-in-place-select.js index 7b63bb9af29270fa28dc8f3ac5c9d16a97932771..f2ed817d4a7a974001c94afcdf20e9424a4472e0 100644 --- a/packages/check-in-place-select/src/check-in-place-select.js +++ b/packages/check-in-place-select/src/check-in-place-select.js @@ -4,7 +4,7 @@ import select2LangEn from './i18n/en/select2'; import JSONLD from '@dbp-toolkit/common/jsonld'; import {css, html} from 'lit-element'; import {ScopedElementsMixin} from '@open-wc/scoped-elements'; -import {i18n} from './i18n.js'; +import {createInstance} from './i18n.js'; import {Icon} from '@dbp-toolkit/common'; import * as commonUtils from '@dbp-toolkit/common/utils'; import * as commonStyles from '@dbp-toolkit/common/styles'; @@ -41,6 +41,7 @@ export class CheckInPlaceSelect extends ScopedElementsMixin(AdapterLitElement) { this.reloadButtonTitle = ''; this.showCapacity = false; this.auth = {}; + this._i18n = createInstance(); this._onDocumentClicked = this._onDocumentClicked.bind(this); } @@ -159,7 +160,7 @@ export class CheckInPlaceSelect extends ScopedElementsMixin(AdapterLitElement) { width: '100%', language: this.lang === "de" ? select2LangDe() : select2LangEn(), minimumInputLength: 2, - placeholder: i18n.t('check-in-place-select.placeholder'), + placeholder: this._i18n.t('check-in-place-select.placeholder'), dropdownParent: this.$('#check-in-place-select-dropdown'), ajax: { delay: 500, @@ -291,7 +292,7 @@ export class CheckInPlaceSelect extends ScopedElementsMixin(AdapterLitElement) { changedProperties.forEach((oldValue, propName) => { switch (propName) { case "lang": - i18n.changeLanguage(this.lang); + this._i18n.changeLanguage(this.lang); if (this.select2IsInitialized()) { // no other way to set an other language at runtime did work @@ -377,6 +378,7 @@ export class CheckInPlaceSelect extends ScopedElementsMixin(AdapterLitElement) { render() { const select2CSS = commonUtils.getAssetURL(select2CSSPath); + const i18n = this._i18n; return html` <link rel="stylesheet" href="${select2CSS}"> <style> diff --git a/packages/check-in-place-select/src/dbp-check-in-place-select-demo.js b/packages/check-in-place-select/src/dbp-check-in-place-select-demo.js index 20c0b84e18a6cfa1e0877bb89be223589bea2ddd..d77e85619122d1d1a74b5cca5c94c7f281b3b615 100644 --- a/packages/check-in-place-select/src/dbp-check-in-place-select-demo.js +++ b/packages/check-in-place-select/src/dbp-check-in-place-select-demo.js @@ -1,4 +1,3 @@ -import {i18n} from './i18n.js'; import {css, html} from 'lit-element'; import {ScopedElementsMixin} from '@open-wc/scoped-elements'; import {CheckInPlaceSelect} from './check-in-place-select.js'; @@ -34,10 +33,6 @@ export class CheckInPlaceSelectDemo extends ScopedElementsMixin(DBPLitElement) { connectedCallback() { super.connectedCallback(); - i18n.changeLanguage(this.lang); - - this.updateComplete.then(()=>{ - }); } static get styles() { diff --git a/packages/check-in-place-select/src/i18n.js b/packages/check-in-place-select/src/i18n.js index 498d9f037b0a5ca481ec8de5df24640900285808..fbc1b032f3c662e149547117a8df129be5262e99 100644 --- a/packages/check-in-place-select/src/i18n.js +++ b/packages/check-in-place-select/src/i18n.js @@ -1,6 +1,10 @@ -import {createInstance} from '@dbp-toolkit/common/i18next.js'; +import {createInstance as _createInstance, setOverrides} from '@dbp-toolkit/common/i18next.js'; import de from './i18n/de/translation.json'; import en from './i18n/en/translation.json'; -export const i18n = createInstance({en: en, de: de}, 'de', 'en'); \ No newline at end of file +export function createInstance() { + return _createInstance({en: en, de: de}, 'de', 'en'); +} + +export {setOverrides}; \ No newline at end of file diff --git a/packages/check-in-place-select/src/i18n/de/translation.json b/packages/check-in-place-select/src/i18n/de/translation.json index 5c44dae5318c21ac5b4bf9a25c0009d51e3284a7..d1ff788578d8e22855ee2d10af1b33a4018d438a 100644 --- a/packages/check-in-place-select/src/i18n/de/translation.json +++ b/packages/check-in-place-select/src/i18n/de/translation.json @@ -1,7 +1,6 @@ { "check-in-place-select": { "placeholder": "Z.B. \"P1\", \"Rechbauerstraße\", \"PZ2EG048\"", - "error-summary": "Ein Fehler ist aufgetreten", "login-required": "Anmeldung erforderlich" } } diff --git a/packages/check-in-place-select/src/i18n/en/translation.json b/packages/check-in-place-select/src/i18n/en/translation.json index 1a525f6b174658879d83894f97a233302d7743f5..40dc94b22cf850aa5fcdba65ce14784e0e25f839 100644 --- a/packages/check-in-place-select/src/i18n/en/translation.json +++ b/packages/check-in-place-select/src/i18n/en/translation.json @@ -1,7 +1,6 @@ { "check-in-place-select": { "placeholder": "E.g. \"P1\", \"Rechbauerstraße\", \"PZ2EG048\"", - "error-summary": "An error occurred", "login-required": "Login required" } }