Skip to content
Snippets Groups Projects
Commit dc3c70ea authored by Kocher, Manuel's avatar Kocher, Manuel
Browse files

Add i18n instance and translation overrides support to adapter-lit-element

parent 68ee78a5
Branches
No related tags found
No related merge requests found
import {LitElement} from 'lit'; import {LitElement} from 'lit';
import {Logger} from './logger'; import {Logger} from './logger';
import {createInstance, setOverridesByGlobalCache} from './i18n.js';
export class AdapterLitElement extends LitElement { export class AdapterLitElement extends LitElement {
constructor() { constructor() {
...@@ -14,6 +15,10 @@ export class AdapterLitElement extends LitElement { ...@@ -14,6 +15,10 @@ export class AdapterLitElement extends LitElement {
this.subscribe = ''; this.subscribe = '';
this.unsubscribe = ''; this.unsubscribe = '';
// dir and i18next instance of translation overrides
this._i18n = createInstance();
this.langDir = '';
this.callbackStore = []; this.callbackStore = [];
// Previously we used direct properties like this["lang"] (instead of this.propertyStore["lang"]) for storing the // Previously we used direct properties like this["lang"] (instead of this.propertyStore["lang"]) for storing the
...@@ -79,6 +84,11 @@ export class AdapterLitElement extends LitElement { ...@@ -79,6 +84,11 @@ export class AdapterLitElement extends LitElement {
this.connected = true; this.connected = true;
// use translation overrides if path is given
if(this.langDir) {
setOverridesByGlobalCache(this._i18n, this);
}
const that = this; const that = this;
this.addEventListener( this.addEventListener(
...@@ -325,6 +335,7 @@ export class AdapterLitElement extends LitElement { ...@@ -325,6 +335,7 @@ export class AdapterLitElement extends LitElement {
subscribe: {type: String}, subscribe: {type: String},
unsubscribe: {type: String}, unsubscribe: {type: String},
providerRoot: {type: Boolean, attribute: 'provider-root'}, providerRoot: {type: Boolean, attribute: 'provider-root'},
langDir: {type: String, attribute: 'lang-dir'},
}; };
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment