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
  • renovate/lock-file-maintenance
  • main
  • demo
  • person-select-custom
  • dbp-translation-component
  • icon-set-mapping
  • port-i18next-parser
  • remove-sentry
  • favorites-and-recent-files
  • revert-6c632dc6
  • lit2
  • advertisement
  • wc-part
  • automagic
  • publish
  • wip-cleanup
  • demo-file-handling
17 results

Target

Select target project
  • Reiter, Christoph / Toolkit
1 result
Select Git revision
  • renovate/lock-file-maintenance
  • main
  • demo
  • person-select-custom
  • dbp-translation-component
  • icon-set-mapping
  • port-i18next-parser
  • remove-sentry
  • favorites-and-recent-files
  • revert-6c632dc6
  • lit2
  • advertisement
  • wc-part
  • automagic
  • publish
  • wip-cleanup
  • demo-file-handling
17 results
Show changes
91 files
+ 947
781
Compare changes
  • Side-by-side
  • Inline

Files

+1 −0
Original line number Diff line number Diff line
@@ -11,6 +11,7 @@
  "scripts": {
    "test": "lerna run test",
    "build": "lerna run build",
    "i18next": "lerna run i18next",
    "version-patch": "lerna version patch",
    "version-minor": "lerna version minor",
    "version": "lerna version",
Original line number Diff line number Diff line
module.exports = {
    input: [
        'src/*.js',
    ],
    output: './',
    options: {
        debug: false,
        removeUnusedKeys: true,
        func: {list: ['i18n.t', '_i18n.t']},
        lngs: ['en','de'],
        resource: {
            loadPath: 'src/i18n/{{lng}}/{{ns}}.json',
            savePath: 'src/i18n/{{lng}}/{{ns}}.json'
        },
    },
}
Original line number Diff line number Diff line
@@ -31,7 +31,8 @@
    "rollup-plugin-copy": "^3.1.0",
    "rollup-plugin-delete": "^2.0.0",
    "rollup-plugin-emit-ejs": "^3.1.0",
    "rollup-plugin-serve": "^1.0.1"
    "rollup-plugin-serve": "^1.0.1",
    "i18next-scanner": "^3.0.0"
  },
  "dependencies": {
    "@dbp-toolkit/auth": "^0.2.2",
@@ -47,6 +48,7 @@
    "universal-router": "^9.0.1"
  },
  "scripts": {
    "i18next": "i18next-scanner",
    "build": "npm run build-local",
    "build-local": "rollup -c",
    "build-test": "rollup -c --environment BUILD:test",
Original line number Diff line number Diff line
import {createI18nInstance} from './i18n.js';
import {createInstance} from './i18n.js';
import {html, css} from 'lit-element';
import {ScopedElementsMixin} from '@open-wc/scoped-elements';
import {LanguageSelect} from '@dbp-toolkit/language-select';
@@ -15,18 +15,16 @@ import {appWelcomeMeta} from './dbp-app-shell-welcome.js';
import {MatomoElement} from "@dbp-toolkit/matomo/src/matomo";
import DBPLitElement from "@dbp-toolkit/common/dbp-lit-element";


const i18n = createI18nInstance();

/**
 * In case the application gets updated future dynamic imports might fail.
 * This sends a notification suggesting the user to reload the page.
 *
 * uage: importNotify(import('<path>'));
 * usage: importNotify(import('<path>'));
 *
 * @param i18n
 * @param {Promise} promise
 */
const importNotify = async (promise) => {
const importNotify = async (i18n, promise) => {
    try {
        return await promise;
    } catch (error) {
@@ -43,7 +41,6 @@ const importNotify = async (promise) => {
export class AppShell extends ScopedElementsMixin(DBPLitElement) {
    constructor() {
        super();
        this.lang = i18n.language;
        this.activeView = '';
        this.entryPointUrl = '';
        this.subtitle = '';
@@ -62,6 +59,8 @@ export class AppShell extends ScopedElementsMixin(DBPLitElement) {
        this.buildTime = '';
        this._loginStatus = 'unknown';
        this._roles = [];
        this._i18n = createInstance();
        this.lang = this._i18n.language;

        this.matomoUrl = '';
        this.matomoSiteId = -1;
@@ -271,7 +270,7 @@ export class AppShell extends ScopedElementsMixin(DBPLitElement) {
     */
    updateLangIfChanged(lang) {
        // in case the language is unknown, fall back to the default
        if (!i18n.languages.includes(lang)) {
        if (!this._i18n.languages.includes(lang)) {
            lang = this.lang;
        }
        if (this.lang !== lang) {
@@ -287,10 +286,9 @@ export class AppShell extends ScopedElementsMixin(DBPLitElement) {
        changedProperties.forEach((oldValue, propName) => {
            switch (propName) {
                case 'lang':
                    i18n.changeLanguage(this.lang);
                    this._i18n.changeLanguage(this.lang);
                    // For screen readers
                    document.documentElement.setAttribute("lang", this.lang);
                    i18n.changeLanguage(this.lang);

                    this.router.update();
                    this.subtitle = this.activeMetaDataText("short_name");
@@ -420,7 +418,7 @@ export class AppShell extends ScopedElementsMixin(DBPLitElement) {
            return;
        }

        importNotify(import(metadata.module_src)).then(() => {
        importNotify(this._i18n, import(metadata.module_src)).then(() => {
            updateFunc();
        }).catch((e) => {
            console.error(`Error loading ${ metadata.element }`);
@@ -836,6 +834,8 @@ export class AppShell extends ScopedElementsMixin(DBPLitElement) {
    }

    render() {
        let i18n = this._i18n;

        const getSelectClasses = (name => {
            return classMap({selected: this.activeView === name});
        });
Original line number Diff line number Diff line
import {createI18nInstance} from './i18n.js';
import {createInstance} from './i18n.js';
import {html, css} from 'lit-element';
import {unsafeHTML} from 'lit-html/directives/unsafe-html.js';
import {ScopedElementsMixin} from '@open-wc/scoped-elements';
@@ -7,14 +7,12 @@ import {Icon} from '@dbp-toolkit/common';
import {AdapterLitElement} from "@dbp-toolkit/provider/src/adapter-lit-element";
import {LoginStatus} from "@dbp-toolkit/auth/src/util";


const i18n = createI18nInstance();

export class AuthMenuButton extends ScopedElementsMixin(AdapterLitElement) {

    constructor() {
        super();
        this.lang = 'de';
        this._i18n = createInstance();
        this.lang = this._i18n.language;
        this.showImage = false;
        this.auth = {};

@@ -82,7 +80,7 @@ export class AuthMenuButton extends ScopedElementsMixin(AdapterLitElement) {
    update(changedProperties) {
        changedProperties.forEach((oldValue, propName) => {
            if (propName === "lang") {
                i18n.changeLanguage(this.lang);
                this._i18n.changeLanguage(this.lang);
            }
        });

@@ -246,6 +244,7 @@ export class AuthMenuButton extends ScopedElementsMixin(AdapterLitElement) {
    }

    renderLoggedIn() {
        const i18n = this._i18n;
        const person = this.auth.person;
        const imageURL = (this.showImage && person && person.image) ? person.image : null;

@@ -270,6 +269,7 @@ export class AuthMenuButton extends ScopedElementsMixin(AdapterLitElement) {
    }

    renderLoggedOut() {
        const i18n = this._i18n;
        let loginSVG = `
        <svg
           viewBox="0 0 100 100"
Original line number Diff line number Diff line
import {html , LitElement} from 'lit-element';
import {createI18nInstance} from './i18n.js';
import {createInstance} from './i18n.js';
import * as commonUtils from '@dbp-toolkit/common/utils';

const i18n = createI18nInstance();

class ActivityExample extends LitElement {

    constructor() {
        super();
        this.lang = i18n.language;
        this._i18n = createInstance();
        this.lang = this._i18n.language;
    }

    static get properties() {
@@ -21,7 +20,7 @@ class ActivityExample extends LitElement {
        changedProperties.forEach((oldValue, propName) => {
            switch (propName) {
                case "lang":
                    i18n.changeLanguage(this.lang);
                    this._i18n.changeLanguage(this.lang);
                    break;
            }
        });
@@ -30,6 +29,7 @@ class ActivityExample extends LitElement {
    }

    render() {
        const i18n = this._i18n;
        return html`
            <h3>${i18n.t('activity-example.hello-world')}</h3>
            <ul>${(Array.from(Array(100).keys())).map(i => html`<li>${i18n.t('activity-example.hello-world') + ' ' + i}</li>`)}</ul>
Original line number Diff line number Diff line
import {createI18nInstance} from './i18n.js';
import {createInstance} from './i18n.js';
import {css, html, LitElement} from 'lit-element';
import {ScopedElementsMixin} from '@open-wc/scoped-elements';
import * as commonUtils from '@dbp-toolkit/common/utils';
import * as commonStyles from '@dbp-toolkit/common/styles';

const i18n = createI18nInstance();

class AppShellWelcome extends ScopedElementsMixin(LitElement) {

    constructor() {
        super();
        this.lang = i18n.language;
        this._i18n = createInstance();
        this.lang = this._i18n.language;

        this._onVisibilityChanged = this._onVisibilityChanged.bind(this);
    }
@@ -28,7 +27,7 @@ class AppShellWelcome extends ScopedElementsMixin(LitElement) {
    update(changedProperties) {
        changedProperties.forEach((oldValue, propName) => {
            if (propName === "lang") {
                i18n.changeLanguage(this.lang);
                this._i18n.changeLanguage(this.lang);
            }
        });

@@ -75,6 +74,7 @@ class AppShellWelcome extends ScopedElementsMixin(LitElement) {
    }

    render() {
        const i18n = this._i18n;
        const app = AppShellWelcome._app;
        let itemTemplates = [];

Original line number Diff line number Diff line
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 en from './i18n/en/translation.json';

const i18n = createInstance({en: en, de: de}, 'de', 'en');

export function createI18nInstance () {
    return i18n.cloneInstance();
}

/**
 * Dummy function to mark strings as i18next keys for i18next-scanner
 *
 * @param {string} key
 * @returns {string} The key param as is
 */
export function i18nKey(key) {
    return key;
export function createInstance() {
    return _createInstance({en: en, de: de}, 'de', 'en');
}
Original line number Diff line number Diff line
import {html, css} from 'lit-element';
import * as commonStyles from '@dbp-toolkit/common/styles';
import {createI18nInstance} from './i18n.js';
import {createInstance} from './i18n.js';
import {AdapterLitElement} from "@dbp-toolkit/provider/src/adapter-lit-element";

const i18n = createI18nInstance();

export class TUGrazLogo extends AdapterLitElement {

    constructor() {
        super();

        this.lang = i18n.language;
        this._i18n = createInstance();
        this.lang = this._i18n.language;
    }

    static get properties() {
@@ -23,7 +22,7 @@ export class TUGrazLogo extends AdapterLitElement {
    update(changedProperties) {
        changedProperties.forEach((oldValue, propName) => {
            if (propName === "lang") {
                i18n.changeLanguage(this.lang);
                this._i18n.changeLanguage(this.lang);
            }
        });
        super.update(changedProperties);
@@ -67,6 +66,7 @@ export class TUGrazLogo extends AdapterLitElement {
    } 

    render() {
        const i18n = this._i18n;
        return html`
            <a href="https://www.tugraz.at" title="TU Graz Home" target="_blank" rel="noopener">
                <div id="claim">
Original line number Diff line number Diff line
@@ -8,7 +8,6 @@ module.exports = {
        removeUnusedKeys: true,
        func: {list: ['i18n.t', '_i18n.t']},
        lngs: ['en','de'],
        defaultNs: 'dbp-auth',
        resource: {
            loadPath: 'src/i18n/{{lng}}/{{ns}}.json',
            savePath: 'src/i18n/{{lng}}/{{ns}}.json'
Original line number Diff line number Diff line
@@ -20,7 +20,6 @@ import {AdapterLitElement} from "@dbp-toolkit/provider/src/adapter-lit-element";
export class AuthKeycloak extends AdapterLitElement {
    constructor() {
        super();
        this.lang = 'de';
        this.forceLogin = false;
        this.loadPerson = false;
        this.token = "";
@@ -33,6 +32,7 @@ export class AuthKeycloak extends AdapterLitElement {
        this._loginStatus = LoginStatus.UNKNOWN;
        this.requestedLoginStatus = LoginStatus.UNKNOWN;
        this._i18n = createInstance();
        this.lang = this._i18n.language;

        // Keycloak config
        this.keycloakUrl = null;
Original line number Diff line number Diff line
@@ -10,11 +10,11 @@ import DBPLitElement from "@dbp-toolkit/common/dbp-lit-element";
export class DbpAuthDemo extends ScopedElementsMixin(DBPLitElement) {
    constructor() {
        super();
        this.lang = 'de';
        this.entryPointUrl = '';
        this.auth = {};
        this.noAuth = false;
        this._i18n = createInstance();
        this.lang = this._i18n.language;
    }

    static get scopedElements() {
Original line number Diff line number Diff line
import {createInstance as _createInstance, setOverrides} from '@dbp-toolkit/common/i18next.js';

import de from './i18n/de/dbp-auth.json';
import en from './i18n/en/dbp-auth.json';
import de from './i18n/de/translation.json';
import en from './i18n/en/translation.json';

export function createInstance() {
    return _createInstance({en: en, de: de}, 'de', 'en', 'dbp-auth');
    return _createInstance({en: en, de: de}, 'de', 'en');
}

export {setOverrides};
 No newline at end of file
Original line number Diff line number Diff line
@@ -55,8 +55,8 @@ export class LoginButton extends ScopedElementsMixin(AdapterLitElement) {

    constructor() {
        super();
        this.lang = 'de';
        this._i18n = createInstance();
        this.lang = this._i18n.language;
        this.auth = {};
    }

Original line number Diff line number Diff line
@@ -25,7 +25,6 @@ export class CheckInPlaceSelect extends ScopedElementsMixin(AdapterLitElement) {
    constructor() {
        super();
        Object.assign(CheckInPlaceSelect.prototype, errorUtils.errorMixin);
        this.lang = 'de';
        this.entryPointUrl = '';
        this.jsonld = null;
        this.$select = null;
@@ -42,6 +41,7 @@ export class CheckInPlaceSelect extends ScopedElementsMixin(AdapterLitElement) {
        this.showCapacity = false;
        this.auth = {};
        this._i18n = createInstance();
        this.lang = this._i18n.language;

        this._onDocumentClicked = this._onDocumentClicked.bind(this);
    }
Original line number Diff line number Diff line
@@ -5,11 +5,14 @@ import {AuthKeycloak, LoginButton} from '@dbp-toolkit/auth';
import * as commonUtils from '@dbp-toolkit/common/utils';
import * as commonStyles from '@dbp-toolkit/common/styles';
import DBPLitElement from "@dbp-toolkit/common/dbp-lit-element";
import {createInstance} from './i18n.js';


export class CheckInPlaceSelectDemo extends ScopedElementsMixin(DBPLitElement) {
    constructor() {
        super();
        this.lang = 'de';
        this._i18n = createInstance();
        this.lang = this._i18n.language;
        this.entryPointUrl = '';
        this.noAuth = false;
    }
Original line number Diff line number Diff line
import {i18n} from './i18n.js';
import {createInstance} from './src/i18n.js';
import {css, html, LitElement} from 'lit-element';
import {ScopedElementsMixin} from '@open-wc/scoped-elements';
import * as commonUtils from './utils.js';
@@ -8,7 +8,8 @@ import {getIconCSS, Icon, MiniSpinner, Button, LoadingButton, Spinner, InlineNot
export class DbpCommonDemo extends ScopedElementsMixin(LitElement) {
    constructor() {
        super();
        this.lang = 'de';
        this._i18n = createInstance();
        this.lang = this._i18n.language;
        this.noAuth = false;
    }

@@ -39,7 +40,7 @@ export class DbpCommonDemo extends ScopedElementsMixin(LitElement) {

    connectedCallback() {
        super.connectedCallback();
        i18n.changeLanguage(this.lang);
        this._i18n.changeLanguage(this.lang);

        this.updateComplete.then(()=>{
        });
Original line number Diff line number Diff line
import {send as notify} from './notification';
import {i18n} from "./i18n";
import {createInstance} from "./src/i18n";

/**
 * Escapes html
@@ -39,14 +39,17 @@ export const errorMixin = {
     * @param textStatus
     * @param errorThrown
     * @param icon
     * @param lang
     */
    handleXhrError(jqXHR, textStatus, errorThrown, icon = "sad") {
    handleXhrError(jqXHR, textStatus, errorThrown, icon = "sad", lang = "de") {
        // return if user aborted the request
        if (textStatus === "abort") {
            return;
        }

        let body;
        const i18n = createInstance();
        i18n.changeLanguage(lang);

        if (jqXHR.responseJSON !== undefined && jqXHR.responseJSON["hydra:description"] !== undefined) {
            // response is a JSON-LD
@@ -86,14 +89,17 @@ export const errorMixin = {
     * @param error
     * @param summary
     * @param icon
     * @param lang
     */
    handleFetchError: async function (error, summary = "", icon = "sad") {
    handleFetchError: async function (error, summary = "", icon = "sad", lang = "de") {
        // return if user aborted the request
        if (error.name === "AbortError") {
            return;
        }

        let body;
        const i18n = createInstance();
        i18n.changeLanguage(lang);

        try {
            await error.json().then((json) => {
Original line number Diff line number Diff line
module.exports = {
    input: [
        'src/*.js',
        './*.js',
    ],
    output: './',
    options: {
        debug: false,
        removeUnusedKeys: true,
        func: {list: ['i18n.t', '_i18n.t']},
        lngs: ['en','de'],
        resource: {
            loadPath: 'src/i18n/{{lng}}/{{ns}}.json',
            savePath: 'src/i18n/{{lng}}/{{ns}}.json'
        },
    },
}
Original line number Diff line number Diff line
@@ -100,20 +100,24 @@ export function createInstance(languages, lng, fallback, namespace) {
 * object is equal to removing all overrides.
 *
 * @param {i18next.i18n} i18n - The i18next instance
 * @param {object} overrides - The override data in the following format: "{language: {namespace: {key: value}}}"
 * @param {HTMLElement} element - The element at which the overrides are targeted
 * @param {object} overrides - The override data in the following format: "{language: {tag-name: {key: value}}}"
 */
export function setOverrides(i18n, overrides) {
export function setOverrides(i18n, element, overrides) {
    // We add a special namespace which gets used with priority and falls back
    // to the original one. This way we an change the overrides at runtime
    // and can even remove them.

    // The scoped mixin saves the real tag name under data-tag-name
    let tagName = ((element.dataset && element.dataset.tagName) || element.tagName).toLowerCase();
    let namespace = i18n.options.fallbackNS;
    let overrideNamespace = getOverrideNamespace(namespace);
    let hasOverrides = false;
    for(let lng of i18n.languages) {
        i18n.removeResourceBundle(lng, overrideNamespace);
        if (overrides[lng] === undefined || overrides[lng][namespace] === undefined)
        if (overrides[lng] === undefined || overrides[lng][tagName] === undefined)
            continue;
        let resources = overrides[lng][namespace];
        let resources = overrides[lng][tagName];
        hasOverrides = true;
        i18n.addResourceBundle(lng, overrideNamespace, resources);
    }
Original line number Diff line number Diff line
import {send as notify} from './notification';
import * as utils from "./utils";
import {i18n} from "./i18n";
import {createInstance} from "./src/i18n";

export default class JSONLD {
    constructor(baseApiUrl, entities) {
@@ -43,9 +43,7 @@ export default class JSONLD {
    }

    static _initialize(apiUrl, successFnc, failureFnc, lang = 'de') {
        if (lang !== 'de') {
            i18n.changeLanguage(lang);
        }
        JSONLD._i18n.changeLanguage(lang);

        // if init api call was already successfully finished execute the success function
        if (JSONLD.instances[apiUrl] !== undefined) {
@@ -72,6 +70,7 @@ export default class JSONLD {

    static _doInitialization(apiUrl) {
        const xhr = new XMLHttpRequest();
        const i18n = JSONLD._i18n;
        xhr.open("GET", apiUrl, true);

        xhr.onreadystatechange = function () {
@@ -170,6 +169,7 @@ export default class JSONLD {
     * @param message
     */
    static _executeFailureFunctions(apiUrl, message = "") {
        const i18n = JSONLD._i18n;
        if (JSONLD.failureFunctions[apiUrl] !== undefined) {
            for (const fnc of JSONLD.failureFunctions[apiUrl]) {
                if (typeof fnc == 'function') {
@@ -297,6 +297,7 @@ export default class JSONLD {
    }
}

JSONLD._i18n = createInstance();
JSONLD.instances = {};
JSONLD.successFunctions = {};
JSONLD.failureFunctions = {};
Original line number Diff line number Diff line
@@ -25,9 +25,11 @@
    "rollup": "^2.33.3",
    "rollup-plugin-copy": "^3.1.0",
    "rollup-plugin-delete": "^2.0.0",
    "rollup-plugin-serve": "^1.0.1"
    "rollup-plugin-serve": "^1.0.1",
    "i18next-scanner": "^3.0.0"
  },
  "scripts": {
    "i18next": "i18next-scanner",
    "clean": "rm dist/*",
    "build": "rollup -c",
    "build-test": "rollup -c --environment BUILD:test",
Original line number Diff line number Diff line
import {createInstance} from './i18next.js';
import {createInstance as _createInstance} from '../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');
}
 No newline at end of file
Original line number Diff line number Diff line
@@ -49,22 +49,23 @@ suite('i18next', () => {
    });

    test('overrides', () => {
        let namespace = 'ns';
        let namespace = 'some-ns';
        let element = document.createElement(namespace);
        var inst = i18next.createInstance({en:  {foo: 'bar'}}, 'en', 'en', namespace);
        assert.equal(inst.t('foo'), 'bar');
        assert.equal(inst.t('quux'), 'quux');
        i18next.setOverrides(inst, {en: {[namespace]: {quux: 'bla'}}});
        i18next.setOverrides(inst, element, {en: {[namespace]: {quux: 'bla'}}});
        assert.equal(inst.t('quux'), 'bla');
        assert.equal(inst.t('foo'), 'bar');
        i18next.setOverrides(inst, {en: {[namespace]: {}}});
        i18next.setOverrides(inst, element, {en: {[namespace]: {}}});
        assert.equal(inst.t('quux'), 'quux');
        assert.equal(inst.t('foo'), 'bar');
        i18next.setOverrides(inst, {en: {[namespace]: {foo: 'hmm'}}});
        i18next.setOverrides(inst, element, {en: {[namespace]: {foo: 'hmm'}}});
        assert.equal(inst.t('foo'), 'hmm');
        i18next.setOverrides(inst, {en: {[namespace]: {quux: 'bla'}}});
        i18next.setOverrides(inst, element, {en: {[namespace]: {quux: 'bla'}}});
        assert.equal(inst.t('foo'), 'bar');
        assert.equal(inst.t('quux'), 'bla');
        i18next.setOverrides(inst, {});
        i18next.setOverrides(inst, element, {});
        assert.equal(inst.t('foo'), 'bar');
        assert.equal(inst.t('quux'), 'quux');
    });
Original line number Diff line number Diff line
module.exports = {
    input: [
        'src/*.js',
    ],
    output: './',
    options: {
        debug: false,
        removeUnusedKeys: true,
        func: {list: ['i18n.t', '_i18n.t']},
        lngs: ['en','de'],
        resource: {
            loadPath: 'src/i18n/{{lng}}/{{ns}}.json',
            savePath: 'src/i18n/{{lng}}/{{ns}}.json'
        },
    },
}
Original line number Diff line number Diff line
@@ -7,7 +7,7 @@ import bttn from 'datatables.net-buttons-dt';
import bttn2 from 'datatables.net-buttons';
import bttnHtml5 from 'datatables.net-buttons/js/buttons.html5.js';
import bttnPrint from 'datatables.net-buttons/js/buttons.print.js';
import {i18n} from './i18n';
import {createInstance} from './i18n';
import {css, html, unsafeCSS} from 'lit-element';
import de from '../assets/datatables/i18n/German';
import en from '../assets/datatables/i18n/English';
@@ -28,7 +28,8 @@ bttnPrint(window, $);
export class DataTableView extends AdapterLitElement {
    constructor() {
        super();
        this.lang = 'de';
        this._i18n = createInstance();
        this.lang = this._i18n.language;
        // datatable properties
        this.table = null;
        this.responsive = null;
@@ -100,6 +101,7 @@ export class DataTableView extends AdapterLitElement {

    set_datatable(data, languageChange = false) {
        const lang_obj = this.lang === 'de' ? de : en;
        const i18n = this._i18n;

        if (typeof this.columns === 'undefined' || !this.columns.length) {
            if (data.length)
@@ -229,7 +231,7 @@ export class DataTableView extends AdapterLitElement {

        changedProperties.forEach((oldValue, propName) => {
            if (propName === "lang") {
                i18n.changeLanguage(this.lang).catch(e => { console.log(e);});
                this._i18n.changeLanguage(this.lang).catch(e => { console.log(e);});
                languageChange = true;
            }
        });
Original line number Diff line number Diff line
import {AuthKeycloak, LoginButton} from '@dbp-toolkit/auth';
import {DataTableView} from './data-table-view.js';
import {i18n} from './i18n';
import {createInstance} from './i18n';
import {css, html} from 'lit-element';
import {ScopedElementsMixin} from '@open-wc/scoped-elements';
import * as commonUtils from '@dbp-toolkit/common/utils';
@@ -10,7 +10,8 @@ import DBPLitElement from "@dbp-toolkit/common/dbp-lit-element";
export class DataTableViewDemo extends ScopedElementsMixin(DBPLitElement) {
    constructor() {
        super();
        this.lang = 'de';
        this._i18n = createInstance();
        this.lang = this._i18n.language;
        this.entryPointUrl = '';
        this.noAuth = false;
    }
@@ -100,7 +101,7 @@ export class DataTableViewDemo extends ScopedElementsMixin(DBPLitElement) {
    update(changedProperties) {
        changedProperties.forEach((oldValue, propName) => {
            if (propName === "lang") {
                i18n.changeLanguage(this.lang);
                this._i18n.changeLanguage(this.lang);
            }
        });

Original line number Diff line number Diff line
import i18next from 'i18next';
import {createInstance as _createInstance} from '@dbp-toolkit/common/i18next.js';

import de from './i18n/de/translation.json';
import en from './i18n/en/translation.json';

const i18n = i18next.createInstance();

i18n.init({
    lng: 'de',
    fallbackLng: ['de'],
    debug: false,
    initImmediate: false, // Don't init async
    resources: {
        en: {translation: en},
        de: {translation: de}
    },
});

console.assert(i18n.isInitialized);

function dateTimeFormat(date, options) {
    return new Intl.DateTimeFormat(i18n.languages, options).format(date);
export function createInstance() {
    return _createInstance({en: en, de: de}, 'de', 'en');
}
 No newline at end of file

function numberFormat(number, options) {
    return new Intl.NumberFormat(i18n.languages, options).format(number);
}

export {i18n, dateTimeFormat, numberFormat};
Original line number Diff line number Diff line
@@ -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',
Original line number Diff line number Diff line
import {i18n} from './i18n';
import {createInstance} from './i18n';
import {css, html} from 'lit-element';
import {ScopedElementsMixin} from '@open-wc/scoped-elements';
import * as commonUtils from '@dbp-toolkit/common/utils';
@@ -20,7 +20,8 @@ export class Clipboard extends ScopedElementsMixin(AdapterLitElement) {

    constructor() {
        super();
        this.lang = 'de';
        this._i18n = createInstance();
        this.lang = this._i18n.language;
        this.allowedMimeTypes = '*/*';
        this.clipboardFiles = {files: ''};
        this.clipboardSelectBtnDisabled = true;
@@ -29,6 +30,8 @@ export class Clipboard extends ScopedElementsMixin(AdapterLitElement) {
        this.filesToSave = [];
        this.numberOfSelectedFiles = 0;
        this.enabledTargets = 'local';
        this.countUploadFiles = 0;
        this.buttonsDisabled = false;

        this.nextcloudWebAppPasswordURL = "";
        this.nextcloudWebDavURL = "";
@@ -56,11 +59,12 @@ export class Clipboard extends ScopedElementsMixin(AdapterLitElement) {
            ...super.properties,
            lang: { type: String },
            allowedMimeTypes: { type: String, attribute: 'allowed-mime-types' },
            clipboardSelectBtnDisabled: { type: Boolean, attribute: true },
            clipboardSelectBtnDisabled: { type: Boolean },
            clipboardFiles: {type: Object, attribute: 'clipboard-files' },
            filesToSave: {type: Array, attribute: 'files-to-save' },
            numberOfSelectedFiles: {type: Number, attribute: false },
            enabledTargets: {type: String, attribute: 'enabled-targets'},
            buttonsDisabled: {type: Boolean },

            nextcloudWebAppPasswordURL: { type: String, attribute: 'nextcloud-auth-url' },
            nextcloudWebDavURL: { type: String, attribute: 'nextcloud-web-dav-url' },
@@ -78,18 +82,22 @@ export class Clipboard extends ScopedElementsMixin(AdapterLitElement) {
        return this.shadowRoot === null ? this.querySelector(selector) : this.shadowRoot.querySelector(selector);
    }

    _a(selector) {
        return this.shadowRoot === null ? this.querySelectorAll(selector) : this.shadowRoot.querySelectorAll(selector);
    }

    update(changedProperties) {
        changedProperties.forEach((oldValue, propName) => {
            switch (propName) {
                case "lang":
                    i18n.changeLanguage(this.lang);
                    this._i18n.changeLanguage(this.lang);
                    break;
                case "clipboardFiles":
                    this.generateClipboardTable();

                    break;
            }
        });

        super.update(changedProperties);
    }

@@ -102,17 +110,22 @@ export class Clipboard extends ScopedElementsMixin(AdapterLitElement) {
        }
    }

    toggleCollapse(e) {
        const table = this.tabulatorTable;
        setTimeout(function() {
            table.redraw();
        }, 0);
    }


    connectedCallback() {
        const i18n = this._i18n;
        super.connectedCallback();
        const that = this;
        this.updateComplete.then(() => {

            // see: http://tabulator.info/docs/4.7
            this.tabulatorTable = new Tabulator(this._("#clipboard-content-table"), {//if you delete the wrapper around the table you need to set a heigh here
                maxHeight:"100%",
                height:"100%",
                layout: "fitColumns",
                selectable: true,
                selectableRangeMode: "drag",
@@ -324,6 +337,17 @@ export class Clipboard extends ScopedElementsMixin(AdapterLitElement) {
            if (this.tabulatorTable !== null) {
                this.tabulatorTable.clearData();
                this.tabulatorTable.setData(data);

                const that = this;
                setTimeout(function(){
                    if (that._('.tabulator-responsive-collapse-toggle-open')) {
                        that._a('.tabulator-responsive-collapse-toggle-open').forEach(element => element.addEventListener("click", that.toggleCollapse.bind(that)));
                    }

                    if (that._('.tabulator-responsive-collapse-toggle-close')) {
                        that._a('.tabulator-responsive-collapse-toggle-close').forEach(element => element.addEventListener("click", that.toggleCollapse.bind(that)));
                    }
                }, 0);
            }
        }
        if (this._("#select_all")) {
@@ -337,6 +361,7 @@ export class Clipboard extends ScopedElementsMixin(AdapterLitElement) {
     * @param files
     */
    async sendClipboardFiles(files) {
        const i18n = this._i18n;
        for (let i = 0; i < files.length; i ++) {
            await this.sendFileEvent(files[i].file);
        }
@@ -363,6 +388,7 @@ export class Clipboard extends ScopedElementsMixin(AdapterLitElement) {
     * @param event
     */
    onReceiveBeforeUnload(event) {
        const i18n = this._i18n;

        // we don't need to stop if there are no signed files
        if (this.clipboardFiles.files.length === 0) {
@@ -417,6 +443,14 @@ export class Clipboard extends ScopedElementsMixin(AdapterLitElement) {
                {  bubbles: true, composed: true });
            this.dispatchEvent(event);
        }

        this.countUploadFiles += 1;
        if (this.countUploadFiles === event.detail.maxUpload) {
            this.buttonsDisabled = false;
            this.countUploadFiles = 0;
        } else {
            this.buttonsDisabled = true;
        }
    }

    /**
@@ -425,6 +459,8 @@ export class Clipboard extends ScopedElementsMixin(AdapterLitElement) {
     */
    saveFilesToClipboard()
    {
        const i18n = this._i18n;

        //save it
        let data = {};
        let files = [];
@@ -455,6 +491,7 @@ export class Clipboard extends ScopedElementsMixin(AdapterLitElement) {
     * @param event
     */
    finishedSaveFilesToClipboard(event) {
        const i18n = this._i18n;
        send({
            "summary": i18n.t('clipboard.saved-files-title', {count: event.detail.count}),
            "body": i18n.t('clipboard.saved-files-body', {count: event.detail.count}),
@@ -491,6 +528,8 @@ export class Clipboard extends ScopedElementsMixin(AdapterLitElement) {
     *
     */
    clearClipboard() {
        const i18n = this._i18n;

        if (this.tabulatorTable && this.tabulatorTable.getSelectedData().length > 0) {
            let count = this.tabulatorTable.getSelectedData().length;
            this.tabulatorTable.deleteRow(this.tabulatorTable.getSelectedRows());
@@ -526,12 +565,15 @@ export class Clipboard extends ScopedElementsMixin(AdapterLitElement) {
     * @returns {html}
     */
    getAdditionalButtons() {
        const i18n = this._i18n;
        let buttonsAreDisabled = this.clipboardFiles.files.length === 0 ? true : this.clipboardSelectBtnDisabled;
        buttonsAreDisabled = this.buttonsDisabled ? true : buttonsAreDisabled;
        return html`
            <div class="flex-container additional-button-container">
                        <div class="btn-flex-container-mobile">
                            <button @click="${() => { this.openFileSource(); }}"
                                    class="button ${classMap({hidden: this.mode === MODE_FILE_SINK || this.mode === MODE_FILE_SOURCE})}" title="${i18n.t('clipboard.add-files')}">
                                    class="button ${classMap({hidden: this.mode === MODE_FILE_SINK || this.mode === MODE_FILE_SOURCE})}" title="${i18n.t('clipboard.add-files')}"
                                    ?disabled="${this.buttonsDisabled}">
                                <dbp-icon class="nav-icon" name="clipboard"></dbp-icon> ${i18n.t('clipboard.add-files-btn')}
                            </button>
                            <button @click="${() => { this.clearClipboard(); }}"
@@ -590,6 +632,7 @@ export class Clipboard extends ScopedElementsMixin(AdapterLitElement) {
     * @returns {html}
     */
    getClipboardSink() {
        const i18n = this._i18n;
        const tabulatorCss = commonUtils.getAssetURL(pkgName, 'tabulator-tables/css/tabulator.min.css');
        return html`
            <div class="wrapper">
@@ -624,6 +667,7 @@ export class Clipboard extends ScopedElementsMixin(AdapterLitElement) {
     */
    getClipboardSource() {
        const tabulatorCss = commonUtils.getAssetURL(pkgName, 'tabulator-tables/css/tabulator.min.css');
        const i18n = this._i18n;
        return html`
            <div class="wrapper">
                <div class="content">
Original line number Diff line number Diff line
import {ScopedElementsMixin} from '@open-wc/scoped-elements';
import DBPLitElement from "../../common/dbp-lit-element";

export default class DbpFileHandlingLitElement extends ScopedElementsMixin(DBPLitElement) {
    constructor() {
        super();

    }

    static get properties() {
        return {
            ...super.properties,
        };
    }

    /**
     * Handles the scroll of the current element and displays the right and/or the left paddle
     * to match the scrolling position
     *
     * @param e
     */
    handleScroll(e) {
        if (!this._(".right-paddle") || !this._(".left-paddle"))
            return;
        let horizontal = e.currentTarget.scrollLeft;
        let scrollWidth = e.currentTarget.scrollWidth - e.currentTarget.clientWidth; //e.currentTarget.scrollLeftMax isn't support except firefox
        if(horizontal > 0) {
            this._(".left-paddle").classList.remove("hidden");
        }
        if (horizontal < scrollWidth) {
            this._(".right-paddle").classList.remove("hidden");
        }

        if (horizontal >= scrollWidth) {
            this._(".right-paddle").classList.add("hidden");
        }

        if (horizontal <= 0) {
            this._(".left-paddle").classList.add("hidden");
        }
    }

    /**
     * Scrolls smooth to the maximum right of an given element
     *
     * @param element
     */
    handleScrollRight(element) {
        const maxwidth = element.scrollWidth - element.clientWidth;
        let container = element;
        let scrollAmount = 0;
        let slideTimer = setInterval(function(){
            container.scrollLeft += 10;
            scrollAmount += 10;
            if(scrollAmount >= maxwidth){
                window.clearInterval(slideTimer);
            }
        }, 25);
    }

    /**
     * Scrolls smooth to the min left of an given element
     *
     * @param element
     */
    handleScrollLeft(element) {
        const minwidth = 0;
        let container = element;
        let scrollAmount = element.scrollWidth - element.clientWidth;
        let slideTimer = setInterval(function(){
            container.scrollLeft -= 10;
            scrollAmount -= 10;
            if(scrollAmount <= minwidth){
                window.clearInterval(slideTimer);
            }
        }, 25);
    }

}
 No newline at end of file
Original line number Diff line number Diff line
import {i18n} from './i18n';
import {createInstance} from './i18n';
import {html, LitElement} from 'lit-element';
import {unsafeHTML} from 'lit-html/directives/unsafe-html.js';
import {ScopedElementsMixin} from '@open-wc/scoped-elements';
@@ -9,7 +9,8 @@ import * as commonUtils from '@dbp-toolkit/common/utils';
export class FileSourceDemo extends ScopedElementsMixin(LitElement) {
    constructor() {
        super();
        this.lang = 'de';
        this._i18n = createInstance();
        this.lang = this._i18n.language;
        this.url = '';
        this.selectedFiles = [];
        this.selectedFilesCount = 0;
@@ -46,7 +47,7 @@ export class FileSourceDemo extends ScopedElementsMixin(LitElement) {
    update(changedProperties) {
        changedProperties.forEach((oldValue, propName) => {
            if (propName === "lang") {
                i18n.changeLanguage(this.lang);
                this._i18n.changeLanguage(this.lang);
            }
        });

@@ -77,6 +78,8 @@ export class FileSourceDemo extends ScopedElementsMixin(LitElement) {
    }

    render() {
        const i18n = this._i18n;

        return html`
            <style>
                dbp-file-source.clean {
Original line number Diff line number Diff line
import {i18n} from './i18n';
import {createInstance} from './i18n';
import {css, html} from 'lit-element';
import {ScopedElementsMixin} from '@open-wc/scoped-elements';
import DBPLitElement from '@dbp-toolkit/common/dbp-lit-element';
import * as commonUtils from "@dbp-toolkit/common/utils";
import {Icon, MiniSpinner} from '@dbp-toolkit/common';
import * as commonStyles from '@dbp-toolkit/common/styles';
@@ -12,16 +11,18 @@ import MicroModal from "./micromodal.es";
import * as fileHandlingStyles from './styles';
import { send } from '@dbp-toolkit/common/notification';
import {Clipboard} from "@dbp-toolkit/file-handling/src/clipboard";
import DbpFileHandlingLitElement from "./dbp-file-handling-lit-element";


/**
 * FileSink web component
 */
export class FileSink extends ScopedElementsMixin(DBPLitElement) {
export class FileSink extends ScopedElementsMixin(DbpFileHandlingLitElement) {
    constructor() {
        super();
        this.context = '';
        this.lang = 'de';
        this._i18n = createInstance();
        this.lang = this._i18n.language;
        this.nextcloudAuthUrl = '';
        this.nextcloudWebDavUrl = '';
        this.nextcloudName ='Nextcloud';
@@ -78,8 +79,12 @@ export class FileSink extends ScopedElementsMixin(DBPLitElement) {

    connectedCallback() {
        super.connectedCallback();

        this.updateComplete.then(() => {
            this._('nav.modal-nav').addEventListener("scroll", this.handleScroll.bind(this));

            this._('.right-paddle').addEventListener("click", this.handleScrollRight.bind(this, this._('nav.modal-nav')));

            this._('.left-paddle').addEventListener("click", this.handleScrollLeft.bind(this, this._('nav.modal-nav')));
        });
    }

@@ -122,7 +127,7 @@ export class FileSink extends ScopedElementsMixin(DBPLitElement) {
        changedProperties.forEach((oldValue, propName) => {
            switch (propName) {
                case "lang":
                    i18n.changeLanguage(this.lang);
                    this._i18n.changeLanguage(this.lang);
                    break;
                case "enabledTargets":
                    if (!this.hasEnabledDestination(this.activeTargets)) {
@@ -163,6 +168,7 @@ export class FileSink extends ScopedElementsMixin(DBPLitElement) {
    }

    finishedFileUpload(event) {
        const i18n = this._i18n;
        this.sendDestination();
        MicroModal.close(this._('#modal-picker'));
        if (event.detail > 0) {
@@ -268,6 +274,7 @@ export class FileSink extends ScopedElementsMixin(DBPLitElement) {
    }

    getNextcloudHtml() {
        const i18n = this._i18n;
        if (this.enabledTargets.includes('nextcloud') && this.nextcloudWebDavUrl !== "" && this.nextcloudAuthUrl !== "") {
            return html`
                <dbp-nextcloud-file-picker id="nextcloud-file-picker"
@@ -331,17 +338,60 @@ export class FileSink extends ScopedElementsMixin(DBPLitElement) {
                height: 100%;
            }

            .paddle {
                position: absolute;
                background-color: #ffffffd1;
                top: 0px;
                padding: 0px 5px;
                box-sizing: content-box;
                height: 100%;
            }

            .right-paddle{
                right: 0px;
            }

            .left-paddle{
                left: 0px;
            }

            .nav-wrapper{
                position: relative;
                display: block;
                overflow-x: auto;
                border:none;
            }

            .paddles{
                display: none;
            }

            .modal-nav{
                height: 100%;
            }

            @media only screen
            and (orientation: portrait)
            and (max-width: 768px) {

                .paddles{
                    display: inherit;
                }

            }
            
            
        `;
    }

    render() {

        const i18n = this._i18n;
        return html`
            <vpu-notification lang="de" client-id="my-client-id"></vpu-notification>
            <div class="modal micromodal-slide" id="modal-picker" aria-hidden="true">
                <div class="modal-overlay" tabindex="-1">
                    <div class="modal-container ${classMap({"modal-container-full-size": this.fullsizeModal})}" role="dialog" aria-modal="true" aria-labelledby="modal-picker-title">
                        <div class="nav-wrapper modal-nav">
                            <nav class="modal-nav">
                                <div title="${i18n.t('file-sink.nav-local')}"
                                     @click="${() => { this.activeTarget = "local"; }}"
@@ -362,6 +412,12 @@ export class FileSink extends ScopedElementsMixin(DBPLitElement) {
                                    <p>${i18n.t('file-sink.clipboard')}</p>
                                </div>
                            </nav>
                            <div class="paddles">
                                <dbp-icon class="left-paddle paddle hidden" name="chevron-left" class="close-icon"></dbp-icon>
                                <dbp-icon class="right-paddle paddle" name="chevron-right" class="close-icon"></dbp-icon>
                            </div>
                        </div>
                       
                            <div class="modal-header">
                                <button title="${i18n.t('file-sink.modal-close')}" class="modal-close"  aria-label="Close modal" @click="${() => { this.closeDialog();}}">
                                        <dbp-icon title="${i18n.t('file-sink.modal-close')}" name="close" class="close-icon"></dbp-icon>
Original line number Diff line number Diff line
import {i18n} from './i18n';
import {createInstance} from './i18n';
import {css, html} from 'lit-element';
import {ScopedElementsMixin} from '@open-wc/scoped-elements';
import DBPLitElement from '@dbp-toolkit/common/dbp-lit-element';
import * as commonUtils from "@dbp-toolkit/common/utils";
import {Icon, MiniSpinner} from '@dbp-toolkit/common';
import {send as notify} from '@dbp-toolkit/common/notification';
@@ -11,6 +10,7 @@ import {classMap} from 'lit-html/directives/class-map.js';
import MicroModal from './micromodal.es';
import * as fileHandlingStyles from './styles';
import {Clipboard} from "@dbp-toolkit/file-handling/src/clipboard";
import DbpFileHandlingLitElement from "./dbp-file-handling-lit-element";

function mimeTypesToAccept(mimeTypes) {
    // Some operating systems can't handle mime types and
@@ -33,11 +33,12 @@ function mimeTypesToAccept(mimeTypes) {
/**
 * FileSource web component
 */
export class FileSource extends ScopedElementsMixin(DBPLitElement) {
export class FileSource extends ScopedElementsMixin(DbpFileHandlingLitElement) {
    constructor() {
        super();
        this.context = '';
        this.lang = 'de';
        this._i18n = createInstance();
        this.lang = this._i18n.language;
        this.nextcloudAuthUrl = '';
        this.nextcloudName ='Nextcloud';
        this.nextcloudWebDavUrl = '';
@@ -96,7 +97,7 @@ export class FileSource extends ScopedElementsMixin(DBPLitElement) {
        changedProperties.forEach((oldValue, propName) => {
            switch (propName) {
                case "lang":
                    i18n.changeLanguage(this.lang);
                    this._i18n.changeLanguage(this.lang);
                    break;
                case "enabledTargets":
                    if (!this.hasEnabledSource(this.activeTarget)) {
@@ -139,6 +140,12 @@ export class FileSource extends ScopedElementsMixin(DBPLitElement) {
            });
            this.dropArea.addEventListener('drop', this.handleDrop.bind(this), false);
            this._('#fileElem').addEventListener('change', this.handleChange.bind(this));

            this._('nav.modal-nav').addEventListener("scroll", this.handleScroll.bind(this));

            this._('.right-paddle').addEventListener("click", this.handleScrollRight.bind(this, this._('nav.modal-nav')));

            this._('.left-paddle').addEventListener("click", this.handleScrollLeft.bind(this, this._('nav.modal-nav')));
        });

    }
@@ -148,8 +155,6 @@ export class FileSource extends ScopedElementsMixin(DBPLitElement) {
        super.disconnectedCallback();
    }



    preventDefaults (e) {
        e.preventDefault();
        e.stopPropagation();
@@ -198,42 +203,44 @@ export class FileSource extends ScopedElementsMixin(DBPLitElement) {
        // console.log('handleFiles: files.length = ' + files.length);
        // this.dispatchEvent(new CustomEvent("dbp-file-source-selection-start",
        //     { "detail": {}, bubbles: true, composed: true }));

        await commonUtils.asyncArrayForEach(files, async (file) => {
        let fileCount = files.length;
        await commonUtils.asyncArrayForEach(files, async (file, index) => {
            if (file.size === 0) {
                console.log('file \'' + file.name + '\' has size=0 and is denied!');
                return;
            }

            // check if we want to decompress the zip and queue the contained files
            if (this.decompressZip
                && (file.type === "application/zip" || file.type === "application/x-zip-compressed")) {
                // add decompressed files to tempFilesToHandle
                await commonUtils.asyncArrayForEach(
                    await this.decompressZIP(file), (file) => this.sendFileEvent(file));
                    await this.decompressZIP(file), (file, index, array) => {
                        fileCount = index === array.length - 1 ? fileCount : fileCount + 1;
                        this.sendFileEvent(file,fileCount);
                     });

                return;
            } else if (this.allowedMimeTypes && !this.checkFileType(file)) {
                return;
            }

            await this.sendFileEvent(file);
            await this.sendFileEvent(file, fileCount);
        });

        // this.dispatchEvent(new CustomEvent("dbp-file-source-selection-finished",
        //     { "detail": {}, bubbles: true, composed: true }));
        const event = new CustomEvent("dbp-file-source-file-upload-finished", { "detail": {count: files.length}, bubbles: true, composed: true });
        const event = new CustomEvent("dbp-file-source-file-upload-finished", { "detail": {count: fileCount}, bubbles: true, composed: true });
        this.dispatchEvent(event);
        this.closeDialog();
    }

    /**
     * @param file
     * @param file, last
     */
    sendFileEvent(file) {
    sendFileEvent(file, maxUpload) {
        this.sendSource();
        MicroModal.close(this._('#modal-picker'));
        const data = {"file": file};
        const data = {"file": file, "maxUpload": maxUpload};
        const event = new CustomEvent("dbp-file-source-file-selected", { "detail": data, bubbles: true, composed: true });
        this.dispatchEvent(event);
    }
@@ -242,7 +249,6 @@ export class FileSource extends ScopedElementsMixin(DBPLitElement) {
        let data = {};
        if (this.activeTarget == 'nextcloud') {
            data = {"target": this.activeTarget, "path": this._("#nextcloud-file-picker").directoryPath};

        } else {
            data = {"target": this.activeTarget};
        }
@@ -321,6 +327,7 @@ export class FileSource extends ScopedElementsMixin(DBPLitElement) {

        // no suitable files found
        if (filesToHandle.length === 0) {
            const i18n = this._i18n;
            console.error('ZIP file does not contain any files of ' + this.allowedMimeTypes);
            //throw new Error('ZIP file does not contain any files of ' + this.allowedMimeTypes);
            notify({
@@ -477,7 +484,7 @@ export class FileSource extends ScopedElementsMixin(DBPLitElement) {
                   auth-info="${this.nextcloudAuthInfo}"
                   allowed-mime-types="${this.allowedMimeTypes}"
                   @dbp-nextcloud-file-picker-file-downloaded="${(event) => {
                    this.sendFileEvent(event.detail.file);}}">
                    this.sendFileEvent(event.detail.file, event.detail.maxUpload);}}">
                </dbp-nextcloud-file-picker>`;
        }
        return html``;
@@ -529,6 +536,39 @@ export class FileSource extends ScopedElementsMixin(DBPLitElement) {
                height: 100%;
            }
            
            .paddle {
                position: absolute;
                background-color: #ffffffd1;
                top: 0px;
                padding: 0px 5px;
                box-sizing: content-box;
                height: 100%;
            }
            
            .right-paddle{
                right: 0px;
            }

            .left-paddle{
                left: 0px;
            }
            
            .nav-wrapper{
                position: relative;
                display: block;
                overflow-x: auto;
                border:none;
            }
            
            .paddles{
                display: none;
            }
            
            .modal-nav{
                height: 100%;
            }


            @media only screen
            and (orientation: portrait)
            and (max-width: 768px) {
@@ -536,18 +576,28 @@ export class FileSource extends ScopedElementsMixin(DBPLitElement) {
                    height: 100%;
                }
             
            
            }

            @media only screen
            and (orientation: portrait)
            and (max-width: 340px) {

                .paddles{
                    display: inherit;
                }
            }
        `;
    }

    render() {
        const i18n = this._i18n;
        let allowedMimeTypes = this.allowedMimeTypes;

        if (this.decompressZip && this.allowedMimeTypes !== "*/*") {
            allowedMimeTypes += ",application/zip,application/x-zip-compressed";
        }


        return html`
<!--
            <button class="button"
@@ -557,6 +607,7 @@ export class FileSource extends ScopedElementsMixin(DBPLitElement) {
            <div class="modal micromodal-slide" id="modal-picker" aria-hidden="true">
                <div class="modal-overlay" tabindex="-1" data-micromodal-close>
                    <div class="modal-container" role="dialog" aria-modal="true" aria-labelledby="modal-picker-title">
                        <div class="nav-wrapper modal-nav">
                            <nav class="modal-nav">
                                <div title="${i18n.t('file-source.nav-local')}"
                                     @click="${() => { this.activeTarget = "local"; }}"
@@ -576,8 +627,12 @@ export class FileSource extends ScopedElementsMixin(DBPLitElement) {
                                    <dbp-icon class="nav-icon" name="clipboard"></dbp-icon>
                                    <p>${i18n.t('file-source.clipboard')}</p>
                                </div>
                            
                            </nav>
                            <div class="paddles">
                                <dbp-icon class="left-paddle paddle hidden" name="chevron-left" class="close-icon"></dbp-icon>
                                <dbp-icon class="right-paddle paddle" name="chevron-right" class="close-icon"></dbp-icon>
                            </div>
                        </div>
                        <div class="modal-header">
                            <button title="${i18n.t('file-source.modal-close')}" class="modal-close"  aria-label="Close modal"  @click="${() => {this.closeDialog();}}">
                                    <dbp-icon name="close" class="close-icon"></dbp-icon>
Original line number Diff line number Diff line
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 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');
}
 No newline at end of file
Original line number Diff line number Diff line
@@ -84,7 +84,8 @@
    "select-nothing": "Nichts auswählen",
    "select-nothing-title": "Alle gewählten Dateien nicht mehr selektieren",
    "abort": "Vorgang abbrechen",
    "abort-message": "Vorgang wurde abgebrochen."
    "abort-message": "Vorgang wurde abgebrochen.",
    "remember-me": "Angemeldet bleiben"
  },
  "clipboard": {
    "add-files": "Dateien der Zwischenablage hinzufügen",
Original line number Diff line number Diff line
@@ -98,7 +98,8 @@
    "select-nothing": "Select none",
    "select-nothing-title": "Select no files",
    "abort": "Cancel process",
    "abort-message": "The process was canceled."
    "abort-message": "The process was canceled.",
    "remember-me": "Remember me"
  },
  "clipboard": {
    "add-files": "Add files to clipboard",
Original line number Diff line number Diff line
import {i18n} from './i18n';
import {createInstance} from './i18n';
import {css, html} from 'lit-element';
import {ScopedElementsMixin} from '@open-wc/scoped-elements';
import DBPLitElement from '@dbp-toolkit/common/dbp-lit-element';
@@ -19,7 +19,9 @@ import * as fileHandlingStyles from './styles';
export class NextcloudFilePicker extends ScopedElementsMixin(DBPLitElement) {
    constructor() {
        super();
        this.lang = 'de';
        this._i18n = createInstance();
        this.lang = this._i18n.language;
        
        this.authUrl = '';
        this.webDavUrl = '';
        this.nextcloudName = 'Nextcloud';
@@ -37,7 +39,7 @@ export class NextcloudFilePicker extends ScopedElementsMixin(DBPLitElement) {
        this.loading = false;
        this._onReceiveWindowMessage = this.onReceiveWindowMessage.bind(this);

        this.folderIsSelected = i18n.t('nextcloud-file-picker.load-in-folder');
        this.folderIsSelected = this._i18n.t('nextcloud-file-picker.load-in-folder');
        this.generatedFilename = '';
        this.replaceFilename = '';
        this.customFilename = '';
@@ -97,7 +99,7 @@ export class NextcloudFilePicker extends ScopedElementsMixin(DBPLitElement) {
        changedProperties.forEach((oldValue, propName) => {
            switch (propName) {
                case "lang":
                    i18n.changeLanguage(this.lang);
                    this._i18n.changeLanguage(this.lang);
                    break;
                case "directoriesOnly":
                    if (this.directoriesOnly && this._("#select_all_wrapper")) {
@@ -136,6 +138,7 @@ export class NextcloudFilePicker extends ScopedElementsMixin(DBPLitElement) {
    connectedCallback() {
        super.connectedCallback();
        const that = this;
        const i18n = this._i18n;
        this.updateComplete.then(() => {
            // see: https://developer.mozilla.org/en-US/docs/Web/API/Window/postMessage
            window.addEventListener('message', this._onReceiveWindowMessage);
@@ -347,8 +350,6 @@ export class NextcloudFilePicker extends ScopedElementsMixin(DBPLitElement) {
                    password: sessionStorage.getItem("nextcloud-webdav-password")
                }
            );
            console.log("check");

            this.loadDirectory(this.directoryPath);

        }
@@ -377,6 +378,7 @@ export class NextcloudFilePicker extends ScopedElementsMixin(DBPLitElement) {
    }

    openFilePicker() {
        const i18n = this._i18n;
        if (this.webDavClient === null) {
            this.loading = true;
            this.statusText = i18n.t('nextcloud-file-picker.auth-progress');
@@ -391,7 +393,6 @@ export class NextcloudFilePicker extends ScopedElementsMixin(DBPLitElement) {
    }

    onReceiveWindowMessage(event) {
        console.log("hui");
        if (this.webDavClient === null) {
            const data = event.data;

@@ -399,7 +400,6 @@ export class NextcloudFilePicker extends ScopedElementsMixin(DBPLitElement) {
                if (this.loginWindow !== null) {
                    this.loginWindow.close();
                }
                console.log("lala");

                // see https://github.com/perry-mitchell/webdav-client/blob/master/API.md#module_WebDAV.createClient
                this.webDavClient = createClient(
@@ -409,7 +409,6 @@ export class NextcloudFilePicker extends ScopedElementsMixin(DBPLitElement) {
                        password: data.token
                    }
                );
                console.log("tada");

                if (this._("#remember-checkbox") && this._("#remember-checkbox").checked) {
                    sessionStorage.setItem('nextcloud-webdav-username', data.loginName);
@@ -428,6 +427,7 @@ export class NextcloudFilePicker extends ScopedElementsMixin(DBPLitElement) {
     * @param path
     */
    loadDirectory(path) {
        const i18n = this._i18n;
        if (typeof this.directoryPath === 'undefined' || this.directoryPath === undefined) {
            this.directoryPath = '';
        }
@@ -549,7 +549,8 @@ export class NextcloudFilePicker extends ScopedElementsMixin(DBPLitElement) {
     * @param files
     */
    downloadFiles(files) {
        files.forEach((fileData) => this.downloadFile(fileData));
        files.forEach((fileData) => this.downloadFile(fileData, files.length));

        this.tabulatorTable.deselectRow();
        if (this._("#select_all")) {
            this._("#select_all").checked = false;
@@ -569,9 +570,11 @@ export class NextcloudFilePicker extends ScopedElementsMixin(DBPLitElement) {
    /**
     * Download a single file
     *
     * @param fileData
     * @param fileData, maxUpload
     */
    downloadFile(fileData) {
    downloadFile(fileData, maxUpload) {

        const i18n = this._i18n;
        this.loading = true;
        this.statusText = "Loading " + fileData.filename + "...";

@@ -582,7 +585,7 @@ export class NextcloudFilePicker extends ScopedElementsMixin(DBPLitElement) {
                // create file to send via event
                const file = new File([contents], fileData.basename, {type: fileData.mime});
                // send event
                const data = {"file": file, "data": fileData};
                const data = {"file": file, "data": fileData, "maxUpload": maxUpload};
                const event = new CustomEvent("dbp-nextcloud-file-picker-file-downloaded",
                    {"detail": data, bubbles: true, composed: true});
                this.dispatchEvent(event);
@@ -602,6 +605,7 @@ export class NextcloudFilePicker extends ScopedElementsMixin(DBPLitElement) {
     * @param directory
     */
    sendDirectory(directory) {
        const i18n = this._i18n;
        this.tabulatorTable.deselectRow();
        let path;

@@ -626,6 +630,7 @@ export class NextcloudFilePicker extends ScopedElementsMixin(DBPLitElement) {
     * @param directory
     */
    uploadFiles(files, directory) {
        const i18n = this._i18n;
        this.loading = true;
        this.statusText = i18n.t('nextcloud-file-picker.upload-to', {path: directory});
        this.fileList = files;
@@ -646,6 +651,7 @@ export class NextcloudFilePicker extends ScopedElementsMixin(DBPLitElement) {
     * @param directory
     */
    async uploadFile(directory) {
        const i18n = this._i18n;
        if (this.abortUpload) {
            this.abortUpload = false;
            this.abortUploadButton = false;
@@ -712,6 +718,7 @@ export class NextcloudFilePicker extends ScopedElementsMixin(DBPLitElement) {
     *
     */
    async uploadFileAfterConflict() {
        const i18n = this._i18n;
        if (this.abortUpload) {
            this.abortUpload = false;
            this.abortUploadButton = false;
@@ -861,6 +868,7 @@ export class NextcloudFilePicker extends ScopedElementsMixin(DBPLitElement) {
     * @param directory
     */
    replaceModalDialog(file, directory) {
        const i18n = this._i18n;
        this.uploadFileObject = file;
        this.uploadFileDirectory = directory;
        let rights = this.checkRights(file);
@@ -969,6 +977,7 @@ export class NextcloudFilePicker extends ScopedElementsMixin(DBPLitElement) {
     * @returns {string} correct cancel text
     */
    getCancelText() {
        const i18n = this._i18n;
        if (this.fileList.length > 1) {
            return i18n.t('nextcloud-file-picker.replace-cancel-all');
        }
@@ -996,6 +1005,7 @@ export class NextcloudFilePicker extends ScopedElementsMixin(DBPLitElement) {
     *
     */
    openAddFolderDialogue() {
        const i18n = this._i18n;
        if (this._('.addRowAnimation')) {
            this._('.addRowAnimation').classList.remove('addRowAnimation');
        }
@@ -1015,6 +1025,7 @@ export class NextcloudFilePicker extends ScopedElementsMixin(DBPLitElement) {
     *
     */
    addFolder() {
        const i18n = this._i18n;
        if (this._('#new-folder').value !== "") {
            let folderName = this._('#new-folder').value;
            if (typeof this.directoryPath === 'undefined') {
@@ -1095,6 +1106,7 @@ export class NextcloudFilePicker extends ScopedElementsMixin(DBPLitElement) {
     * @returns {string} clickable breadcrumb path
     */
    getBreadcrumb() {
        const i18n = this._i18n;
        if (typeof this.directoryPath === 'undefined') {
            this.directoryPath = '';
        }
@@ -1601,6 +1613,7 @@ export class NextcloudFilePicker extends ScopedElementsMixin(DBPLitElement) {
    }

    render() {
        const i18n = this._i18n;
        const tabulatorCss = commonUtils.getAssetURL(pkgName, 'tabulator-tables/css/tabulator.min.css');

        return html`
@@ -1630,7 +1643,7 @@ export class NextcloudFilePicker extends ScopedElementsMixin(DBPLitElement) {
                    </div>
                    <div class="block text-center m-inherit ${classMap({hidden: this.isPickerActive})}">
                        <label class="button-container remember-container">
                            Remember me
                            ${i18n.t('nextcloud-file-picker.remember-me')}
                            <input type="checkbox" id="remember-checkbox" name="remember">
                            <span class="checkmark"></span>
                        </label>
Original line number Diff line number Diff line
@@ -211,7 +211,7 @@ export function getFileHandlingCss() {
        }

        .tabulator .tabulator-tableHolder {
            height: unset !important; /*TODO find a better way to do this*/
           /* height: unset !important; /*TODO find a better way to do this*/
        }

        .tabulator-row .tabulator-responsive-collapse{
@@ -227,6 +227,15 @@ export function getFileHandlingCss() {
            margin-top: -8px;
        }
        
        .tabulator-responsive-collapse-toggle-open, .tabulator-responsive-collapse-toggle-close{
            width: 100%;
            height: 100%;
        }
        
        .tabulator-row-handle{
            padding: 0px !important;
        }

        @media only screen
        and (orientation: portrait)
        and (max-width: 768px) {
Original line number Diff line number Diff line
@@ -30,7 +30,8 @@
    "rollup-plugin-copy": "^3.1.0",
    "rollup-plugin-delete": "^2.0.0",
    "rollup-plugin-serve": "^1.0.1",
    "rollup-plugin-terser": "^7.0.2"
    "rollup-plugin-terser": "^7.0.2",
    "i18next-scanner": "^3.0.0"
  },
  "dependencies": {
    "@dbp-toolkit/auth": "^0.2.2",
@@ -42,6 +43,7 @@
    "material-design-icons-svg": "^3.0.0"
  },
  "scripts": {
    "i18next": "i18next-scanner",
    "clean": "rm dist/*",
    "build": "npm run build-local",
    "build-local": "rollup -c",
Original line number Diff line number Diff line
import {i18n} from './i18n';
import {createInstance} from './i18n';
import {css, html} from 'lit-element';
import {ScopedElementsMixin} from '@open-wc/scoped-elements';
import {AuthKeycloak, LoginButton} from '@dbp-toolkit/auth';
@@ -10,7 +10,8 @@ import DBPLitElement from "@dbp-toolkit/common/dbp-lit-element";
export class KnowledgeBaseWebPageElementViewDemo extends ScopedElementsMixin(DBPLitElement) {
    constructor() {
        super();
        this.lang = 'de';
        this._i18n = createInstance();
        this.lang = this._i18n.language;
        this.entryPointUrl = '';
        this.noAuth = false;
    }
@@ -35,7 +36,7 @@ export class KnowledgeBaseWebPageElementViewDemo extends ScopedElementsMixin(DBP
    update(changedProperties) {
        changedProperties.forEach((oldValue, propName) => {
            if (propName === "lang") {
                i18n.changeLanguage(this.lang);
                this._i18n.changeLanguage(this.lang);
            }
        });

Original line number Diff line number Diff line
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 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');
}
 No newline at end of file
Original line number Diff line number Diff line
import {i18n} from './i18n';
import {createInstance} from './i18n';
import {html} from 'lit-element';
import {ScopedElementsMixin} from '@open-wc/scoped-elements';
import {MiniSpinner} from '@dbp-toolkit/common';
@@ -12,7 +12,8 @@ import {AdapterLitElement} from "@dbp-toolkit/provider/src/adapter-lit-element";
export class KnowledgeBaseWebPageElementView extends ScopedElementsMixin(AdapterLitElement) {
    constructor() {
        super();
        this.lang = 'de';
        this._i18n = createInstance();
        this.lang = this._i18n.language;
        this.value = '';
        this.html = '';
        this.entryPointUrl = '';
@@ -56,6 +57,8 @@ export class KnowledgeBaseWebPageElementView extends ScopedElementsMixin(Adapter
     * Loads the data from the web page element
     */
    loadWebPageElement() {
        const i18n = this._i18n;

        if (this.auth.token === undefined || this.auth.token === "") {
            return;
        }
@@ -107,7 +110,7 @@ export class KnowledgeBaseWebPageElementView extends ScopedElementsMixin(Adapter
    update(changedProperties) {
        changedProperties.forEach((oldValue, propName) => {
            if (propName === "lang") {
                i18n.changeLanguage(this.lang);
                this._i18n.changeLanguage(this.lang);
            }

            switch(propName) {
Original line number Diff line number Diff line
@@ -9,12 +9,12 @@ import {createInstance, setOverrides} from './i18n.js';
// This is an example on how to override translations at runtime
let OVERRIDES = {
    'de': {
        'translation': {
        'dbp-language-select-display': {
            'demo': 'Überschrieben'
        }
    },
    'en': {
        'translation': {
        'dbp-language-select-display': {
            'demo': 'Overridden'
        }
    }
@@ -26,7 +26,7 @@ class LanguageSelectDisplay extends AdapterLitElement {
        super();
        this.lang = 'de';
        this._i18n = createInstance();
        setOverrides(this._i18n, OVERRIDES);
        setOverrides(this._i18n, this, OVERRIDES);
    }

    static get properties() {
Original line number Diff line number Diff line
@@ -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',
Original line number Diff line number Diff line
import {i18n} from './i18n.js';
import {createInstance} from './i18n.js';
import {css, html} from 'lit-element';
import {ScopedElementsMixin} from '@open-wc/scoped-elements';
import {AuthKeycloak, LoginButton} from '@dbp-toolkit/auth';
@@ -12,7 +12,8 @@ export class MatomoDemo extends ScopedElementsMixin(DBPLitElement) {

    constructor() {
        super();
        this.lang = 'de';
        this._i18n = createInstance();
        this.lang = this._i18n.language;
        this.entryPointUrl = '';
        this.matomoUrl = '';
        this.matomoSiteId = -1;
@@ -38,9 +39,14 @@ export class MatomoDemo extends ScopedElementsMixin(DBPLitElement) {
        };
    }

    connectedCallback() {
        super.connectedCallback();
        i18n.changeLanguage(this.lang);
    update(changedProperties) {
         changedProperties.forEach((oldValue, propName) => {
            if (propName === "lang") {
                this._i18n.changeLanguage(this.lang);
            }
        });

        super.update(changedProperties);
    }

    track(action, message) {
Original line number Diff line number Diff line
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 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');
}
 No newline at end of file
Original line number Diff line number Diff line
@@ -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',
Original line number Diff line number Diff line
import {i18n} from './i18n';
import {createInstance} from './i18n';
import {send as notify} from '@dbp-toolkit/common/notification';
import {css, html, LitElement} from 'lit-element';
import {ScopedElementsMixin} from '@open-wc/scoped-elements';
@@ -9,7 +9,8 @@ import * as commonStyles from "@dbp-toolkit/common/styles";
export class NotificationDemo extends ScopedElementsMixin(LitElement) {
    constructor() {
        super();
        this.lang = 'de';
        this._i18n = createInstance();
        this.lang = this._i18n.language;
    }

    static get scopedElements() {
@@ -24,12 +25,14 @@ export class NotificationDemo extends ScopedElementsMixin(LitElement) {
        };
    }

    connectedCallback() {
        super.connectedCallback();
        i18n.changeLanguage(this.lang);

        this.updateComplete.then(()=>{
    update(changedProperties) {
        changedProperties.forEach((oldValue, propName) => {
           if (propName === "lang") {
               this._i18n.changeLanguage(this.lang);
           }
       });

       super.update(changedProperties);
   }

    static get styles() {
@@ -42,6 +45,8 @@ export class NotificationDemo extends ScopedElementsMixin(LitElement) {
    }

    render() {
        const i18n = this._i18n;

        return html`
            <section class="section">
                <div class="container">
Original line number Diff line number Diff line
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 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');
}
 No newline at end of file
Original line number Diff line number Diff line
import {i18n} from './i18n';
import {createInstance} from './i18n';
import {createUUID} from './utils';
import {css, html} from 'lit-element';
import DBPLitElement from '@dbp-toolkit/common/dbp-lit-element';
@@ -10,7 +10,8 @@ import * as commonStyles from '@dbp-toolkit/common/styles';
export class Notification extends DBPLitElement {
    constructor() {
        super();
        this.lang = 'de';
        this._i18n = createInstance();
        this.lang = this._i18n.language;
    }

    /**
@@ -25,7 +26,6 @@ export class Notification extends DBPLitElement {

    connectedCallback() {
        super.connectedCallback();
        i18n.changeLanguage(this.lang);
        const that = this;

        window.addEventListener("dbp-notification-send", (e) => {
@@ -63,9 +63,6 @@ export class Notification extends DBPLitElement {
            // mark the event as handled
            e.preventDefault();
        });

        this.updateComplete.then(()=>{
        });
    }

    removeMessageId(messageElementId) {
Original line number Diff line number Diff line
@@ -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',
Original line number Diff line number Diff line
import {i18n} from './i18n.js';
import {createInstance} from './i18n.js';
import {css, html} from 'lit-element';
import {ScopedElementsMixin} from '@open-wc/scoped-elements';
import {OrganizationSelect} from './organization-select.js';
@@ -10,7 +10,8 @@ import DBPLitElement from "@dbp-toolkit/common/dbp-lit-element";
export class OrganizationSelectDemo extends ScopedElementsMixin(DBPLitElement) {
    constructor() {
        super();
        this.lang = 'de';
        this._i18n = createInstance();
        this.lang = this._i18n.language;
        this.entryPointUrl = '';
        this.noAuth = false;
    }
@@ -32,12 +33,11 @@ export class OrganizationSelectDemo extends ScopedElementsMixin(DBPLitElement) {
        };
    }

    connectedCallback() {
        super.connectedCallback();
        i18n.changeLanguage(this.lang);

        this.updateComplete.then(()=>{
        });
    update(changedProperties) {
        if (changedProperties.has("lang")) {
            this._i18n.changeLanguage(this.lang);
        }
        super.update(changedProperties);
    }

    static get styles() {
Original line number Diff line number Diff line
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 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');
}
 No newline at end of file
Original line number Diff line number Diff line
{
  "select-organization": {
    "placeholder": "Bitte wählen Sie ein Institut aus",
    "loading": "Wird geladen...",
    "load-error": "Fehler beim Laden der Organisation"
    "loading": "Wird geladen..."
  }
}
Original line number Diff line number Diff line
{
  "select-organization": {
    "placeholder": "Please select an organization",
    "loading": "Loading...",
    "load-error": "Error loading the organization"
    "loading": "Loading..."
  }
}
Original line number Diff line number Diff line
import $ from 'jquery';
import select2 from 'select2';
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 * as commonUtils from '@dbp-toolkit/common/utils';
import * as commonStyles from '@dbp-toolkit/common/styles';
@@ -16,7 +16,8 @@ export class OrganizationSelect extends AdapterLitElement {
    constructor() {
        super();
        this.auth = {};
        this.lang = i18n.language;
        this._i18n = createInstance();
        this.lang = this._i18n.language;
        this.entryPointUrl = '';
        this.jsonld = null;
        this.organizations = [];
@@ -93,6 +94,7 @@ export class OrganizationSelect extends AdapterLitElement {
    }

    async updateSelect2() {
        const i18n = this._i18n;
        await this.updateComplete;

        const $select = this.$('#' + this.selectId);
@@ -181,7 +183,7 @@ export class OrganizationSelect extends AdapterLitElement {
        changedProperties.forEach((oldValue, propName) => {
            switch (propName) {
                case "lang":
                    i18n.changeLanguage(this.lang);
                    this._i18n.changeLanguage(this.lang);
                    this.updateSelect2();
                    break;
                case "value": {
Original line number Diff line number Diff line
@@ -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',
Original line number Diff line number Diff line
import {AuthKeycloak, LoginButton} from '@dbp-toolkit/auth';
import {i18n} from './i18n.js';
import {createInstance} from './i18n.js';
import {css, html} from 'lit-element';
import {ScopedElementsMixin} from '@open-wc/scoped-elements';
import DBPLitElement from '@dbp-toolkit/common/dbp-lit-element';
@@ -12,7 +12,8 @@ import {PersonSelect} from '@dbp-toolkit/person-select';
export class PersonProfileDemo extends ScopedElementsMixin(DBPLitElement) {
    constructor() {
        super();
        this.lang = 'de';
        this._i18n = createInstance();
        this.lang = this._i18n.language;
        this.entryPointUrl = '';
        this.person = '';
        this.selectedPerson = '';
@@ -42,6 +43,10 @@ export class PersonProfileDemo extends ScopedElementsMixin(DBPLitElement) {
    }

    update(changedProperties) {
        if (changedProperties.has("lang")) {
            this._i18n.changeLanguage(this.lang);
        }

        changedProperties.forEach((oldValue, propName) => {
            switch (propName) {
                case 'auth':
@@ -61,7 +66,6 @@ export class PersonProfileDemo extends ScopedElementsMixin(DBPLitElement) {

    connectedCallback() {
        super.connectedCallback();
        i18n.changeLanguage(this.lang);
        const that = this;

        this.updateComplete.then(()=>{
Original line number Diff line number Diff line
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 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');
}
 No newline at end of file
Original line number Diff line number Diff line

import JSONLD from '@dbp-toolkit/common/jsonld';
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 * as commonStyles from '@dbp-toolkit/common/styles';

@@ -10,7 +10,8 @@ export class PersonProfile extends DBPLitElement {

    constructor() {
        super();
        this.lang = 'de';
        this._i18n = createInstance();
        this.lang = this._i18n.language;
        this.entryPointUrl = '';
        this.jsonld = null;
        this.value = '';
@@ -29,18 +30,11 @@ export class PersonProfile extends DBPLitElement {
        };
    }

    connectedCallback() {
        super.connectedCallback();

        this.updateComplete.then(()=>{
        });
    }

    update(changedProperties) {
        changedProperties.forEach((oldValue, propName) => {
            switch (propName) {
                case "lang":
                    i18n.changeLanguage(this.lang);
                    this._i18n.changeLanguage(this.lang);
                    break;
                case "entryPointUrl": {
                    const that = this;
@@ -83,6 +77,7 @@ export class PersonProfile extends DBPLitElement {
    }

    render() {
        const i18n = this._i18n;
        let role = i18n.t('person-profile.unknown');
        if (this.person !== null && this.person.roles !== undefined) {
            // roles are only defined for self-disclosure
Original line number Diff line number Diff line
@@ -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',
Original line number Diff line number Diff line
import {i18n} from './i18n.js';
import {createInstance} from './i18n.js';
import {css, html} from 'lit-element';
import {ScopedElementsMixin} from '@open-wc/scoped-elements';
import {PersonSelect} from './person-select.js';
@@ -10,7 +10,8 @@ import DBPLitElement from "@dbp-toolkit/common/dbp-lit-element";
export class PersonSelectDemo extends ScopedElementsMixin(DBPLitElement) {
    constructor() {
        super();
        this.lang = 'de';
        this._i18n = createInstance();
        this.lang = this._i18n.language;
        this.entryPointUrl = '';
        this.noAuth = false;
    }
@@ -32,14 +33,6 @@ export class PersonSelectDemo extends ScopedElementsMixin(DBPLitElement) {
        };
    }

    connectedCallback() {
        super.connectedCallback();
        i18n.changeLanguage(this.lang);

        this.updateComplete.then(()=>{
        });
    }

    static get styles() {
        // language=css
        return [
@@ -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() {
        return this.noAuth ? html`<dbp-login-button subscribe="auth" lang="${this.lang}" show-image></dbp-login-button>` : html`
            <div class="container">
Original line number Diff line number Diff line
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 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');
}
 No newline at end of file
Original line number Diff line number Diff line
{
  "person-select": {
    "placeholder": "Bitte wählen Sie eine Person aus",
    "error-summary": "Ein Fehler ist aufgetreten",
    "login-required": "Anmeldung erforderlich"
  }
}
Original line number Diff line number Diff line
@@ -6,7 +6,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';
@@ -29,7 +29,8 @@ export class PersonSelect extends ScopedElementsMixin(AdapterLitElement) {
        super();
        Object.assign(PersonSelect.prototype, errorUtils.errorMixin);
        this.auth = {};
        this.lang = 'de';
        this._i18n = createInstance();
        this.lang = this._i18n.language;
        this.entryPointUrl = '';
        this.jsonld = null;
        this.$select = null;
@@ -129,6 +130,7 @@ export class PersonSelect extends ScopedElementsMixin(AdapterLitElement) {
     * @param ignorePreset
     */
    initSelect2(ignorePreset = false) {
        const i18n = this._i18n;
        const that = this;
        const $this = $(this);

@@ -155,7 +157,7 @@ export class PersonSelect extends ScopedElementsMixin(AdapterLitElement) {
            width: '100%',
            language: this.lang === "de" ? select2LangDe() : select2LangEn(),
            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'),
            ajax: {
                delay: 500,
@@ -277,7 +279,7 @@ export class PersonSelect 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
@@ -361,6 +363,7 @@ export class PersonSelect extends ScopedElementsMixin(AdapterLitElement) {
    }

    render() {
        const i18n = this._i18n;
        const select2CSS = commonUtils.getAssetURL(select2CSSPath);
        return html`
            <link rel="stylesheet" href="${select2CSS}">
Original line number Diff line number Diff line
@@ -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',
Original line number Diff line number Diff line
import {i18n} from './i18n.js';
import {createInstance} from './i18n.js';
import {css, html} from 'lit-element';
import {ScopedElementsMixin} from '@open-wc/scoped-elements';
import {AuthKeycloak, LoginButton} from '@dbp-toolkit/auth';
@@ -14,7 +14,8 @@ class ProviderDemo extends ScopedElementsMixin(DBPLitElement) {

    constructor() {
        super();
        this.lang = 'de';
        this._i18n = createInstance();
        this.lang = this._i18n.language;
    }

    static get scopedElements() {
@@ -35,18 +36,12 @@ class ProviderDemo extends ScopedElementsMixin(DBPLitElement) {
        };
    }

    connectedCallback() {
        super.connectedCallback();
        i18n.changeLanguage(this.lang);

    }

    attributeChangedCallback(name, oldValue, newValue) {
        console.debug('ProviderDemo (' + this.id + ') attributeChangesCallback( ' + name + ', ' + oldValue + ', ' + newValue + ')');
        switch(name) {
            case 'lang':
                this.lang = newValue;
                i18n.changeLanguage(this.lang);
                this._i18n.changeLanguage(this.lang);
                break;
            default:
                super.attributeChangedCallback(name, oldValue, newValue);
@@ -71,6 +66,7 @@ class ProviderDemo extends ScopedElementsMixin(DBPLitElement) {
    }

    render() {
        const i18n = this._i18n;
        return html`
            <section class="section">
                <p>${i18n.t('demo.provider_description', {id: "root", description: "is the top most in hierarchy"})}</p>
@@ -142,7 +138,8 @@ class DemoConsumer extends DBPLitElement {
    constructor() {
        super();

        this.lang = 'de';
        this._i18n = createInstance();
        this.lang = this._i18n.language;
        this.entryPointUrl = '';
        // default values
        this.foo = 100;
@@ -157,7 +154,6 @@ class DemoConsumer extends DBPLitElement {

    connectedCallback() {
        super.connectedCallback();
        i18n.changeLanguage(this.lang);
        console.debug('DemoConsumer(' + this.id + ') connectedCallback()');
        this.render();
    }
@@ -184,7 +180,7 @@ class DemoConsumer extends DBPLitElement {
        switch(name) {
            case 'lang':
                this.lang = newValue;
                i18n.changeLanguage(this.lang);
                this._i18n.changeLanguage(this.lang);
                break;
            case 'foo':
                this.foo = parseInt(newValue);
@@ -209,6 +205,7 @@ class DemoConsumer extends DBPLitElement {
    }

    render() {
        const i18n = this._i18n;
        if (! this.connected) {
            return `not connected!`;
        }
Original line number Diff line number Diff line
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 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');
}
 No newline at end of file
Original line number Diff line number Diff line
@@ -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',
Original line number Diff line number Diff line
import {i18n} from './i18n';
import {createInstance} from './i18n';
import {css, html, LitElement} from 'lit-element';
import {ScopedElementsMixin} from '@open-wc/scoped-elements';
import * as commonUtils from '@dbp-toolkit/common/utils';
@@ -8,7 +8,8 @@ import {QrCodeScanner} from './qr-code-scanner.js';
export class QrCodeScannerDemo extends ScopedElementsMixin(LitElement) {
    constructor() {
        super();
        this.lang = 'de';
        this._i18n = createInstance();
        this.lang = this._i18n.language;
    }

    static get scopedElements() {
@@ -23,12 +24,11 @@ export class QrCodeScannerDemo extends ScopedElementsMixin(LitElement) {
        };
    }

    connectedCallback() {
        super.connectedCallback();
        i18n.changeLanguage(this.lang);

        this.updateComplete.then(()=>{
        });
    update(changedProperties) {
        if (changedProperties.has("lang")) {
            this._i18n.changeLanguage(this.lang);
        }
        super.update(changedProperties);
    }

    static get styles() {
Original line number Diff line number Diff line
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 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');
}
 No newline at end of file
Original line number Diff line number Diff line
{
  "no-camera-access": "Zugriff auf Kamera nicht möglich.",
  "check-access": "Bitte stellen Sie sicher, dass eine Webcam oder Kamera aktiviert ist und überprüfen Sie ob Ihr Browser die notwendigen Berechtigungen besitzt.",
  "finished-scan": "Scannen abgeschlossen.",
  "loading-video": "Video laden ...",
  "no-qr-detected": "Kein QR-Code erkannt.",
  "no-support": "Ihr Browser unterstützt keine Videoaufnahmen.",
Original line number Diff line number Diff line
{
  "no-camera-access": "Unable to access video stream.",
  "check-access": "Please make sure that a webcam or camera is activated and check whether your browser has the necessary authorizations.",
  "finished-scan": "Finished scanning.",
  "loading-video": "⌛ Loading video...",
  "no-qr-detected": "No QR code detected.",
  "no-support": "Your browser does not support video recording.",
Original line number Diff line number Diff line
import {i18n} from './i18n';
import {createInstance} from './i18n';
import {css, html, unsafeCSS} from 'lit-element';
import DBPLitElement from '@dbp-toolkit/common/dbp-lit-element';
import * as commonStyles from '@dbp-toolkit/common/styles';
@@ -33,9 +33,10 @@ function getPrimaryDevice(devices) {
 *
 * Moreimportant devices first.
 *
 * @param i18n
 * @returns {Map<string,string>} the map of devices
 */
async function getVideoDevices() {
async function getVideoDevices(i18n) {
    let devices_map = new Map();
    if (navigator.mediaDevices
        && navigator.mediaDevices.enumerateDevices
@@ -135,7 +136,8 @@ class QRScanner {
export class QrCodeScanner extends ScopedElementsMixin(DBPLitElement) {
    constructor() {
        super();
        this.lang = 'de';
        this._i18n = createInstance();
        this.lang = this._i18n.language;

        this._askPermission = false;
        this._loading = false;
@@ -181,9 +183,8 @@ export class QrCodeScanner extends ScopedElementsMixin(DBPLitElement) {

    async connectedCallback() {
        super.connectedCallback();
        i18n.changeLanguage(this.lang);

        let devices = await getVideoDevices();
        let devices = await getVideoDevices(this._i18n);
        this._activeCamera = getPrimaryDevice(devices) || '';
        this._devices = devices;

@@ -209,7 +210,7 @@ export class QrCodeScanner extends ScopedElementsMixin(DBPLitElement) {
        changedProperties.forEach((oldValue, propName) => {
            switch (propName) {
                case "lang":
                    i18n.changeLanguage(this.lang);
                    this._i18n.changeLanguage(this.lang);
                    break;
            }
        });
@@ -232,6 +233,7 @@ export class QrCodeScanner extends ScopedElementsMixin(DBPLitElement) {
    }

    async _startScanning() {
        const i18n = this._i18n;
        console.assert(this._lock.isLocked());
        await this.updateComplete;

@@ -488,6 +490,7 @@ export class QrCodeScanner extends ScopedElementsMixin(DBPLitElement) {
    }

    render() {
        const i18n = this._i18n;
        let hasDevices = this._devices.size > 0;
        let showCanvas = this._videoRunning && !this._askPermission && !this._loading;
        let noSupportString = checkIosMobileSupport(this._devices) ? i18n.t('no-ios-support') : i18n.t('no-support');
Original line number Diff line number Diff line
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 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');
}
 No newline at end of file
Original line number Diff line number Diff line
import {html,LitElement,property} from 'lit-element';
import {i18n} from './i18n';
import {html,LitElement} from 'lit-element';
import {createInstance} from './i18n';

export class TypeScriptExample extends LitElement {

@@ -8,20 +8,20 @@ export class TypeScriptExample extends LitElement {
    constructor() {
        super();

        this._i18n = i18n.cloneInstance();
        this._i18n = createInstance();
        this.lang = this._i18n.language;
    }

    @property({type: String})
    lang = '';
    static get properties() {
        return {
          lang: {type: String}
        };
    }

    update(changedProperties) {
        changedProperties.forEach((oldValue, propName) => {
            switch (propName) {
                case "lang":
        if (changedProperties.has("lang")) {
            this._i18n.changeLanguage(this.lang);
                    break;
        }
        });
        super.update(changedProperties);
    }

+255 −423

File changed.

Preview size limit exceeded, changes collapsed.