summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsyuilo <syuilotan@yahoo.co.jp>2018-04-15 06:16:50 +0900
committersyuilo <syuilotan@yahoo.co.jp>2018-04-15 06:16:50 +0900
commita53746e9d07a7089947480b1893eb829c0560a28 (patch)
treed73052a018c799ee8998c16f384b467492d25e00
parentwip (diff)
downloadmisskey-a53746e9d07a7089947480b1893eb829c0560a28.tar.gz
misskey-a53746e9d07a7089947480b1893eb829c0560a28.tar.bz2
misskey-a53746e9d07a7089947480b1893eb829c0560a28.zip
:v:
-rw-r--r--src/build/i18n.ts2
-rw-r--r--src/client/app/boot.js8
-rw-r--r--webpack.config.ts8
-rw-r--r--webpack/loaders/replace.js3
4 files changed, 12 insertions, 9 deletions
diff --git a/src/build/i18n.ts b/src/build/i18n.ts
index 35204c34a4..2790191191 100644
--- a/src/build/i18n.ts
+++ b/src/build/i18n.ts
@@ -63,6 +63,8 @@ export default class Replacer {
key = key.substr(1);
}
+ if (ctx && ctx.lang) this.lang = ctx.lang;
+
if (match[0] == '"') {
return '"' + this.get(name, key).replace(/"/g, '\\"') + '"';
} else if (match[0] == "'") {
diff --git a/src/client/app/boot.js b/src/client/app/boot.js
index 2675fa233a..12b0d220a9 100644
--- a/src/client/app/boot.js
+++ b/src/client/app/boot.js
@@ -31,11 +31,9 @@
// Detect the user language
// Note: The default language is Japanese
- //let lang = navigator.language.split('-')[0];
- //if (!/^(en|ja)$/.test(lang)) lang = 'ja';
- //if (localStorage.getItem('lang')) lang = localStorage.getItem('lang');
- //if (ENV != 'production') lang = 'ja';
- const lang = 'ja';
+ let lang = navigator.language.split('-')[0];
+ if (!/^(en|ja)$/.test(lang)) lang = 'ja';
+ if (localStorage.getItem('lang')) lang = localStorage.getItem('lang');
// Detect the user agent
const ua = navigator.userAgent.toLowerCase();
diff --git a/webpack.config.ts b/webpack.config.ts
index b0b06c7392..bc876e067d 100644
--- a/webpack.config.ts
+++ b/webpack.config.ts
@@ -42,7 +42,7 @@ const langs = Object.keys(locales);
const entries = process.env.NODE_ENV == 'production'
? langs.map(l => [l, false]).concat(langs.map(l => [l, true]))
- : [['ja', false]];
+ : langs.map(l => [l, false]);
module.exports = entries.map(x => {
const [lang, isProduction] = x;
@@ -144,7 +144,8 @@ module.exports = entries.map(x => {
query: {
search: i18nReplacer.pattern.toString(),
replace: 'i18nReplacement',
- i18n: true
+ i18n: true,
+ lang
}
}, {
loader: 'replace',
@@ -216,7 +217,8 @@ module.exports = entries.map(x => {
query: {
search: i18nReplacer.pattern.toString(),
replace: 'i18nReplacement',
- i18n: true
+ i18n: true,
+ lang
}
}, {
loader: 'replace',
diff --git a/webpack/loaders/replace.js b/webpack/loaders/replace.js
index 9897fe37d5..0326dcdab3 100644
--- a/webpack/loaders/replace.js
+++ b/webpack/loaders/replace.js
@@ -11,7 +11,8 @@ module.exports = function(src) {
const g = search[search.length - 1] == 'g';
const file = this.resourcePath.replace(/\\/g, '/');
const replace = options.i18n ? global[options.replace].bind(null, {
- src: file
+ src: file,
+ lang: options.lang
}) : global[options.replace];
if (typeof search != 'string' || search.length == 0) console.error('invalid search');
if (typeof replace != 'function') console.error('invalid replacer:', replace, this.request);