Skip to content
Snippets Groups Projects
Commit 73b45d34 authored by Reiter, Christoph's avatar Reiter, Christoph :snake:
Browse files

checkin-place-select: port to one i18next instance per component instance

parent 8b653471
No related branches found
No related tags found
No related merge requests found
Pipeline #45037 failed
......@@ -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',
......
......@@ -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>
......
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() {
......
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
{
"check-in-place-select": {
"placeholder": "Z.B. \"P1\", \"Rechbauerstraße\", \"PZ2EG048\"",
"error-summary": "Ein Fehler ist aufgetreten",
"login-required": "Anmeldung erforderlich"
}
}
{
"check-in-place-select": {
"placeholder": "E.g. \"P1\", \"Rechbauerstraße\", \"PZ2EG048\"",
"error-summary": "An error occurred",
"login-required": "Login required"
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment