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

Add missing langDir properties to components

parent c9355068
No related branches found
No related tags found
No related merge requests found
Showing
with 87 additions and 13 deletions
import {createInstance} from './i18n.js'; import {createInstance, setOverridesByGlobalCache} from './i18n.js';
import {html, css} from 'lit'; import {html, css} from 'lit';
import {ScopedElementsMixin} from '@open-wc/scoped-elements'; import {ScopedElementsMixin} from '@open-wc/scoped-elements';
import {LanguageSelect} from '@dbp-toolkit/language-select'; import {LanguageSelect} from '@dbp-toolkit/language-select';
...@@ -283,6 +283,10 @@ export class AppShell extends ScopedElementsMixin(DBPLitElement) { ...@@ -283,6 +283,10 @@ export class AppShell extends ScopedElementsMixin(DBPLitElement) {
if (this.src) { if (this.src) {
this.fetchMetadata(this.src); this.fetchMetadata(this.src);
} }
if (this.langDir != '') {
setOverridesByGlobalCache(this._i18n, this);
}
} }
/** /**
......
import {createInstance} from './i18n.js'; import {createInstance, setOverridesByGlobalCache} from './i18n.js';
import {html, css} from 'lit'; import {html, css} from 'lit';
import {unsafeHTML} from 'lit/directives/unsafe-html.js'; import {unsafeHTML} from 'lit/directives/unsafe-html.js';
import {ScopedElementsMixin} from '@open-wc/scoped-elements'; import {ScopedElementsMixin} from '@open-wc/scoped-elements';
...@@ -12,6 +12,7 @@ export class AuthMenuButton extends ScopedElementsMixin(AdapterLitElement) { ...@@ -12,6 +12,7 @@ export class AuthMenuButton extends ScopedElementsMixin(AdapterLitElement) {
super(); super();
this._i18n = createInstance(); this._i18n = createInstance();
this.lang = this._i18n.language; this.lang = this._i18n.language;
this.langDir = '';
this.auth = {}; this.auth = {};
this.closeDropdown = this.closeDropdown.bind(this); this.closeDropdown = this.closeDropdown.bind(this);
...@@ -28,6 +29,7 @@ export class AuthMenuButton extends ScopedElementsMixin(AdapterLitElement) { ...@@ -28,6 +29,7 @@ export class AuthMenuButton extends ScopedElementsMixin(AdapterLitElement) {
return { return {
...super.properties, ...super.properties,
lang: {type: String}, lang: {type: String},
langDir: {type: String},
auth: {type: Object}, auth: {type: Object},
}; };
} }
...@@ -41,6 +43,10 @@ export class AuthMenuButton extends ScopedElementsMixin(AdapterLitElement) { ...@@ -41,6 +43,10 @@ export class AuthMenuButton extends ScopedElementsMixin(AdapterLitElement) {
window.addEventListener('resize', this.onWindowResize); window.addEventListener('resize', this.onWindowResize);
document.addEventListener('click', this.closeDropdown); document.addEventListener('click', this.closeDropdown);
if (this.langDir != '') {
setOverridesByGlobalCache(this._i18n, this);
}
} }
disconnectedCallback() { disconnectedCallback() {
......
import {html, LitElement} from 'lit'; import {html, LitElement} from 'lit';
import {createInstance} from './i18n.js'; import {createInstance, setOverridesByGlobalCache} from './i18n.js';
import * as commonUtils from '@dbp-toolkit/common/utils'; import * as commonUtils from '@dbp-toolkit/common/utils';
class ActivityExample extends LitElement { class ActivityExample extends LitElement {
...@@ -7,14 +7,24 @@ class ActivityExample extends LitElement { ...@@ -7,14 +7,24 @@ class ActivityExample extends LitElement {
super(); super();
this._i18n = createInstance(); this._i18n = createInstance();
this.lang = this._i18n.language; this.lang = this._i18n.language;
this.langDir = '';
} }
static get properties() { static get properties() {
return { return {
lang: {type: String}, lang: {type: String},
langDir: {type: String},
}; };
} }
connectedCallback() {
super.connectedCallback();
if (this.langDir != '') {
setOverridesByGlobalCache(this._i18n, this);
}
}
update(changedProperties) { update(changedProperties) {
changedProperties.forEach((oldValue, propName) => { changedProperties.forEach((oldValue, propName) => {
switch (propName) { switch (propName) {
......
import {createInstance} from './i18n.js'; import {createInstance, setOverridesByGlobalCache} from './i18n.js';
import {css, html, LitElement} from 'lit'; import {css, html, LitElement} from 'lit';
import {ScopedElementsMixin} from '@open-wc/scoped-elements'; import {ScopedElementsMixin} from '@open-wc/scoped-elements';
import * as commonUtils from '@dbp-toolkit/common/utils'; import * as commonUtils from '@dbp-toolkit/common/utils';
...@@ -9,6 +9,7 @@ class AppShellWelcome extends ScopedElementsMixin(LitElement) { ...@@ -9,6 +9,7 @@ class AppShellWelcome extends ScopedElementsMixin(LitElement) {
super(); super();
this._i18n = createInstance(); this._i18n = createInstance();
this.lang = this._i18n.language; this.lang = this._i18n.language;
this.langDir = '';
this._onVisibilityChanged = this._onVisibilityChanged.bind(this); this._onVisibilityChanged = this._onVisibilityChanged.bind(this);
} }
...@@ -16,6 +17,7 @@ class AppShellWelcome extends ScopedElementsMixin(LitElement) { ...@@ -16,6 +17,7 @@ class AppShellWelcome extends ScopedElementsMixin(LitElement) {
static get properties() { static get properties() {
return { return {
lang: {type: String}, lang: {type: String},
langDir: {type: String},
}; };
} }
...@@ -99,6 +101,10 @@ class AppShellWelcome extends ScopedElementsMixin(LitElement) { ...@@ -99,6 +101,10 @@ class AppShellWelcome extends ScopedElementsMixin(LitElement) {
const app = AppShellWelcome._app; const app = AppShellWelcome._app;
app.addEventListener('visibility-changed', this._onVisibilityChanged); app.addEventListener('visibility-changed', this._onVisibilityChanged);
if (this.langDir != '') {
setOverridesByGlobalCache(this._i18n, this);
}
} }
disconnectedCallback() { disconnectedCallback() {
......
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 de from './i18n/de/translation.json';
import en from './i18n/en/translation.json'; import en from './i18n/en/translation.json';
...@@ -6,3 +6,5 @@ import en from './i18n/en/translation.json'; ...@@ -6,3 +6,5 @@ import en from './i18n/en/translation.json';
export function createInstance() { export function createInstance() {
return _createInstance({en: en, de: de}, 'de', 'en'); return _createInstance({en: en, de: de}, 'de', 'en');
} }
export {setOverridesByGlobalCache};
import {html, css} from 'lit'; import {html, css} from 'lit';
import * as commonStyles from '@dbp-toolkit/common/styles'; 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'; import {AdapterLitElement} from '@dbp-toolkit/common';
export class TUGrazLogo extends AdapterLitElement { export class TUGrazLogo extends AdapterLitElement {
...@@ -9,15 +9,25 @@ export class TUGrazLogo extends AdapterLitElement { ...@@ -9,15 +9,25 @@ export class TUGrazLogo extends AdapterLitElement {
this._i18n = createInstance(); this._i18n = createInstance();
this.lang = this._i18n.language; this.lang = this._i18n.language;
this.langDir = '';
} }
static get properties() { static get properties() {
return { return {
...super.properties, ...super.properties,
lang: {type: String}, lang: {type: String},
langDir: {type: String},
}; };
} }
connectedCallback() {
super.connectedCallback();
if (this.langDir != '') {
setOverridesByGlobalCache(this._i18n, this);
}
}
update(changedProperties) { update(changedProperties) {
changedProperties.forEach((oldValue, propName) => { changedProperties.forEach((oldValue, propName) => {
if (propName === 'lang') { if (propName === 'lang') {
......
import {createInstance} from './i18n.js'; import {createInstance, setOverridesByGlobalCache} from './i18n.js';
import JSONLD from '@dbp-toolkit/common/jsonld'; import JSONLD from '@dbp-toolkit/common/jsonld';
import {KeycloakWrapper} from './keycloak.js'; import {KeycloakWrapper} from './keycloak.js';
import {LoginStatus} from './util.js'; import {LoginStatus} from './util.js';
...@@ -32,6 +32,7 @@ export class AuthKeycloak extends AdapterLitElement { ...@@ -32,6 +32,7 @@ export class AuthKeycloak extends AdapterLitElement {
this.requestedLoginStatus = LoginStatus.UNKNOWN; this.requestedLoginStatus = LoginStatus.UNKNOWN;
this._i18n = createInstance(); this._i18n = createInstance();
this.lang = this._i18n.language; this.lang = this._i18n.language;
this.langDir = '';
// Keycloak config // Keycloak config
this.keycloakUrl = null; this.keycloakUrl = null;
...@@ -185,6 +186,7 @@ export class AuthKeycloak extends AdapterLitElement { ...@@ -185,6 +186,7 @@ export class AuthKeycloak extends AdapterLitElement {
return { return {
...super.properties, ...super.properties,
lang: {type: String}, lang: {type: String},
langDir: {type: String},
forceLogin: {type: Boolean, attribute: 'force-login'}, forceLogin: {type: Boolean, attribute: 'force-login'},
tryLogin: {type: Boolean, attribute: 'try-login'}, tryLogin: {type: Boolean, attribute: 'try-login'},
entryPointUrl: {type: String, attribute: 'entry-point-url'}, entryPointUrl: {type: String, attribute: 'entry-point-url'},
...@@ -246,6 +248,10 @@ export class AuthKeycloak extends AdapterLitElement { ...@@ -246,6 +248,10 @@ export class AuthKeycloak extends AdapterLitElement {
}; };
handleLogin(); handleLogin();
if (this.langDir != '') {
setOverridesByGlobalCache(this._i18n, this);
}
} }
disconnectedCallback() { disconnectedCallback() {
......
import {createInstance} from './i18n.js'; import {createInstance, setOverridesByGlobalCache} from './i18n.js';
import {html} from 'lit'; import {html} from 'lit';
import {ScopedElementsMixin} from '@open-wc/scoped-elements'; import {ScopedElementsMixin} from '@open-wc/scoped-elements';
import {AuthKeycloak} from './auth-keycloak.js'; import {AuthKeycloak} from './auth-keycloak.js';
...@@ -15,6 +15,7 @@ export class DbpAuthDemo extends ScopedElementsMixin(DBPLitElement) { ...@@ -15,6 +15,7 @@ export class DbpAuthDemo extends ScopedElementsMixin(DBPLitElement) {
this.noAuth = false; this.noAuth = false;
this._i18n = createInstance(); this._i18n = createInstance();
this.lang = this._i18n.language; this.lang = this._i18n.language;
this.langDir = '';
} }
static get scopedElements() { static get scopedElements() {
...@@ -28,12 +29,21 @@ export class DbpAuthDemo extends ScopedElementsMixin(DBPLitElement) { ...@@ -28,12 +29,21 @@ export class DbpAuthDemo extends ScopedElementsMixin(DBPLitElement) {
return { return {
...super.properties, ...super.properties,
lang: {type: String}, lang: {type: String},
langDir: {type: String},
entryPointUrl: {type: String, attribute: 'entry-point-url'}, entryPointUrl: {type: String, attribute: 'entry-point-url'},
auth: {type: Object}, auth: {type: Object},
noAuth: {type: Boolean, attribute: 'no-auth'}, noAuth: {type: Boolean, attribute: 'no-auth'},
}; };
} }
connectedCallback() {
super.connectedCallback();
if (this.langDir != '') {
setOverridesByGlobalCache(this._i18n, this);
}
}
update(changedProperties) { update(changedProperties) {
changedProperties.forEach((oldValue, propName) => { changedProperties.forEach((oldValue, propName) => {
if (propName === 'lang') { if (propName === 'lang') {
......
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 de from './i18n/de/translation.json';
import en from './i18n/en/translation.json'; import en from './i18n/en/translation.json';
...@@ -7,4 +7,4 @@ export function createInstance() { ...@@ -7,4 +7,4 @@ export function createInstance() {
return _createInstance({en: en, de: de}, 'de', 'en'); return _createInstance({en: en, de: de}, 'de', 'en');
} }
export {setOverrides}; export {setOverridesByGlobalCache};
import {createInstance} from './i18n.js'; import {createInstance, setOverridesByGlobalCache} from './i18n.js';
import {html, css} from 'lit'; import {html, css} from 'lit';
import {unsafeHTML} from 'lit/directives/unsafe-html.js'; import {unsafeHTML} from 'lit/directives/unsafe-html.js';
import {ScopedElementsMixin} from '@open-wc/scoped-elements'; import {ScopedElementsMixin} from '@open-wc/scoped-elements';
...@@ -56,6 +56,7 @@ export class LoginButton extends ScopedElementsMixin(AdapterLitElement) { ...@@ -56,6 +56,7 @@ export class LoginButton extends ScopedElementsMixin(AdapterLitElement) {
super(); super();
this._i18n = createInstance(); this._i18n = createInstance();
this.lang = this._i18n.language; this.lang = this._i18n.language;
this.langDir = '';
this.auth = {}; this.auth = {};
} }
...@@ -68,12 +69,17 @@ export class LoginButton extends ScopedElementsMixin(AdapterLitElement) { ...@@ -68,12 +69,17 @@ export class LoginButton extends ScopedElementsMixin(AdapterLitElement) {
static get properties() { static get properties() {
return { return {
lang: {type: String}, lang: {type: String},
langDir: {type: String},
auth: {type: Object}, auth: {type: Object},
}; };
} }
connectedCallback() { connectedCallback() {
super.connectedCallback(); super.connectedCallback();
if (this.langDir != '') {
setOverridesByGlobalCache(this._i18n, this);
}
} }
disconnectedCallback() { disconnectedCallback() {
......
...@@ -59,7 +59,7 @@ export class DbpCommonDemo extends ScopedElementsMixin(LitElement) { ...@@ -59,7 +59,7 @@ export class DbpCommonDemo extends ScopedElementsMixin(LitElement) {
super.connectedCallback(); super.connectedCallback();
this._i18n.changeLanguage(this.lang); this._i18n.changeLanguage(this.lang);
// necessary because activity does not extend adapter // set translation overrides if requested
if (this.langDir) { if (this.langDir) {
setOverridesByGlobalCache(this._i18n, this); setOverridesByGlobalCache(this._i18n, this);
} }
......
...@@ -23,6 +23,7 @@ export class Translation extends DBPLitElement { ...@@ -23,6 +23,7 @@ export class Translation extends DBPLitElement {
...super.properties, ...super.properties,
key: {type: String}, key: {type: String},
lang: {type: String}, lang: {type: String},
langDir: {type: String},
interpolation: {type: Object, attribute: 'var'}, interpolation: {type: Object, attribute: 'var'},
unsafe: {type: Boolean, attribute: 'unsafe'}, unsafe: {type: Boolean, attribute: 'unsafe'},
}; };
......
...@@ -54,6 +54,7 @@ export class DataTableView extends AdapterLitElement { ...@@ -54,6 +54,7 @@ export class DataTableView extends AdapterLitElement {
return { return {
...super.properties, ...super.properties,
lang: {type: String}, lang: {type: String},
langDir: {type: String},
table: {type: Object, attribute: false}, table: {type: Object, attribute: false},
paging: {type: Boolean}, paging: {type: Boolean},
searching: {type: Boolean}, searching: {type: Boolean},
......
...@@ -28,6 +28,7 @@ export class DataTableViewDemo extends ScopedElementsMixin(DBPLitElement) { ...@@ -28,6 +28,7 @@ export class DataTableViewDemo extends ScopedElementsMixin(DBPLitElement) {
return { return {
...super.properties, ...super.properties,
lang: {type: String}, lang: {type: String},
langDir: {type: String},
entryPointUrl: {type: String, attribute: 'entry-point-url'}, entryPointUrl: {type: String, attribute: 'entry-point-url'},
noAuth: {type: Boolean, attribute: 'no-auth'}, noAuth: {type: Boolean, attribute: 'no-auth'},
}; };
......
...@@ -66,6 +66,7 @@ export class Clipboard extends ScopedElementsMixin(AdapterLitElement) { ...@@ -66,6 +66,7 @@ export class Clipboard extends ScopedElementsMixin(AdapterLitElement) {
return { return {
...super.properties, ...super.properties,
lang: {type: String}, lang: {type: String},
langDir: {type: String},
allowedMimeTypes: {type: String, attribute: 'allowed-mime-types'}, allowedMimeTypes: {type: String, attribute: 'allowed-mime-types'},
clipboardSelectBtnDisabled: {type: Boolean}, clipboardSelectBtnDisabled: {type: Boolean},
clipboardFiles: {type: Object, attribute: 'clipboard-files'}, clipboardFiles: {type: Object, attribute: 'clipboard-files'},
......
import {createInstance} from './i18n'; import {createInstance, setOverridesByGlobalCache} from './i18n';
import {html, LitElement} from 'lit'; import {html, LitElement} from 'lit';
import {ScopedElementsMixin} from '@open-wc/scoped-elements'; import {ScopedElementsMixin} from '@open-wc/scoped-elements';
import {FileSource} from './file-source'; import {FileSource} from './file-source';
...@@ -10,6 +10,7 @@ export class FileSourceDemo extends ScopedElementsMixin(LitElement) { ...@@ -10,6 +10,7 @@ export class FileSourceDemo extends ScopedElementsMixin(LitElement) {
super(); super();
this._i18n = createInstance(); this._i18n = createInstance();
this.lang = this._i18n.language; this.lang = this._i18n.language;
this.langDir = '';
this.url = ''; this.url = '';
this.selectedFiles = []; this.selectedFiles = [];
this.selectedFilesCount = 0; this.selectedFilesCount = 0;
...@@ -25,6 +26,7 @@ export class FileSourceDemo extends ScopedElementsMixin(LitElement) { ...@@ -25,6 +26,7 @@ export class FileSourceDemo extends ScopedElementsMixin(LitElement) {
static get properties() { static get properties() {
return { return {
lang: {type: String}, lang: {type: String},
langDir: {type: String},
url: {type: String}, url: {type: String},
selectedFiles: {type: Array, attribute: false}, selectedFiles: {type: Array, attribute: false},
selectedFilesCount: {type: Number, attribute: false}, selectedFilesCount: {type: Number, attribute: false},
...@@ -43,6 +45,10 @@ export class FileSourceDemo extends ScopedElementsMixin(LitElement) { ...@@ -43,6 +45,10 @@ export class FileSourceDemo extends ScopedElementsMixin(LitElement) {
); );
}); });
}); });
if (this.langDir != '') {
setOverridesByGlobalCache(this._i18n, this);
}
} }
update(changedProperties) { update(changedProperties) {
......
...@@ -59,6 +59,7 @@ export class FileSink extends ScopedElementsMixin(DbpFileHandlingLitElement) { ...@@ -59,6 +59,7 @@ export class FileSink extends ScopedElementsMixin(DbpFileHandlingLitElement) {
...super.properties, ...super.properties,
context: {type: String, attribute: 'context'}, context: {type: String, attribute: 'context'},
lang: {type: String}, lang: {type: String},
langDir: {type: String},
filename: {type: String}, filename: {type: String},
files: {type: Array, attribute: false}, files: {type: Array, attribute: false},
enabledTargets: {type: String, attribute: 'enabled-targets'}, enabledTargets: {type: String, attribute: 'enabled-targets'},
......
...@@ -80,6 +80,7 @@ export class FileSource extends ScopedElementsMixin(DbpFileHandlingLitElement) { ...@@ -80,6 +80,7 @@ export class FileSource extends ScopedElementsMixin(DbpFileHandlingLitElement) {
...super.properties, ...super.properties,
context: {type: String, attribute: 'context'}, context: {type: String, attribute: 'context'},
lang: {type: String}, lang: {type: String},
langDir: {type: String},
allowedMimeTypes: {type: String, attribute: 'allowed-mime-types'}, allowedMimeTypes: {type: String, attribute: 'allowed-mime-types'},
enabledTargets: {type: String, attribute: 'enabled-targets'}, enabledTargets: {type: String, attribute: 'enabled-targets'},
nextcloudAuthUrl: {type: String, attribute: 'nextcloud-auth-url'}, nextcloudAuthUrl: {type: String, attribute: 'nextcloud-auth-url'},
......
...@@ -94,6 +94,7 @@ export class NextcloudFilePicker extends ScopedElementsMixin(DBPLitElement) { ...@@ -94,6 +94,7 @@ export class NextcloudFilePicker extends ScopedElementsMixin(DBPLitElement) {
return { return {
...super.properties, ...super.properties,
lang: {type: String}, lang: {type: String},
langDir: {type: String},
auth: {type: Object}, auth: {type: Object},
authUrl: {type: String, attribute: 'auth-url'}, authUrl: {type: String, attribute: 'auth-url'},
webDavUrl: {type: String, attribute: 'web-dav-url'}, webDavUrl: {type: String, attribute: 'web-dav-url'},
......
...@@ -29,6 +29,7 @@ export class KnowledgeBaseWebPageElementViewDemo extends ScopedElementsMixin(DBP ...@@ -29,6 +29,7 @@ export class KnowledgeBaseWebPageElementViewDemo extends ScopedElementsMixin(DBP
return { return {
...super.properties, ...super.properties,
lang: {type: String}, lang: {type: String},
langDir: {type: String},
entryPointUrl: {type: String, attribute: 'entry-point-url'}, entryPointUrl: {type: String, attribute: 'entry-point-url'},
noAuth: {type: Boolean, attribute: 'no-auth'}, noAuth: {type: Boolean, attribute: 'no-auth'},
}; };
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment