Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found
Select Git revision
  • advertisement
  • automagic
  • dbp-translation-component
  • demo
  • demo-file-handling
  • favorites-and-recent-files
  • icon-set-mapping
  • lit2
  • main
  • person-select-custom
  • port-i18next-parser
  • publish
  • remove-sentry
  • renovate/lock-file-maintenance
  • revert-6c632dc6
  • wc-part
  • wip-cleanup
17 results

Target

Select target project
  • 987FCF504483CBC8/toolkit
1 result
Select Git revision
  • advertisement
  • automagic
  • dbp-translation-component
  • demo
  • demo-file-handling
  • favorites-and-recent-files
  • icon-set-mapping
  • lit2
  • main
  • person-select-custom
  • port-i18next-parser
  • publish
  • remove-sentry
  • renovate/lock-file-maintenance
  • revert-6c632dc6
  • wc-part
  • wip-cleanup
17 results
Show changes
Showing
with 76 additions and 70 deletions
import {i18n} from './i18n'; import {createInstance} from './i18n';
import {createUUID} from './utils'; import {createUUID} from './utils';
import {css, html} from 'lit-element'; import {css, html} from 'lit-element';
import DBPLitElement from '@dbp-toolkit/common/dbp-lit-element'; import DBPLitElement from '@dbp-toolkit/common/dbp-lit-element';
...@@ -10,7 +10,8 @@ import * as commonStyles from '@dbp-toolkit/common/styles'; ...@@ -10,7 +10,8 @@ import * as commonStyles from '@dbp-toolkit/common/styles';
export class Notification extends DBPLitElement { export class Notification extends DBPLitElement {
constructor() { constructor() {
super(); super();
this.lang = 'de'; this._i18n = createInstance();
this.lang = this._i18n.language;
} }
/** /**
...@@ -25,7 +26,6 @@ export class Notification extends DBPLitElement { ...@@ -25,7 +26,6 @@ export class Notification extends DBPLitElement {
connectedCallback() { connectedCallback() {
super.connectedCallback(); super.connectedCallback();
i18n.changeLanguage(this.lang);
const that = this; const that = this;
window.addEventListener("dbp-notification-send", (e) => { window.addEventListener("dbp-notification-send", (e) => {
...@@ -63,9 +63,6 @@ export class Notification extends DBPLitElement { ...@@ -63,9 +63,6 @@ export class Notification extends DBPLitElement {
// mark the event as handled // mark the event as handled
e.preventDefault(); e.preventDefault();
}); });
this.updateComplete.then(()=>{
});
} }
removeMessageId(messageElementId) { removeMessageId(messageElementId) {
......
...@@ -6,6 +6,7 @@ module.exports = { ...@@ -6,6 +6,7 @@ module.exports = {
options: { options: {
debug: false, debug: false,
removeUnusedKeys: true, removeUnusedKeys: true,
func: {list: ['i18n.t', '_i18n.t']},
lngs: ['en','de'], lngs: ['en','de'],
resource: { resource: {
loadPath: 'src/i18n/{{lng}}/{{ns}}.json', loadPath: 'src/i18n/{{lng}}/{{ns}}.json',
......
import {i18n} from './i18n.js'; import {createInstance} from './i18n.js';
import {css, html} from 'lit-element'; import {css, html} from 'lit-element';
import {ScopedElementsMixin} from '@open-wc/scoped-elements'; import {ScopedElementsMixin} from '@open-wc/scoped-elements';
import {OrganizationSelect} from './organization-select.js'; import {OrganizationSelect} from './organization-select.js';
...@@ -10,7 +10,8 @@ import DBPLitElement from "@dbp-toolkit/common/dbp-lit-element"; ...@@ -10,7 +10,8 @@ import DBPLitElement from "@dbp-toolkit/common/dbp-lit-element";
export class OrganizationSelectDemo extends ScopedElementsMixin(DBPLitElement) { export class OrganizationSelectDemo extends ScopedElementsMixin(DBPLitElement) {
constructor() { constructor() {
super(); super();
this.lang = 'de'; this._i18n = createInstance();
this.lang = this._i18n.language;
this.entryPointUrl = ''; this.entryPointUrl = '';
this.noAuth = false; this.noAuth = false;
} }
...@@ -32,12 +33,11 @@ export class OrganizationSelectDemo extends ScopedElementsMixin(DBPLitElement) { ...@@ -32,12 +33,11 @@ export class OrganizationSelectDemo extends ScopedElementsMixin(DBPLitElement) {
}; };
} }
connectedCallback() { update(changedProperties) {
super.connectedCallback(); if (changedProperties.has("lang")) {
i18n.changeLanguage(this.lang); this._i18n.changeLanguage(this.lang);
}
this.updateComplete.then(()=>{ super.update(changedProperties);
});
} }
static get styles() { static get styles() {
......
import {createInstance} from '@dbp-toolkit/common/i18next.js'; import {createInstance as _createInstance} from '@dbp-toolkit/common/i18next.js';
import de from './i18n/de/translation.json'; import de from './i18n/de/translation.json';
import en from './i18n/en/translation.json'; import en from './i18n/en/translation.json';
export const i18n = createInstance({en: en, de: de}, 'de', 'en'); export function createInstance() {
\ No newline at end of file return _createInstance({en: en, de: de}, 'de', 'en');
}
\ No newline at end of file
{ {
"select-organization": { "select-organization": {
"placeholder": "Bitte wählen Sie ein Institut aus", "placeholder": "Bitte wählen Sie ein Institut aus",
"loading": "Wird geladen...", "loading": "Wird geladen..."
"load-error": "Fehler beim Laden der Organisation"
} }
} }
{ {
"select-organization": { "select-organization": {
"placeholder": "Please select an organization", "placeholder": "Please select an organization",
"loading": "Loading...", "loading": "Loading..."
"load-error": "Error loading the organization"
} }
} }
import $ from 'jquery'; import $ from 'jquery';
import select2 from 'select2'; import select2 from 'select2';
import select2CSSPath from 'select2/dist/css/select2.min.css'; import select2CSSPath from 'select2/dist/css/select2.min.css';
import {i18n} from './i18n.js'; import {createInstance} from './i18n.js';
import {css, html} from 'lit-element'; import {css, html} from 'lit-element';
import * as commonUtils from '@dbp-toolkit/common/utils'; import * as commonUtils from '@dbp-toolkit/common/utils';
import * as commonStyles from '@dbp-toolkit/common/styles'; import * as commonStyles from '@dbp-toolkit/common/styles';
...@@ -16,7 +16,8 @@ export class OrganizationSelect extends AdapterLitElement { ...@@ -16,7 +16,8 @@ export class OrganizationSelect extends AdapterLitElement {
constructor() { constructor() {
super(); super();
this.auth = {}; this.auth = {};
this.lang = i18n.language; this._i18n = createInstance();
this.lang = this._i18n.language;
this.entryPointUrl = ''; this.entryPointUrl = '';
this.jsonld = null; this.jsonld = null;
this.organizations = []; this.organizations = [];
...@@ -93,6 +94,7 @@ export class OrganizationSelect extends AdapterLitElement { ...@@ -93,6 +94,7 @@ export class OrganizationSelect extends AdapterLitElement {
} }
async updateSelect2() { async updateSelect2() {
const i18n = this._i18n;
await this.updateComplete; await this.updateComplete;
const $select = this.$('#' + this.selectId); const $select = this.$('#' + this.selectId);
...@@ -181,7 +183,7 @@ export class OrganizationSelect extends AdapterLitElement { ...@@ -181,7 +183,7 @@ export class OrganizationSelect extends AdapterLitElement {
changedProperties.forEach((oldValue, propName) => { changedProperties.forEach((oldValue, propName) => {
switch (propName) { switch (propName) {
case "lang": case "lang":
i18n.changeLanguage(this.lang); this._i18n.changeLanguage(this.lang);
this.updateSelect2(); this.updateSelect2();
break; break;
case "value": { case "value": {
......
...@@ -6,6 +6,7 @@ module.exports = { ...@@ -6,6 +6,7 @@ module.exports = {
options: { options: {
debug: false, debug: false,
removeUnusedKeys: true, removeUnusedKeys: true,
func: {list: ['i18n.t', '_i18n.t']},
lngs: ['en','de'], lngs: ['en','de'],
resource: { resource: {
loadPath: 'src/i18n/{{lng}}/{{ns}}.json', loadPath: 'src/i18n/{{lng}}/{{ns}}.json',
......
import {AuthKeycloak, LoginButton} from '@dbp-toolkit/auth'; import {AuthKeycloak, LoginButton} from '@dbp-toolkit/auth';
import {i18n} from './i18n.js'; import {createInstance} from './i18n.js';
import {css, html} from 'lit-element'; import {css, html} from 'lit-element';
import {ScopedElementsMixin} from '@open-wc/scoped-elements'; import {ScopedElementsMixin} from '@open-wc/scoped-elements';
import DBPLitElement from '@dbp-toolkit/common/dbp-lit-element'; import DBPLitElement from '@dbp-toolkit/common/dbp-lit-element';
...@@ -12,7 +12,8 @@ import {PersonSelect} from '@dbp-toolkit/person-select'; ...@@ -12,7 +12,8 @@ import {PersonSelect} from '@dbp-toolkit/person-select';
export class PersonProfileDemo extends ScopedElementsMixin(DBPLitElement) { export class PersonProfileDemo extends ScopedElementsMixin(DBPLitElement) {
constructor() { constructor() {
super(); super();
this.lang = 'de'; this._i18n = createInstance();
this.lang = this._i18n.language;
this.entryPointUrl = ''; this.entryPointUrl = '';
this.person = ''; this.person = '';
this.selectedPerson = ''; this.selectedPerson = '';
...@@ -42,6 +43,10 @@ export class PersonProfileDemo extends ScopedElementsMixin(DBPLitElement) { ...@@ -42,6 +43,10 @@ export class PersonProfileDemo extends ScopedElementsMixin(DBPLitElement) {
} }
update(changedProperties) { update(changedProperties) {
if (changedProperties.has("lang")) {
this._i18n.changeLanguage(this.lang);
}
changedProperties.forEach((oldValue, propName) => { changedProperties.forEach((oldValue, propName) => {
switch (propName) { switch (propName) {
case 'auth': case 'auth':
...@@ -61,7 +66,6 @@ export class PersonProfileDemo extends ScopedElementsMixin(DBPLitElement) { ...@@ -61,7 +66,6 @@ export class PersonProfileDemo extends ScopedElementsMixin(DBPLitElement) {
connectedCallback() { connectedCallback() {
super.connectedCallback(); super.connectedCallback();
i18n.changeLanguage(this.lang);
const that = this; const that = this;
this.updateComplete.then(()=>{ this.updateComplete.then(()=>{
......
import {createInstance} from '@dbp-toolkit/common/i18next.js'; import {createInstance as _createInstance} from '@dbp-toolkit/common/i18next.js';
import de from './i18n/de/translation.json'; import de from './i18n/de/translation.json';
import en from './i18n/en/translation.json'; import en from './i18n/en/translation.json';
export const i18n = createInstance({en: en, de: de}, 'de', 'en'); export function createInstance() {
\ No newline at end of file return _createInstance({en: en, de: de}, 'de', 'en');
}
\ No newline at end of file
import JSONLD from '@dbp-toolkit/common/jsonld'; import JSONLD from '@dbp-toolkit/common/jsonld';
import {css, html} from 'lit-element'; import {css, html} from 'lit-element';
import {i18n} from './i18n.js'; import {createInstance} from './i18n.js';
import DBPLitElement from '@dbp-toolkit/common/dbp-lit-element'; import DBPLitElement from '@dbp-toolkit/common/dbp-lit-element';
import * as commonStyles from '@dbp-toolkit/common/styles'; import * as commonStyles from '@dbp-toolkit/common/styles';
...@@ -10,7 +10,8 @@ export class PersonProfile extends DBPLitElement { ...@@ -10,7 +10,8 @@ export class PersonProfile extends DBPLitElement {
constructor() { constructor() {
super(); super();
this.lang = 'de'; this._i18n = createInstance();
this.lang = this._i18n.language;
this.entryPointUrl = ''; this.entryPointUrl = '';
this.jsonld = null; this.jsonld = null;
this.value = ''; this.value = '';
...@@ -29,18 +30,11 @@ export class PersonProfile extends DBPLitElement { ...@@ -29,18 +30,11 @@ export class PersonProfile extends DBPLitElement {
}; };
} }
connectedCallback() {
super.connectedCallback();
this.updateComplete.then(()=>{
});
}
update(changedProperties) { update(changedProperties) {
changedProperties.forEach((oldValue, propName) => { changedProperties.forEach((oldValue, propName) => {
switch (propName) { switch (propName) {
case "lang": case "lang":
i18n.changeLanguage(this.lang); this._i18n.changeLanguage(this.lang);
break; break;
case "entryPointUrl": { case "entryPointUrl": {
const that = this; const that = this;
...@@ -83,6 +77,7 @@ export class PersonProfile extends DBPLitElement { ...@@ -83,6 +77,7 @@ export class PersonProfile extends DBPLitElement {
} }
render() { render() {
const i18n = this._i18n;
let role = i18n.t('person-profile.unknown'); let role = i18n.t('person-profile.unknown');
if (this.person !== null && this.person.roles !== undefined) { if (this.person !== null && this.person.roles !== undefined) {
// roles are only defined for self-disclosure // roles are only defined for self-disclosure
......
...@@ -6,6 +6,7 @@ module.exports = { ...@@ -6,6 +6,7 @@ module.exports = {
options: { options: {
debug: false, debug: false,
removeUnusedKeys: true, removeUnusedKeys: true,
func: {list: ['i18n.t', '_i18n.t']},
lngs: ['en','de'], lngs: ['en','de'],
resource: { resource: {
loadPath: 'src/i18n/{{lng}}/{{ns}}.json', loadPath: 'src/i18n/{{lng}}/{{ns}}.json',
......
import {i18n} from './i18n.js'; import {createInstance} from './i18n.js';
import {css, html} from 'lit-element'; import {css, html} from 'lit-element';
import {ScopedElementsMixin} from '@open-wc/scoped-elements'; import {ScopedElementsMixin} from '@open-wc/scoped-elements';
import {PersonSelect} from './person-select.js'; import {PersonSelect} from './person-select.js';
...@@ -10,7 +10,8 @@ import DBPLitElement from "@dbp-toolkit/common/dbp-lit-element"; ...@@ -10,7 +10,8 @@ import DBPLitElement from "@dbp-toolkit/common/dbp-lit-element";
export class PersonSelectDemo extends ScopedElementsMixin(DBPLitElement) { export class PersonSelectDemo extends ScopedElementsMixin(DBPLitElement) {
constructor() { constructor() {
super(); super();
this.lang = 'de'; this._i18n = createInstance();
this.lang = this._i18n.language;
this.entryPointUrl = ''; this.entryPointUrl = '';
this.noAuth = false; this.noAuth = false;
} }
...@@ -32,14 +33,6 @@ export class PersonSelectDemo extends ScopedElementsMixin(DBPLitElement) { ...@@ -32,14 +33,6 @@ export class PersonSelectDemo extends ScopedElementsMixin(DBPLitElement) {
}; };
} }
connectedCallback() {
super.connectedCallback();
i18n.changeLanguage(this.lang);
this.updateComplete.then(()=>{
});
}
static get styles() { static get styles() {
// language=css // language=css
return [ return [
...@@ -52,6 +45,13 @@ export class PersonSelectDemo extends ScopedElementsMixin(DBPLitElement) { ...@@ -52,6 +45,13 @@ export class PersonSelectDemo extends ScopedElementsMixin(DBPLitElement) {
]; ];
} }
update(changedProperties) {
if (changedProperties.has("lang")) {
this._i18n.changeLanguage(this.lang);
}
super.update(changedProperties);
}
getAuthComponentHtml() { getAuthComponentHtml() {
return this.noAuth ? html`<dbp-login-button subscribe="auth" lang="${this.lang}" show-image></dbp-login-button>` : html` return this.noAuth ? html`<dbp-login-button subscribe="auth" lang="${this.lang}" show-image></dbp-login-button>` : html`
<div class="container"> <div class="container">
......
import {createInstance} from '@dbp-toolkit/common/i18next.js'; import {createInstance as _createInstance} from '@dbp-toolkit/common/i18next.js';
import de from './i18n/de/translation.json'; import de from './i18n/de/translation.json';
import en from './i18n/en/translation.json'; import en from './i18n/en/translation.json';
export const i18n = createInstance({en: en, de: de}, 'de', 'en'); export function createInstance() {
\ No newline at end of file return _createInstance({en: en, de: de}, 'de', 'en');
}
\ No newline at end of file
{ {
"person-select": { "person-select": {
"placeholder": "Bitte wählen Sie eine Person aus", "placeholder": "Bitte wählen Sie eine Person aus",
"error-summary": "Ein Fehler ist aufgetreten",
"login-required": "Anmeldung erforderlich" "login-required": "Anmeldung erforderlich"
} }
} }
{ {
"person-select": { "person-select": {
"placeholder": "Please select a person", "placeholder": "Please select a person",
"error-summary": "An error occurred",
"login-required": "Login required" "login-required": "Login required"
} }
} }
...@@ -6,7 +6,7 @@ import select2LangEn from './i18n/en/select2'; ...@@ -6,7 +6,7 @@ import select2LangEn from './i18n/en/select2';
import JSONLD from '@dbp-toolkit/common/jsonld'; import JSONLD from '@dbp-toolkit/common/jsonld';
import {css, html} from 'lit-element'; import {css, html} from 'lit-element';
import {ScopedElementsMixin} from '@open-wc/scoped-elements'; import {ScopedElementsMixin} from '@open-wc/scoped-elements';
import {i18n} from './i18n.js'; import {createInstance} from './i18n.js';
import {Icon} from '@dbp-toolkit/common'; import {Icon} from '@dbp-toolkit/common';
import * as commonUtils from '@dbp-toolkit/common/utils'; import * as commonUtils from '@dbp-toolkit/common/utils';
import * as commonStyles from '@dbp-toolkit/common/styles'; import * as commonStyles from '@dbp-toolkit/common/styles';
...@@ -29,7 +29,8 @@ export class PersonSelect extends ScopedElementsMixin(AdapterLitElement) { ...@@ -29,7 +29,8 @@ export class PersonSelect extends ScopedElementsMixin(AdapterLitElement) {
super(); super();
Object.assign(PersonSelect.prototype, errorUtils.errorMixin); Object.assign(PersonSelect.prototype, errorUtils.errorMixin);
this.auth = {}; this.auth = {};
this.lang = 'de'; this._i18n = createInstance();
this.lang = this._i18n.language;
this.entryPointUrl = ''; this.entryPointUrl = '';
this.jsonld = null; this.jsonld = null;
this.$select = null; this.$select = null;
...@@ -129,6 +130,7 @@ export class PersonSelect extends ScopedElementsMixin(AdapterLitElement) { ...@@ -129,6 +130,7 @@ export class PersonSelect extends ScopedElementsMixin(AdapterLitElement) {
* @param ignorePreset * @param ignorePreset
*/ */
initSelect2(ignorePreset = false) { initSelect2(ignorePreset = false) {
const i18n = this._i18n;
const that = this; const that = this;
const $this = $(this); const $this = $(this);
...@@ -155,7 +157,7 @@ export class PersonSelect extends ScopedElementsMixin(AdapterLitElement) { ...@@ -155,7 +157,7 @@ export class PersonSelect extends ScopedElementsMixin(AdapterLitElement) {
width: '100%', width: '100%',
language: this.lang === "de" ? select2LangDe() : select2LangEn(), language: this.lang === "de" ? select2LangDe() : select2LangEn(),
minimumInputLength: 2, minimumInputLength: 2,
placeholder: i18n.t(this.authenticated() ? 'person-select.placeholder' : 'person-select.login-required'), placeholder: this.authenticated() ? i18n.t('person-select.placeholder') : i18n.t('person-select.login-required'),
dropdownParent: this.$('#person-select-dropdown'), dropdownParent: this.$('#person-select-dropdown'),
ajax: { ajax: {
delay: 500, delay: 500,
...@@ -277,7 +279,7 @@ export class PersonSelect extends ScopedElementsMixin(AdapterLitElement) { ...@@ -277,7 +279,7 @@ export class PersonSelect extends ScopedElementsMixin(AdapterLitElement) {
changedProperties.forEach((oldValue, propName) => { changedProperties.forEach((oldValue, propName) => {
switch (propName) { switch (propName) {
case "lang": case "lang":
i18n.changeLanguage(this.lang); this._i18n.changeLanguage(this.lang);
if (this.select2IsInitialized()) { if (this.select2IsInitialized()) {
// no other way to set an other language at runtime did work // no other way to set an other language at runtime did work
...@@ -361,6 +363,7 @@ export class PersonSelect extends ScopedElementsMixin(AdapterLitElement) { ...@@ -361,6 +363,7 @@ export class PersonSelect extends ScopedElementsMixin(AdapterLitElement) {
} }
render() { render() {
const i18n = this._i18n;
const select2CSS = commonUtils.getAssetURL(select2CSSPath); const select2CSS = commonUtils.getAssetURL(select2CSSPath);
return html` return html`
<link rel="stylesheet" href="${select2CSS}"> <link rel="stylesheet" href="${select2CSS}">
......
...@@ -6,6 +6,7 @@ module.exports = { ...@@ -6,6 +6,7 @@ module.exports = {
options: { options: {
debug: false, debug: false,
removeUnusedKeys: true, removeUnusedKeys: true,
func: {list: ['i18n.t', '_i18n.t']},
lngs: ['en','de'], lngs: ['en','de'],
resource: { resource: {
loadPath: 'src/i18n/{{lng}}/{{ns}}.json', loadPath: 'src/i18n/{{lng}}/{{ns}}.json',
......
import {i18n} from './i18n.js'; import {createInstance} from './i18n.js';
import {css, html} from 'lit-element'; import {css, html} from 'lit-element';
import {ScopedElementsMixin} from '@open-wc/scoped-elements'; import {ScopedElementsMixin} from '@open-wc/scoped-elements';
import {AuthKeycloak, LoginButton} from '@dbp-toolkit/auth'; import {AuthKeycloak, LoginButton} from '@dbp-toolkit/auth';
...@@ -14,7 +14,8 @@ class ProviderDemo extends ScopedElementsMixin(DBPLitElement) { ...@@ -14,7 +14,8 @@ class ProviderDemo extends ScopedElementsMixin(DBPLitElement) {
constructor() { constructor() {
super(); super();
this.lang = 'de'; this._i18n = createInstance();
this.lang = this._i18n.language;
} }
static get scopedElements() { static get scopedElements() {
...@@ -35,18 +36,12 @@ class ProviderDemo extends ScopedElementsMixin(DBPLitElement) { ...@@ -35,18 +36,12 @@ class ProviderDemo extends ScopedElementsMixin(DBPLitElement) {
}; };
} }
connectedCallback() {
super.connectedCallback();
i18n.changeLanguage(this.lang);
}
attributeChangedCallback(name, oldValue, newValue) { attributeChangedCallback(name, oldValue, newValue) {
console.debug('ProviderDemo (' + this.id + ') attributeChangesCallback( ' + name + ', ' + oldValue + ', ' + newValue + ')'); console.debug('ProviderDemo (' + this.id + ') attributeChangesCallback( ' + name + ', ' + oldValue + ', ' + newValue + ')');
switch(name) { switch(name) {
case 'lang': case 'lang':
this.lang = newValue; this.lang = newValue;
i18n.changeLanguage(this.lang); this._i18n.changeLanguage(this.lang);
break; break;
default: default:
super.attributeChangedCallback(name, oldValue, newValue); super.attributeChangedCallback(name, oldValue, newValue);
...@@ -71,6 +66,7 @@ class ProviderDemo extends ScopedElementsMixin(DBPLitElement) { ...@@ -71,6 +66,7 @@ class ProviderDemo extends ScopedElementsMixin(DBPLitElement) {
} }
render() { render() {
const i18n = this._i18n;
return html` return html`
<section class="section"> <section class="section">
<p>${i18n.t('demo.provider_description', {id: "root", description: "is the top most in hierarchy"})}</p> <p>${i18n.t('demo.provider_description', {id: "root", description: "is the top most in hierarchy"})}</p>
...@@ -142,7 +138,8 @@ class DemoConsumer extends DBPLitElement { ...@@ -142,7 +138,8 @@ class DemoConsumer extends DBPLitElement {
constructor() { constructor() {
super(); super();
this.lang = 'de'; this._i18n = createInstance();
this.lang = this._i18n.language;
this.entryPointUrl = ''; this.entryPointUrl = '';
// default values // default values
this.foo = 100; this.foo = 100;
...@@ -157,7 +154,6 @@ class DemoConsumer extends DBPLitElement { ...@@ -157,7 +154,6 @@ class DemoConsumer extends DBPLitElement {
connectedCallback() { connectedCallback() {
super.connectedCallback(); super.connectedCallback();
i18n.changeLanguage(this.lang);
console.debug('DemoConsumer(' + this.id + ') connectedCallback()'); console.debug('DemoConsumer(' + this.id + ') connectedCallback()');
this.render(); this.render();
} }
...@@ -184,7 +180,7 @@ class DemoConsumer extends DBPLitElement { ...@@ -184,7 +180,7 @@ class DemoConsumer extends DBPLitElement {
switch(name) { switch(name) {
case 'lang': case 'lang':
this.lang = newValue; this.lang = newValue;
i18n.changeLanguage(this.lang); this._i18n.changeLanguage(this.lang);
break; break;
case 'foo': case 'foo':
this.foo = parseInt(newValue); this.foo = parseInt(newValue);
...@@ -209,6 +205,7 @@ class DemoConsumer extends DBPLitElement { ...@@ -209,6 +205,7 @@ class DemoConsumer extends DBPLitElement {
} }
render() { render() {
const i18n = this._i18n;
if (! this.connected) { if (! this.connected) {
return `not connected!`; return `not connected!`;
} }
......
import {createInstance} from '@dbp-toolkit/common/i18next.js'; import {createInstance as _createInstance} from '@dbp-toolkit/common/i18next.js';
import de from './i18n/de/translation.json'; import de from './i18n/de/translation.json';
import en from './i18n/en/translation.json'; import en from './i18n/en/translation.json';
export const i18n = createInstance({en: en, de: de}, 'de', 'en'); export function createInstance() {
\ No newline at end of file return _createInstance({en: en, de: de}, 'de', 'en');
}
\ No newline at end of file