diff --git a/gulpfile.ts b/gulpfile.ts index 06eaafc96f..ff178582be 100644 --- a/gulpfile.ts +++ b/gulpfile.ts @@ -2,6 +2,7 @@ * Gulp tasks */ +import * as childProcess from 'child_process'; import * as fs from 'fs'; import * as Path from 'path'; import * as gulp from 'gulp'; @@ -10,7 +11,6 @@ import * as ts from 'gulp-typescript'; import tslint from 'gulp-tslint'; import * as glob from 'glob'; import * as es from 'event-stream'; -import * as webpack from 'webpack-stream'; import cssnano = require('gulp-cssnano'); //import * as uglify from 'gulp-uglify'; import pug = require('gulp-pug'); @@ -123,21 +123,25 @@ gulp.task('cleanall', ['clean'], cb => gulp.task('default', ['build']); gulp.task('build:client', [ - 'build:ts', 'build:js', - 'build:client:scripts', + 'build:ts', + 'build:js', + 'webpack', + 'build:client:script', 'build:client:pug', 'copy:client' ]); -gulp.task('build:client:scripts', () => - es.merge( - webpack(require('./webpack.config'), require('webpack')) - .pipe(gulp.dest('./built/web/assets/')) as any, - gulp.src('./src/web/app/client/script.js') - .pipe(replace('VERSION', JSON.stringify(version))) - //.pipe(isProduction ? uglify() : gutil.noop()) - .pipe(gulp.dest('./built/web/assets/client/')) as any - ) +gulp.task('webpack', done => { + const output = childProcess.execSync(Path.join('.', 'node_modules', '.bin', 'webpack') + ' --config webpack.config.ts', ); + console.log(output.toString()); + done(); +}); + +gulp.task('build:client:script', () => + gulp.src('./src/web/app/client/script.js') + .pipe(replace('VERSION', JSON.stringify(version))) + //.pipe(isProduction ? uglify() : gutil.noop()) + .pipe(gulp.dest('./built/web/assets/client/')) as any ); gulp.task('build:client:styles', () => @@ -149,7 +153,8 @@ gulp.task('build:client:styles', () => ); gulp.task('copy:client', [ - 'build:client:scripts' + 'build:client:script', + 'webpack' ], () => gulp.src([ './assets/**/*', @@ -165,7 +170,7 @@ gulp.task('copy:client', [ gulp.task('build:client:pug', [ 'copy:client', - 'build:client:scripts', + 'build:client:script', 'build:client:styles' ], () => gulp.src('./src/web/app/*/view.pug') diff --git a/locales/en.json b/locales/en.json new file mode 100644 index 0000000000..ea6ae5b7d6 --- /dev/null +++ b/locales/en.json @@ -0,0 +1,3 @@ +{ + "home": "Home" +} diff --git a/locales/ja.json b/locales/ja.json new file mode 100644 index 0000000000..7a7f3a2d02 --- /dev/null +++ b/locales/ja.json @@ -0,0 +1,3 @@ +{ + "home": "ホーム" +} diff --git a/package.json b/package.json index 631bb84d2c..e77c1dbba0 100644 --- a/package.json +++ b/package.json @@ -144,7 +144,6 @@ "uuid": "3.0.1", "vhost": "3.0.2", "webpack": "2.3.1", - "webpack-stream": "3.2.0", "websocket": "1.0.24", "whatwg-fetch": "2.0.3", "xml2json": "0.11.0" diff --git a/src/web/app/client/script.js b/src/web/app/client/script.js index 0f0fd7aa45..876d2c1694 100644 --- a/src/web/app/client/script.js +++ b/src/web/app/client/script.js @@ -4,6 +4,10 @@ (() => { const head = document.getElementsByTagName('head')[0]; + // Detect user language + let lang = (navigator.languages && navigator.languages[0]) || navigator.language; + if (!/en|en\-US|ja/.test(lang)) lang = 'en'; + // Detect user agent const ua = navigator.userAgent.toLowerCase(); const isMobile = /mobile|iphone|ipad|android/.test(ua); @@ -15,7 +19,7 @@ */ function mountDesktop() { const script = document.createElement('script'); - script.setAttribute('src', `/assets/desktop/script.${VERSION}.js`); + script.setAttribute('src', `/assets/desktop/script.${VERSION}.${lang}.js`); script.setAttribute('async', 'true'); script.setAttribute('defer', 'true'); head.appendChild(script); @@ -31,7 +35,7 @@ head.appendChild(meta); const script = document.createElement('script'); - script.setAttribute('src', `/assets/mobile/script.${VERSION}.js`); + script.setAttribute('src', `/assets/mobile/script.${VERSION}.${lang}.js`); script.setAttribute('async', 'true'); script.setAttribute('defer', 'true'); head.appendChild(script); diff --git a/src/web/app/desktop/tags/ui-header-nav.tag b/src/web/app/desktop/tags/ui-header-nav.tag index 447dcf2388..5ffa392f5c 100644 --- a/src/web/app/desktop/tags/ui-header-nav.tag +++ b/src/web/app/desktop/tags/ui-header-nav.tag @@ -3,7 +3,7 @@
ホーム
+'i18n:home'