mirror of
https://github.com/umami-software/umami.git
synced 2026-02-04 04:37:11 +01:00
Add timestamp localization
This commit is contained in:
parent
30ebf7b266
commit
e7b92cd097
2 changed files with 12 additions and 2 deletions
|
|
@ -118,6 +118,11 @@ export const dateLocales = {
|
|||
'it-IT': it,
|
||||
};
|
||||
|
||||
const timeFormats = {
|
||||
// https://date-fns.org/v2.17.0/docs/format
|
||||
'en-US': 'ha',
|
||||
};
|
||||
|
||||
export const menuOptions = [
|
||||
{ label: '中文', value: 'zh-CN', display: 'cn' },
|
||||
{ label: '中文(繁體)', value: 'zh-TW', display: 'tw' },
|
||||
|
|
@ -152,3 +157,7 @@ export const menuOptions = [
|
|||
export function dateFormat(date, str, locale) {
|
||||
return format(date, str, { locale: dateLocales[locale] || enUS });
|
||||
}
|
||||
|
||||
export function timeFormat(date, locale = 'en-US') {
|
||||
return format(date, timeFormats[locale] || 'p', { locale: dateLocales[locale] });
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue