fix(boot): meta problem

This commit is contained in:
무라쿠모 2024-07-25 20:09:14 +09:00
parent 8104a87c69
commit ce1f3c9f88
No known key found for this signature in database
GPG key ID: 139D6573F92DA9F7

View file

@ -32,21 +32,6 @@
renderError('FORCED_ERROR', 'This error is forced by having forceError in local storage.') renderError('FORCED_ERROR', 'This error is forced by having forceError in local storage.')
} }
//#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 = 'ko-KR';
}
}
const metaRes = await window.fetch('/api/meta', { const metaRes = await window.fetch('/api/meta', {
method: 'POST', method: 'POST',
body: JSON.stringify({}), body: JSON.stringify({}),
@ -67,6 +52,21 @@
return; return;
} }
//#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 = 'ko-KR';
}
}
// for https://github.com/misskey-dev/misskey/issues/10202 // for https://github.com/misskey-dev/misskey/issues/10202
if (lang == null || lang.toString == null || lang.toString() === 'null') { if (lang == null || lang.toString == null || lang.toString() === 'null') {
console.error('invalid lang value detected!!!', typeof lang, lang); console.error('invalid lang value detected!!!', typeof lang, lang);