表示言語が設定されてない場合、ブラウザの言語と関係なく日本語にする (MisskeyIO#175)

This commit is contained in:
まっちゃとーにゅ 2023-10-07 03:38:40 +09:00 committed by GitHub
parent a296a35460
commit e695c60a1d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 4 additions and 18 deletions

View file

@ -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);