From fbc801d1dadfdc0d38298e153facbb34f70af13c Mon Sep 17 00:00:00 2001 From: syuilo Date: Wed, 12 Feb 2020 07:12:58 +0900 Subject: [PATCH] =?UTF-8?q?=E8=A8=80=E8=AA=9E=E5=88=87=E3=82=8A=E6=9B=BF?= =?UTF-8?q?=E3=81=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- locales/ja-JP.yml | 37 +++++++++++++++------------ src/client/init.ts | 22 ++++++++-------- src/client/pages/settings/general.vue | 21 ++++++++++++++- webpack.config.ts | 2 +- 4 files changed, 53 insertions(+), 29 deletions(-) diff --git a/locales/ja-JP.yml b/locales/ja-JP.yml index 5dbe603e4..e8c0b6957 100644 --- a/locales/ja-JP.yml +++ b/locales/ja-JP.yml @@ -1,20 +1,4 @@ -_ago: - unknown: "謎" - future: "未来" - justNow: "たった今" - secondsAgo: "{n}秒前" - minutesAgo: "{n}分前" - hoursAgo: "{n}時間前" - daysAgo: "{n}日前" - weeksAgo: "{n}週間前" - monthsAgo: "{n}ヶ月前" - yearsAgo: "{n}年前" - -_time: - second: "秒" - minute: "分" - hour: "時間" - day: "日" +_lang_: "日本語" introMisskey: "ようこそ!Misskeyは、オープンソースの分散型マイクロブログサービスです。\n「ノート」を作成して、いま起こっていることを共有したり、あなたについて皆に発信しよう📡\n「リアクション」機能で、皆のノートに素早く反応を追加することもできます👍\n新しい世界を探検しよう🚀" monthAndDay: "{month}月 {day}日" @@ -400,6 +384,25 @@ passwordNotMatched: "一致していません" signinWith: "{x}でログイン" tapSecurityKey: "セキュリティーキーにタッチ" or: "もしくは" +uiLanguage: "UIの表示言語" + +_ago: + unknown: "謎" + future: "未来" + justNow: "たった今" + secondsAgo: "{n}秒前" + minutesAgo: "{n}分前" + hoursAgo: "{n}時間前" + daysAgo: "{n}日前" + weeksAgo: "{n}週間前" + monthsAgo: "{n}ヶ月前" + yearsAgo: "{n}年前" + +_time: + second: "秒" + minute: "分" + hour: "時間" + day: "日" _tutorial: title: "Misskeyの使い方" diff --git a/src/client/init.ts b/src/client/init.ts index 9a9ba8be6..a3953dcd0 100644 --- a/src/client/init.ts +++ b/src/client/init.ts @@ -61,20 +61,22 @@ if (localStorage.getItem('theme') == null) { } //#region Detect the user language -let lang = null; +let lang = localStorage.getItem('lang'); -if (langs.map(x => x[0]).includes(navigator.language)) { - lang = navigator.language; -} else { - lang = langs.map(x => x[0]).find(x => x.split('-')[0] == navigator.language); +if (lang == null) { + if (langs.map(x => x[0]).includes(navigator.language)) { + lang = navigator.language; + } else { + lang = langs.map(x => x[0]).find(x => x.split('-')[0] == navigator.language); - if (lang == null) { - // Fallback - lang = 'en-US'; + if (lang == null) { + // Fallback + lang = 'en-US'; + } } -} -localStorage.setItem('lang', lang); + localStorage.setItem('lang', lang); +} //#endregion // Detect the user agent diff --git a/src/client/pages/settings/general.vue b/src/client/pages/settings/general.vue index 061838b44..90803636b 100644 --- a/src/client/pages/settings/general.vue +++ b/src/client/pages/settings/general.vue @@ -27,6 +27,13 @@ {{ $t('reduceUiAnimation') }} +
+ + + + + +
@@ -36,8 +43,9 @@ import { faImage, faCog } from '@fortawesome/free-solid-svg-icons'; import MkInput from '../../components/ui/input.vue'; import MkButton from '../../components/ui/button.vue'; import MkSwitch from '../../components/ui/switch.vue'; +import MkSelect from '../../components/ui/select.vue'; import i18n from '../../i18n'; -import { apiUrl } from '../../config'; +import { apiUrl, langs } from '../../config'; export default Vue.extend({ i18n, @@ -46,10 +54,13 @@ export default Vue.extend({ MkInput, MkButton, MkSwitch, + MkSelect, }, data() { return { + langs, + lang: localStorage.getItem('lang'), wallpaperUploading: false, faImage, faCog } @@ -72,6 +83,14 @@ export default Vue.extend({ }, }, + watch: { + lang() { + localStorage.setItem('lang', this.lang); + localStorage.removeItem('locale'); + location.reload(); + } + }, + methods: { onWallpaperChange([file]) { this.wallpaperUploading = true; diff --git a/webpack.config.ts b/webpack.config.ts index bec2093d5..df04767eb 100644 --- a/webpack.config.ts +++ b/webpack.config.ts @@ -124,7 +124,7 @@ module.exports = { }), new webpack.DefinePlugin({ _VERSION_: JSON.stringify(meta.version), - _LANGS_: JSON.stringify(Object.entries(locales).map(([k, v]: [string, any]) => [k, v && v.meta && v.meta.lang])), + _LANGS_: JSON.stringify(Object.entries(locales).map(([k, v]: [string, any]) => [k, v._lang_])), _ENV_: JSON.stringify(process.env.NODE_ENV) }), new VueLoaderPlugin(),