mirror of
https://github.com/betaflight/betaflight-configurator.git
synced 2025-07-15 12:25:15 +03:00
chore: ESM for localization
This commit is contained in:
parent
4fa1f6a4c0
commit
73172bdb04
10 changed files with 90 additions and 15 deletions
19
gulpfile.js
19
gulpfile.js
|
@ -311,7 +311,15 @@ function dist_rollup() {
|
||||||
|
|
||||||
return rollup
|
return rollup
|
||||||
.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: [
|
plugins: [
|
||||||
alias({
|
alias({
|
||||||
entries: {
|
entries: {
|
||||||
|
@ -329,8 +337,13 @@ function dist_rollup() {
|
||||||
.then(bundle =>
|
.then(bundle =>
|
||||||
bundle.write({
|
bundle.write({
|
||||||
format: 'esm',
|
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,
|
||||||
|
})
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -85,7 +85,6 @@
|
||||||
"follow-redirects": "^1.10.0",
|
"follow-redirects": "^1.10.0",
|
||||||
"fs-extra": "^8.1.0",
|
"fs-extra": "^8.1.0",
|
||||||
"glob": "^7.1.6",
|
"glob": "^7.1.6",
|
||||||
"postcss": "^8.1.1",
|
|
||||||
"gulp": "^4.0.2",
|
"gulp": "^4.0.2",
|
||||||
"gulp-concat": "~2.6.1",
|
"gulp-concat": "~2.6.1",
|
||||||
"gulp-debian": "~0.1.8",
|
"gulp-debian": "~0.1.8",
|
||||||
|
@ -100,6 +99,7 @@
|
||||||
"karma-chai": "^0.1.0",
|
"karma-chai": "^0.1.0",
|
||||||
"karma-chrome-launcher": "^3.0.0",
|
"karma-chrome-launcher": "^3.0.0",
|
||||||
"karma-mocha": "^1.3.0",
|
"karma-mocha": "^1.3.0",
|
||||||
|
"karma-rollup-preprocessor": "^7.0.5",
|
||||||
"karma-sinon": "^1.0.5",
|
"karma-sinon": "^1.0.5",
|
||||||
"karma-sinon-chai": "^2.0.2",
|
"karma-sinon-chai": "^2.0.2",
|
||||||
"karma-spec-reporter": "^0.0.32",
|
"karma-spec-reporter": "^0.0.32",
|
||||||
|
@ -107,6 +107,7 @@
|
||||||
"mocha": "^7.0.1",
|
"mocha": "^7.0.1",
|
||||||
"nw-builder": "^3.5.7",
|
"nw-builder": "^3.5.7",
|
||||||
"os": "^0.1.1",
|
"os": "^0.1.1",
|
||||||
|
"postcss": "^8.1.1",
|
||||||
"rollup": "^2.28.2",
|
"rollup": "^2.28.2",
|
||||||
"rollup-plugin-vue": "^5.*.*",
|
"rollup-plugin-vue": "^5.*.*",
|
||||||
"rpm-builder": "^1.2.1",
|
"rpm-builder": "^1.2.1",
|
||||||
|
|
|
@ -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 Vue from "vue";
|
||||||
import vueI18n from "./vueI18n.js";
|
import vueI18n from "./vueI18n.js";
|
||||||
import BatteryLegend from "./quad-status/BatteryLegend.vue";
|
import BatteryLegend from "./quad-status/BatteryLegend.vue";
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
import Vue from "vue";
|
import Vue from "vue";
|
||||||
import VueI18Next from "@panter/vue-i18next";
|
import VueI18Next from "@panter/vue-i18next";
|
||||||
|
import i18next from 'i18next';
|
||||||
|
|
||||||
Vue.use(VueI18Next);
|
Vue.use(VueI18Next);
|
||||||
|
|
||||||
|
|
|
@ -1,10 +1,12 @@
|
||||||
'use strict';
|
import i18next from 'i18next';
|
||||||
|
import i18nextXHRBackend from 'i18next-xhr-backend';
|
||||||
|
|
||||||
|
const i18n = {};
|
||||||
/*
|
/*
|
||||||
* Wrapper around the i18n system
|
* 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'];
|
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);
|
const ns = takeFirst(i18next.options.defaultNS);
|
||||||
i18next.addResourceBundle(lang, ns, bundle, true, true);
|
i18next.addResourceBundle(lang, ns, bundle, true, true);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export { i18n };
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
'use strict';
|
import { i18n } from "./localization.js";
|
||||||
|
|
||||||
const REQUIRED_WEBVIEW_VERSION = 72;
|
const REQUIRED_WEBVIEW_VERSION = 72;
|
||||||
const WEBVIEW = {
|
const WEBVIEW = {
|
||||||
|
|
|
@ -49,8 +49,6 @@
|
||||||
<!-- CORDOVA_INCLUDE js/cordova_chromeapi.js -->
|
<!-- CORDOVA_INCLUDE js/cordova_chromeapi.js -->
|
||||||
<!-- CORDOVA_INCLUDE js/cordova_startup.js -->
|
<!-- CORDOVA_INCLUDE js/cordova_startup.js -->
|
||||||
<script type="text/javascript" src="./node_modules/lru_map/lru.js"></script>
|
<script type="text/javascript" src="./node_modules/lru_map/lru.js"></script>
|
||||||
<script type="text/javascript" src="./node_modules/i18next/i18next.min.js"></script>
|
|
||||||
<script type="text/javascript" src="./node_modules/i18next-xhr-backend/i18nextXHRBackend.min.js"></script>
|
|
||||||
<script type="text/javascript" src="./node_modules/marked/marked.min.js"></script>
|
<script type="text/javascript" src="./node_modules/marked/marked.min.js"></script>
|
||||||
<script type="text/javascript" src="./node_modules/universal-ga/lib/analytics.min.js"></script>
|
<script type="text/javascript" src="./node_modules/universal-ga/lib/analytics.min.js"></script>
|
||||||
<script type="text/javascript" src="./node_modules/short-unique-id/dist/short-unique-id.min.js"></script>
|
<script type="text/javascript" src="./node_modules/short-unique-id/dist/short-unique-id.min.js"></script>
|
||||||
|
@ -93,7 +91,6 @@
|
||||||
<script type="text/javascript" src="./js/peripherals.js"></script>
|
<script type="text/javascript" src="./js/peripherals.js"></script>
|
||||||
<script type="text/javascript" src="./js/protocols/stm32.js"></script>
|
<script type="text/javascript" src="./js/protocols/stm32.js"></script>
|
||||||
<script type="text/javascript" src="./js/protocols/stm32usbdfu.js"></script>
|
<script type="text/javascript" src="./js/protocols/stm32usbdfu.js"></script>
|
||||||
<script type="text/javascript" src="./js/localization.js"></script>
|
|
||||||
<script type="text/javascript" src="./js/boards.js"></script>
|
<script type="text/javascript" src="./js/boards.js"></script>
|
||||||
<script type="text/javascript" src="./js/RateCurve.js"></script>
|
<script type="text/javascript" src="./js/RateCurve.js"></script>
|
||||||
<script type="text/javascript" src="./js/Features.js"></script>
|
<script type="text/javascript" src="./js/Features.js"></script>
|
||||||
|
|
|
@ -39,10 +39,7 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<script type="text/javascript" src="./node_modules/jquery/dist/jquery.min.js"></script>
|
<script type="text/javascript" src="./node_modules/jquery/dist/jquery.min.js"></script>
|
||||||
<script type="text/javascript" src="./node_modules/i18next/i18next.min.js"></script>
|
|
||||||
<script type="text/javascript" src="./node_modules/i18next-xhr-backend/i18nextXHRBackend.min.js"></script>
|
|
||||||
<script type="text/javascript" src="./js/localization.js"></script>
|
|
||||||
<script type="text/javascript" src="cordova.js"></script>
|
<script type="text/javascript" src="cordova.js"></script>
|
||||||
<script type="text/javascript" src="./js/main_cordova.js"></script>
|
<script type="module" src="./js/main_cordova.js"></script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
|
@ -1,3 +1,9 @@
|
||||||
|
const commonjs = require("@rollup/plugin-commonjs");
|
||||||
|
const resolve = require("@rollup/plugin-node-resolve").default;
|
||||||
|
const rollupReplace = require("@rollup/plugin-replace");
|
||||||
|
|
||||||
|
const NODE_ENV = process.env.NODE_ENV || 'test';
|
||||||
|
|
||||||
module.exports = function(config) {
|
module.exports = function(config) {
|
||||||
config.set({
|
config.set({
|
||||||
reporters: ['tfs', 'spec'],
|
reporters: ['tfs', 'spec'],
|
||||||
|
@ -10,7 +16,7 @@ module.exports = function(config) {
|
||||||
'./node_modules/jbox/dist/jBox.min.js',
|
'./node_modules/jbox/dist/jBox.min.js',
|
||||||
'./src/js/serial.js',
|
'./src/js/serial.js',
|
||||||
'./src/js/data_storage.js',
|
'./src/js/data_storage.js',
|
||||||
'./src/js/localization.js',
|
{ pattern: './src/js/localization.js', type: 'module', watched: false },
|
||||||
'./src/js/gui.js',
|
'./src/js/gui.js',
|
||||||
'./src/js/CliAutoComplete.js',
|
'./src/js/CliAutoComplete.js',
|
||||||
'./src/js/tabs/cli.js',
|
'./src/js/tabs/cli.js',
|
||||||
|
@ -29,5 +35,20 @@ module.exports = function(config) {
|
||||||
outputFile: 'test_results.xml',
|
outputFile: 'test_results.xml',
|
||||||
},
|
},
|
||||||
singleRun: true,
|
singleRun: true,
|
||||||
|
preprocessors: {
|
||||||
|
'./src/js/localization.js': ['rollup'],
|
||||||
|
},
|
||||||
|
rollupPreprocessor: {
|
||||||
|
plugins: [
|
||||||
|
rollupReplace({
|
||||||
|
'process.env.NODE_ENV': JSON.stringify(NODE_ENV),
|
||||||
|
}),
|
||||||
|
resolve(),
|
||||||
|
commonjs(),
|
||||||
|
],
|
||||||
|
output: {
|
||||||
|
format: 'esm',
|
||||||
|
},
|
||||||
|
},
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
35
yarn.lock
35
yarn.lock
|
@ -1401,6 +1401,21 @@ chokidar@^3.0.0:
|
||||||
optionalDependencies:
|
optionalDependencies:
|
||||||
fsevents "~2.1.1"
|
fsevents "~2.1.1"
|
||||||
|
|
||||||
|
chokidar@^3.3.1:
|
||||||
|
version "3.4.3"
|
||||||
|
resolved "https://registry.yarnpkg.com/chokidar/-/chokidar-3.4.3.tgz#c1df38231448e45ca4ac588e6c79573ba6a57d5b"
|
||||||
|
integrity sha512-DtM3g7juCXQxFVSNPNByEC2+NImtBuxQQvWlHunpJIS5Ocr0lG306cC7FCi7cEA0fzmybPUIl4txBIobk1gGOQ==
|
||||||
|
dependencies:
|
||||||
|
anymatch "~3.1.1"
|
||||||
|
braces "~3.0.2"
|
||||||
|
glob-parent "~5.1.0"
|
||||||
|
is-binary-path "~2.1.0"
|
||||||
|
is-glob "~4.0.1"
|
||||||
|
normalize-path "~3.0.0"
|
||||||
|
readdirp "~3.5.0"
|
||||||
|
optionalDependencies:
|
||||||
|
fsevents "~2.1.2"
|
||||||
|
|
||||||
chownr@^1.0.1, chownr@^1.1.1:
|
chownr@^1.0.1, chownr@^1.1.1:
|
||||||
version "1.1.3"
|
version "1.1.3"
|
||||||
resolved "https://registry.yarnpkg.com/chownr/-/chownr-1.1.3.tgz#42d837d5239688d55f303003a508230fa6727142"
|
resolved "https://registry.yarnpkg.com/chownr/-/chownr-1.1.3.tgz#42d837d5239688d55f303003a508230fa6727142"
|
||||||
|
@ -2061,6 +2076,11 @@ de-indent@^1.0.2:
|
||||||
resolved "https://registry.yarnpkg.com/de-indent/-/de-indent-1.0.2.tgz#b2038e846dc33baa5796128d0804b455b8c1e21d"
|
resolved "https://registry.yarnpkg.com/de-indent/-/de-indent-1.0.2.tgz#b2038e846dc33baa5796128d0804b455b8c1e21d"
|
||||||
integrity sha1-sgOOhG3DO6pXlhKNCAS0VbjB4h0=
|
integrity sha1-sgOOhG3DO6pXlhKNCAS0VbjB4h0=
|
||||||
|
|
||||||
|
debounce@^1.2.0:
|
||||||
|
version "1.2.0"
|
||||||
|
resolved "https://registry.yarnpkg.com/debounce/-/debounce-1.2.0.tgz#44a540abc0ea9943018dc0eaa95cce87f65cd131"
|
||||||
|
integrity sha512-mYtLl1xfZLi1m4RtQYlZgJUNQjl4ZxVnHzIR8nLLgi4q1YT8o/WM+MK/f8yfcc9s5Ir5zRaPZyZU6xs1Syoocg==
|
||||||
|
|
||||||
debug@2.6.9, debug@^2.2.0, debug@^2.3.3:
|
debug@2.6.9, debug@^2.2.0, debug@^2.3.3:
|
||||||
version "2.6.9"
|
version "2.6.9"
|
||||||
resolved "https://registry.yarnpkg.com/debug/-/debug-2.6.9.tgz#5d128515df134ff327e90a4c93f4e077a536341f"
|
resolved "https://registry.yarnpkg.com/debug/-/debug-2.6.9.tgz#5d128515df134ff327e90a4c93f4e077a536341f"
|
||||||
|
@ -4636,6 +4656,14 @@ karma-mocha@^1.3.0:
|
||||||
dependencies:
|
dependencies:
|
||||||
minimist "1.2.0"
|
minimist "1.2.0"
|
||||||
|
|
||||||
|
karma-rollup-preprocessor@^7.0.5:
|
||||||
|
version "7.0.5"
|
||||||
|
resolved "https://registry.yarnpkg.com/karma-rollup-preprocessor/-/karma-rollup-preprocessor-7.0.5.tgz#d2cd9c8e654bc1451c31518bc18e6b022237deff"
|
||||||
|
integrity sha512-VhZI81l8LZBvBrSf4xaojsbur7bcycsSlxXkYaTOjV6DQwx1gtAM0CQVdue7LuIbXB1AohYIg0S5at+dqDtMxQ==
|
||||||
|
dependencies:
|
||||||
|
chokidar "^3.3.1"
|
||||||
|
debounce "^1.2.0"
|
||||||
|
|
||||||
karma-sinon-chai@^2.0.2:
|
karma-sinon-chai@^2.0.2:
|
||||||
version "2.0.2"
|
version "2.0.2"
|
||||||
resolved "https://registry.yarnpkg.com/karma-sinon-chai/-/karma-sinon-chai-2.0.2.tgz#e28c109b989973abafc28a7c9f09ef24a05e07c2"
|
resolved "https://registry.yarnpkg.com/karma-sinon-chai/-/karma-sinon-chai-2.0.2.tgz#e28c109b989973abafc28a7c9f09ef24a05e07c2"
|
||||||
|
@ -6736,6 +6764,13 @@ readdirp@~3.4.0:
|
||||||
dependencies:
|
dependencies:
|
||||||
picomatch "^2.2.1"
|
picomatch "^2.2.1"
|
||||||
|
|
||||||
|
readdirp@~3.5.0:
|
||||||
|
version "3.5.0"
|
||||||
|
resolved "https://registry.yarnpkg.com/readdirp/-/readdirp-3.5.0.tgz#9ba74c019b15d365278d2e91bb8c48d7b4d42c9e"
|
||||||
|
integrity sha512-cMhu7c/8rdhkHXWsY+osBhfSy0JikwpHK/5+imo+LpeasTF8ouErHrlYkwT0++njiyuDvc7OFY5T3ukvZ8qmFQ==
|
||||||
|
dependencies:
|
||||||
|
picomatch "^2.2.1"
|
||||||
|
|
||||||
rechoir@^0.6.2:
|
rechoir@^0.6.2:
|
||||||
version "0.6.2"
|
version "0.6.2"
|
||||||
resolved "https://registry.yarnpkg.com/rechoir/-/rechoir-0.6.2.tgz#85204b54dba82d5742e28c96756ef43af50e3384"
|
resolved "https://registry.yarnpkg.com/rechoir/-/rechoir-0.6.2.tgz#85204b54dba82d5742e28c96756ef43af50e3384"
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue