From 5c38084af523b6f21fa915b8d442a9d3f6a24f8f Mon Sep 17 00:00:00 2001 From: syuilo Date: Thu, 17 May 2018 15:41:07 +0900 Subject: [PATCH] :v: --- gulpfile.ts | 2 ++ locales/index.ts | 1 + src/client/app/boot.js | 2 +- src/client/app/desktop/views/components/settings.vue | 5 +++-- 4 files changed, 7 insertions(+), 3 deletions(-) diff --git a/gulpfile.ts b/gulpfile.ts index a9ccbbdb5..fa1155878 100644 --- a/gulpfile.ts +++ b/gulpfile.ts @@ -20,6 +20,7 @@ import * as replace from 'gulp-replace'; import * as htmlmin from 'gulp-htmlmin'; const uglifyes = require('uglify-es'); +import locales from './locales'; import { fa } from './src/build/fa'; const client = require('./built/client/meta.json'); import config from './src/config'; @@ -122,6 +123,7 @@ gulp.task('build:client:script', () => .pipe(replace('VERSION', JSON.stringify(client.version))) .pipe(replace('API', JSON.stringify(config.api_url))) .pipe(replace('ENV', JSON.stringify(env))) + .pipe(replace('LANGS', JSON.stringify(Object.keys(locales)))) .pipe(isProduction ? uglify({ toplevel: true } as any) : gutil.noop()) diff --git a/locales/index.ts b/locales/index.ts index 89d18190f..319d178e0 100644 --- a/locales/index.ts +++ b/locales/index.ts @@ -11,6 +11,7 @@ const loadLang = lang => yaml.safeLoad( const native = loadLang('ja'); const langs = { + 'de': loadLang('de'), 'en': loadLang('en'), 'fr': loadLang('fr'), 'ja': native, diff --git a/src/client/app/boot.js b/src/client/app/boot.js index 35d02cf9c..9338bc501 100644 --- a/src/client/app/boot.js +++ b/src/client/app/boot.js @@ -32,7 +32,7 @@ // Detect the user language // Note: The default language is Japanese let lang = navigator.language.split('-')[0]; - if (!/^(en|ja)$/.test(lang)) lang = 'ja'; + if (!LANGS.includes(lang)) lang = 'en'; if (localStorage.getItem('lang')) lang = localStorage.getItem('lang'); // Detect the user agent diff --git a/src/client/app/desktop/views/components/settings.vue b/src/client/app/desktop/views/components/settings.vue index 9439ded2f..9e13aba13 100644 --- a/src/client/app/desktop/views/components/settings.vue +++ b/src/client/app/desktop/views/components/settings.vue @@ -80,10 +80,11 @@ - - + + +