|
@@ -1,9 +1,7 @@
|
|
|
import { formatDistanceToNow } from 'date-fns';
|
|
import { formatDistanceToNow } from 'date-fns';
|
|
|
import { useTranslation } from 'next-i18next';
|
|
import { useTranslation } from 'next-i18next';
|
|
|
-import {
|
|
|
|
|
- enUS, ja, fr, ko, zhCN, Locale,
|
|
|
|
|
-} from 'date-fns/locale';
|
|
|
|
|
-
|
|
|
|
|
|
|
+import { type Locale } from 'date-fns/locale';
|
|
|
|
|
+import { getLocale } from '~/client/util/date-local';
|
|
|
import type { ActivityHasUserId, SupportedActivityActionType } from '~/interfaces/activity';
|
|
import type { ActivityHasUserId, SupportedActivityActionType } from '~/interfaces/activity';
|
|
|
import { ActivityLogActions } from '~/interfaces/activity';
|
|
import { ActivityLogActions } from '~/interfaces/activity';
|
|
|
|
|
|
|
@@ -38,39 +36,6 @@ export const IconActivityTranslationMap: Record<
|
|
|
[ActivityLogActions.ACTION_COMMENT_CREATE]: 'comment',
|
|
[ActivityLogActions.ACTION_COMMENT_CREATE]: 'comment',
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
-const localeMap: Record<string, Locale | undefined> = {
|
|
|
|
|
- en: enUS,
|
|
|
|
|
- 'en-US': enUS,
|
|
|
|
|
- en_US: enUS,
|
|
|
|
|
-
|
|
|
|
|
- ja,
|
|
|
|
|
- 'ja-JP': ja,
|
|
|
|
|
- ja_JP: ja,
|
|
|
|
|
-
|
|
|
|
|
- fr,
|
|
|
|
|
- 'fr-FR': fr,
|
|
|
|
|
- fr_FR: fr,
|
|
|
|
|
-
|
|
|
|
|
- ko,
|
|
|
|
|
- 'ko-KR': ko,
|
|
|
|
|
- ko_KR: ko,
|
|
|
|
|
-
|
|
|
|
|
- zh: zhCN,
|
|
|
|
|
- 'zh-CN': zhCN,
|
|
|
|
|
- zh_CN: zhCN,
|
|
|
|
|
-};
|
|
|
|
|
-
|
|
|
|
|
-const getLocale = (langCode: string): Locale => {
|
|
|
|
|
- let locale = localeMap[langCode];
|
|
|
|
|
-
|
|
|
|
|
- if (!locale) {
|
|
|
|
|
- const baseCode = langCode.split('-')[0];
|
|
|
|
|
- locale = localeMap[baseCode];
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- return locale ?? enUS;
|
|
|
|
|
-};
|
|
|
|
|
-
|
|
|
|
|
const translateAction = (action: SupportedActivityActionType): string => {
|
|
const translateAction = (action: SupportedActivityActionType): string => {
|
|
|
return ActivityActionTranslationMap[action] || 'unknown_action';
|
|
return ActivityActionTranslationMap[action] || 'unknown_action';
|
|
|
};
|
|
};
|