From e9f78e8215d11958fa04ce8c2527ed751264093d Mon Sep 17 00:00:00 2001
From: Christoph Reiter <reiter.christoph@gmail.com>
Date: Thu, 1 Jul 2021 17:42:58 +0200
Subject: [PATCH] app-shell: add i18next-scanner support

---
 packages/app-shell/i18next-scanner.config.js    | 16 ++++++++++++++++
 packages/app-shell/package.json                 |  4 +++-
 packages/app-shell/src/i18n/de/translation.json |  4 ++--
 packages/app-shell/src/i18n/en/translation.json |  2 +-
 4 files changed, 22 insertions(+), 4 deletions(-)
 create mode 100644 packages/app-shell/i18next-scanner.config.js

diff --git a/packages/app-shell/i18next-scanner.config.js b/packages/app-shell/i18next-scanner.config.js
new file mode 100644
index 00000000..aeb8fdb6
--- /dev/null
+++ b/packages/app-shell/i18next-scanner.config.js
@@ -0,0 +1,16 @@
+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'
+        },
+    },
+}
diff --git a/packages/app-shell/package.json b/packages/app-shell/package.json
index ccecb039..d31a609a 100644
--- a/packages/app-shell/package.json
+++ b/packages/app-shell/package.json
@@ -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",
diff --git a/packages/app-shell/src/i18n/de/translation.json b/packages/app-shell/src/i18n/de/translation.json
index bac3fc0f..3b959a1a 100644
--- a/packages/app-shell/src/i18n/de/translation.json
+++ b/packages/app-shell/src/i18n/de/translation.json
@@ -12,10 +12,10 @@
     "hello-world": "Hallo Welt"
   },
   "welcome": {
-      "headline": "Willkommen bei der Applikation '{{appname}}'."
+    "headline": "Willkommen bei der Applikation '{{appname}}'."
   },
   "login": "Einloggen",
   "logout": "Ausloggen",
   "page-not-found": "Die gewünschte Seite wurde nicht gefunden",
   "choose-from-menu": "Bitte wählen Sie eine Aktivität aus dem Menu."
-}
\ No newline at end of file
+}
diff --git a/packages/app-shell/src/i18n/en/translation.json b/packages/app-shell/src/i18n/en/translation.json
index 5a5c20a4..ae4a137d 100644
--- a/packages/app-shell/src/i18n/en/translation.json
+++ b/packages/app-shell/src/i18n/en/translation.json
@@ -12,7 +12,7 @@
     "hello-world": "Hello World"
   },
   "welcome": {
-      "headline": "Welcome to the '{{appname}}' application."
+    "headline": "Welcome to the '{{appname}}' application."
   },
   "login": "Login",
   "logout": "Logout",
-- 
GitLab