diff --git a/gulpfile.js b/gulpfile.js
index 2e8b2625..7af12d35 100644
--- a/gulpfile.js
+++ b/gulpfile.js
@@ -311,7 +311,15 @@ function dist_rollup() {
return rollup
.rollup({
- input: 'src/components/init.js',
+ input: {
+ // For any new file migrated to modules add the output path
+ // in dist on the left, on the right it's input file path.
+ // If all the things used by other files are importing
+ // it with `import/export` file doesn't have to be here.
+ // I will be picked up by rollup and bundled accrodingly.
+ 'components/init': 'src/components/init.js',
+ 'js/main_cordova': 'src/js/main_cordova.js',
+ },
plugins: [
alias({
entries: {
@@ -329,8 +337,13 @@ function dist_rollup() {
.then(bundle =>
bundle.write({
format: 'esm',
- file: 'dist/components/init.js',
- }),
+ // rollup is smart about how `name` is treated.
+ // so `input` you create file like `components/init`
+ // `[name]` will be replaced with it creating directories
+ // accordingly inside of `dist`
+ entryFileNames: '[name].js',
+ dir: DIST_DIR,
+ })
);
}
diff --git a/package.json b/package.json
index 21838ab4..c2f31b03 100644
--- a/package.json
+++ b/package.json
@@ -85,7 +85,6 @@
"follow-redirects": "^1.10.0",
"fs-extra": "^8.1.0",
"glob": "^7.1.6",
- "postcss": "^8.1.1",
"gulp": "^4.0.2",
"gulp-concat": "~2.6.1",
"gulp-debian": "~0.1.8",
@@ -100,6 +99,7 @@
"karma-chai": "^0.1.0",
"karma-chrome-launcher": "^3.0.0",
"karma-mocha": "^1.3.0",
+ "karma-rollup-preprocessor": "^7.0.5",
"karma-sinon": "^1.0.5",
"karma-sinon-chai": "^2.0.2",
"karma-spec-reporter": "^0.0.32",
@@ -107,6 +107,7 @@
"mocha": "^7.0.1",
"nw-builder": "^3.5.7",
"os": "^0.1.1",
+ "postcss": "^8.1.1",
"rollup": "^2.28.2",
"rollup-plugin-vue": "^5.*.*",
"rpm-builder": "^1.2.1",
diff --git a/src/components/init.js b/src/components/init.js
index 339aa9c7..a10436b1 100644
--- a/src/components/init.js
+++ b/src/components/init.js
@@ -1,3 +1,9 @@
+// This modules is imported and has side effect of attaching the
+// `i18n` helper to window and setting up `i18next`
+// in the future it should be pure. This means it should
+// explicitly export things used by other parts of the app.
+import '../js/localization.js';
+import i18next from 'i18next';
import Vue from "vue";
import vueI18n from "./vueI18n.js";
import BatteryLegend from "./quad-status/BatteryLegend.vue";
diff --git a/src/components/vueI18n.js b/src/components/vueI18n.js
index 436553f7..fa4174bb 100644
--- a/src/components/vueI18n.js
+++ b/src/components/vueI18n.js
@@ -1,5 +1,6 @@
import Vue from "vue";
import VueI18Next from "@panter/vue-i18next";
+import i18next from 'i18next';
Vue.use(VueI18Next);
diff --git a/src/js/localization.js b/src/js/localization.js
index 7c8d7594..ff90b78d 100644
--- a/src/js/localization.js
+++ b/src/js/localization.js
@@ -1,10 +1,12 @@
-'use strict';
+import i18next from 'i18next';
+import i18nextXHRBackend from 'i18next-xhr-backend';
+const i18n = {};
/*
* Wrapper around the i18n system
*/
+window.i18n = i18n;
-window.i18n = {};
const languagesAvailables = ['ca', 'de', 'en', 'es', 'eu', 'fr', 'gl', 'hr', 'hu', 'id', 'it', 'ja', 'ko', 'lv', 'nl', 'pt', 'pt_BR', 'pl', 'ru', 'sv', 'zh_CN', 'zh_TW'];
@@ -242,3 +244,5 @@ i18n.addResources = function(bundle) {
const ns = takeFirst(i18next.options.defaultNS);
i18next.addResourceBundle(lang, ns, bundle, true, true);
};
+
+export { i18n };
diff --git a/src/js/main_cordova.js b/src/js/main_cordova.js
index 942655f6..16a2634e 100644
--- a/src/js/main_cordova.js
+++ b/src/js/main_cordova.js
@@ -1,4 +1,4 @@
-'use strict';
+import { i18n } from "./localization.js";
const REQUIRED_WEBVIEW_VERSION = 72;
const WEBVIEW = {
diff --git a/src/main.html b/src/main.html
index a596ddf4..ee42864c 100644
--- a/src/main.html
+++ b/src/main.html
@@ -49,8 +49,6 @@
-
-
@@ -93,7 +91,6 @@
-
diff --git a/src/main_cordova.html b/src/main_cordova.html
index e1e828e9..c4977a9b 100644
--- a/src/main_cordova.html
+++ b/src/main_cordova.html
@@ -39,10 +39,7 @@
-
-
-
-
+