diff --git a/.gitignore b/.gitignore index 015a031..0de9aaf 100644 --- a/.gitignore +++ b/.gitignore @@ -7,4 +7,3 @@ node_modules/ .idea .sass-cache *.map -js/lang.js diff --git a/_build_js.sh b/_build_js.sh index fea3428..32ff64a 100755 --- a/_build_js.sh +++ b/_build_js.sh @@ -2,8 +2,6 @@ source "_build_common.sh" mkdir -p out/js -echo 'Generating lang.js...' -php ./dump_js_lang.php $@ echo 'Processing JS...' npm run webpack diff --git a/dump_js_lang.php b/dump_js_lang.php deleted file mode 100755 index 80196de..0000000 --- a/dump_js_lang.php +++ /dev/null @@ -1,28 +0,0 @@ - obj.request) + .concat([this.resource]).join('!') + } + + let currentRequest = this.currentRequest + if (!currentRequest) { + remainingRequest = this.loaders.slice(this.loaderIndex) + .map(obj => obj.request) + .concat([this.resource]).join('!') + } + + let map = { + version: 3, + file: currentRequest, + sourceRoot: '', + sources: [remainingRequest], + sourcesContent: [source], + names: [], + mappings: 'AAAA;AAAA' + } + + this.callback(null, + `/* Generated language file */\n` + + `module.exports=${JSON.stringify(data)}\n`, map) +} diff --git a/lang/js-keys.js b/lang/js-keys.js new file mode 100644 index 0000000..967aa6f --- /dev/null +++ b/lang/js-keys.js @@ -0,0 +1,12 @@ +// define language keys used by JS here +module.exports = [ + 'wifi.connected_ip_is', + 'wifi.not_conn', + 'wifi.enter_passwd', + 'term_nav.fullscreen', + 'term_conn.connecting', + 'term_conn.waiting_content', + 'term_conn.disconnected', + 'term_conn.waiting_server', + 'term_conn.reconnecting' +] diff --git a/webpack.config.js b/webpack.config.js index e332745..29ba3f4 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -20,6 +20,13 @@ plugins.push(new webpack.optimize.UglifyJsPlugin({ sourceMap: devtool === 'source-map' })) +// replace "locale-data" with path to locale data +let locale = process.env.ESP_LANG || 'en' +plugins.push(new webpack.NormalModuleReplacementPlugin( + /^locale-data$/, + path.resolve(`lang/${locale}.php`) +)) + module.exports = { entry: './js', output: { @@ -34,6 +41,10 @@ module.exports = { path.resolve(__dirname, 'node_modules') ], loader: 'babel-loader' + }, + { + test: /lang\/.+?\.php$/, + loader: './lang/_js-lang-loader.js' } ] },