Skip to content
Snippets Groups Projects
Unverified Commit c37616de authored by かっこかり's avatar かっこかり Committed by GitHub
Browse files

fix(frontend): Intlが対応していない言語の場合はフォールバックする (#12163)

* (fix) Intlが対応していない言語の場合はフォールバックする

* Update Changelog
parent e5ff8d84
No related branches found
No related tags found
No related merge requests found
......@@ -26,6 +26,7 @@
- Enhance: プラグインを削除した際には、使用されていたアクセストークンも同時に削除されるようになりました
- Fix: 投稿フォームでのユーザー変更がプレビューに反映されない問題を修正
- Fix: ユーザーページの ノート > ファイル付き タブにリプライが表示されてしまう
- Fix: 一部の言語でMisskey Webがクラッシュする問題を修正
### Server
- Enhance: RedisへのTLのキャッシュをオフにできるように
......
......@@ -6,12 +6,41 @@
import { lang } from '@/config.js';
export const versatileLang = (lang ?? 'ja-JP').replace('ja-KS', 'ja-JP');
export const dateTimeFormat = new Intl.DateTimeFormat(versatileLang, {
year: 'numeric',
month: 'numeric',
day: 'numeric',
hour: 'numeric',
minute: 'numeric',
second: 'numeric',
});
export const numberFormat = new Intl.NumberFormat(versatileLang);
let _dateTimeFormat: Intl.DateTimeFormat;
try {
_dateTimeFormat = new Intl.DateTimeFormat(versatileLang, {
year: 'numeric',
month: 'numeric',
day: 'numeric',
hour: 'numeric',
minute: 'numeric',
second: 'numeric',
});
} catch (err) {
console.warn(err);
if (_DEV_) console.log('[Intl] Fallback to en-US');
// Fallback to en-US
_dateTimeFormat = new Intl.DateTimeFormat('en-US', {
year: 'numeric',
month: 'numeric',
day: 'numeric',
hour: 'numeric',
minute: 'numeric',
second: 'numeric',
});
}
export const dateTimeFormat = _dateTimeFormat;
let _numberFormat: Intl.NumberFormat;
try {
_numberFormat = new Intl.NumberFormat(versatileLang);
} catch (err) {
console.warn(err);
if (_DEV_) console.log('[Intl] Fallback to en-US');
// Fallback to en-US
_numberFormat = new Intl.NumberFormat('en-US');
}
export const numberFormat = _numberFormat;
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment