From e695c60a1dbe692bd0d4b07cfcb0dbce96210234 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=BE=E3=81=A3=E3=81=A1=E3=82=83=E3=81=A8=E3=83=BC?= =?UTF-8?q?=E3=81=AB=E3=82=85?= <17376330+u1-liquid@users.noreply.github.com> Date: Sat, 7 Oct 2023 03:38:40 +0900 Subject: [PATCH] =?UTF-8?q?=E8=A1=A8=E7=A4=BA=E8=A8=80=E8=AA=9E=E3=81=8C?= =?UTF-8?q?=E8=A8=AD=E5=AE=9A=E3=81=95=E3=82=8C=E3=81=A6=E3=81=AA=E3=81=84?= =?UTF-8?q?=E5=A0=B4=E5=90=88=E3=80=81=E3=83=96=E3=83=A9=E3=82=A6=E3=82=B6?= =?UTF-8?q?=E3=81=AE=E8=A8=80=E8=AA=9E=E3=81=A8=E9=96=A2=E4=BF=82=E3=81=AA?= =?UTF-8?q?=E3=81=8F=E6=97=A5=E6=9C=AC=E8=AA=9E=E3=81=AB=E3=81=99=E3=82=8B?= =?UTF-8?q?=20(MisskeyIO#175)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/backend/src/server/web/boot.js | 18 ++---------------- packages/frontend/src/config.ts | 2 +- packages/sw/src/scripts/lang.ts | 2 +- 3 files changed, 4 insertions(+), 18 deletions(-) diff --git a/packages/backend/src/server/web/boot.js b/packages/backend/src/server/web/boot.js index 022dfab83..3e31b5d5f 100644 --- a/packages/backend/src/server/web/boot.js +++ b/packages/backend/src/server/web/boot.js @@ -34,17 +34,9 @@ //#region Detect language & fetch translations if (!localStorage.hasOwnProperty('locale')) { - const supportedLangs = LANGS; let lang = localStorage.getItem('lang'); - if (lang == null || !supportedLangs.includes(lang)) { - if (supportedLangs.includes(navigator.language)) { - lang = navigator.language; - } else { - lang = supportedLangs.find(x => x.split('-')[0] === navigator.language); - - // Fallback - if (lang == null) lang = 'en-US'; - } + if (lang == null || lang.toString == null || lang.toString() === 'null') { + lang = 'ja-JP'; } const metaRes = await window.fetch('/api/meta', { @@ -67,12 +59,6 @@ return; } - // for https://github.com/misskey-dev/misskey/issues/10202 - if (lang == null || lang.toString == null || lang.toString() === 'null') { - console.error('invalid lang value detected!!!', typeof lang, lang); - lang = 'en-US'; - } - const localRes = await window.fetch(`/assets/locales/${lang}.${v}.json`); if (localRes.status === 200) { localStorage.setItem('lang', lang); diff --git a/packages/frontend/src/config.ts b/packages/frontend/src/config.ts index 9ce3f8fa1..898d5b817 100644 --- a/packages/frontend/src/config.ts +++ b/packages/frontend/src/config.ts @@ -13,7 +13,7 @@ export const hostname = address.hostname; export const url = address.origin; export const apiUrl = url + '/api'; export const wsUrl = url.replace('http://', 'ws://').replace('https://', 'wss://') + '/streaming'; -export const lang = miLocalStorage.getItem('lang') ?? 'en-US'; +export const lang = miLocalStorage.getItem('lang') ?? 'ja-JP'; export const langs = _LANGS_; const preParseLocale = miLocalStorage.getItem('locale'); export let locale = preParseLocale ? JSON.parse(preParseLocale) : null; diff --git a/packages/sw/src/scripts/lang.ts b/packages/sw/src/scripts/lang.ts index dbe25130b..c8ce36531 100644 --- a/packages/sw/src/scripts/lang.ts +++ b/packages/sw/src/scripts/lang.ts @@ -13,7 +13,7 @@ class SwLang { public cacheName = `mk-cache-${_VERSION_}`; public lang: Promise = get('lang').then(async prelang => { - if (!prelang) return 'en-US'; + if (!prelang) return 'ja-JP'; return prelang; });