mirror of
https://github.com/umami-software/umami.git
synced 2026-02-04 04:37:11 +01:00
Date formatting using locale.
This commit is contained in:
parent
987fdfd57d
commit
ff854150ae
7 changed files with 48 additions and 36 deletions
23
lib/lang.js
Normal file
23
lib/lang.js
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
import enMessages from 'lang-compiled/en.json';
|
||||
import zhCNMessages from 'lang-compiled/zh-CN.json';
|
||||
import { format } from 'date-fns';
|
||||
import { enUS, zhCN } from 'date-fns/locale';
|
||||
|
||||
export const messages = {
|
||||
en: enMessages,
|
||||
'zh-CN': zhCNMessages,
|
||||
};
|
||||
|
||||
export const dateLocales = {
|
||||
en: enUS,
|
||||
'zh-CN': zhCN,
|
||||
};
|
||||
|
||||
export const menuOptions = [
|
||||
{ label: 'English', value: 'en', display: 'EN' },
|
||||
{ label: '中文 (Chinese Simplified)', value: 'zh-CN', display: '中文' },
|
||||
];
|
||||
|
||||
export function dateFormat(date, str, locale) {
|
||||
return format(date, str, { locale: dateLocales[locale] || enUS });
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue