summaryrefslogtreecommitdiff
path: root/packages/frontend/src/scripts
diff options
context:
space:
mode:
authorかっこかり <67428053+kakkokari-gtyih@users.noreply.github.com>2023-10-28 07:56:24 +0900
committerGitHub <noreply@github.com>2023-10-28 07:56:24 +0900
commitc37616de722bc2bc51aa93510abce396b77449f7 (patch)
treeaf5da9b0198f359ebd94e27401c651cacf8deecc /packages/frontend/src/scripts
parentenhance: プラグイン削除時にアクセストークンも削除する (... (diff)
downloadsharkey-c37616de722bc2bc51aa93510abce396b77449f7.tar.gz
sharkey-c37616de722bc2bc51aa93510abce396b77449f7.tar.bz2
sharkey-c37616de722bc2bc51aa93510abce396b77449f7.zip
fix(frontend): Intlが対応していない言語の場合はフォールバックする (#12163)
* (fix) Intlが対応していない言語の場合はフォールバックする * Update Changelog
Diffstat (limited to 'packages/frontend/src/scripts')
-rw-r--r--packages/frontend/src/scripts/intl-const.ts47
1 files changed, 38 insertions, 9 deletions
diff --git a/packages/frontend/src/scripts/intl-const.ts b/packages/frontend/src/scripts/intl-const.ts
index 8012a677ef..ea16c9c2ae 100644
--- a/packages/frontend/src/scripts/intl-const.ts
+++ b/packages/frontend/src/scripts/intl-const.ts
@@ -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;