diff --git a/packages/common/dbp-common-demo.js b/packages/common/dbp-common-demo.js index 95a9986f1a0c79cd3f5564f279f4a776f89fc1f1..9a56ef03ec21d0d620844c2944453c36225b68e7 100644 --- a/packages/common/dbp-common-demo.js +++ b/packages/common/dbp-common-demo.js @@ -1,4 +1,4 @@ -import {createInstance} 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'; diff --git a/packages/common/i18next-scanner.config.js b/packages/common/i18next-scanner.config.js new file mode 100644 index 0000000000000000000000000000000000000000..773819264a14879dcd454bb9a5317ccdeec2e9d8 --- /dev/null +++ b/packages/common/i18next-scanner.config.js @@ -0,0 +1,17 @@ +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' + }, + }, +} diff --git a/packages/common/jsonld.js b/packages/common/jsonld.js index 6ce7750d246933f8b4bd6fa40dd8738d34a0cfeb..f74e38cf8b1b46881bde1376ce4472775f6d59d5 100644 --- a/packages/common/jsonld.js +++ b/packages/common/jsonld.js @@ -1,6 +1,6 @@ import {send as notify} from './notification'; import * as utils from "./utils"; -import {createInstance} from "./i18n"; +import {createInstance} from "./src/i18n"; export default class JSONLD { constructor(baseApiUrl, entities) { diff --git a/packages/common/package.json b/packages/common/package.json index d4ed6c5f0b8c3cd447d1a833b4b725028a58f995..c14f62c5b9bb4c9826e3206b7139506ad61ffaac 100644 --- a/packages/common/package.json +++ b/packages/common/package.json @@ -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", diff --git a/packages/common/i18n.js b/packages/common/src/i18n.js similarity index 74% rename from packages/common/i18n.js rename to packages/common/src/i18n.js index 65d10ba70c8b7e955ec855d7ba89d06540168373..ebd734720b5a52bbd4008d0e503ca96f9d3fa068 100644 --- a/packages/common/i18n.js +++ b/packages/common/src/i18n.js @@ -1,4 +1,4 @@ -import {createInstance as _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'; diff --git a/packages/common/i18n/de/translation.json b/packages/common/src/i18n/de/translation.json similarity index 100% rename from packages/common/i18n/de/translation.json rename to packages/common/src/i18n/de/translation.json diff --git a/packages/common/i18n/en/translation.json b/packages/common/src/i18n/en/translation.json similarity index 100% rename from packages/common/i18n/en/translation.json rename to packages/common/src/i18n/en/translation.json