umami/lib/lang.js

28 lines
752 B
JavaScript
Raw Normal View History

2020-09-08 04:48:40 +02:00
import enMessages from 'lang-compiled/en.json';
import nlMessages from 'lang-compiled/nl-NL.json';
2020-09-08 04:48:40 +02:00
import zhCNMessages from 'lang-compiled/zh-CN.json';
import { format } from 'date-fns';
2020-09-08 09:42:43 +02:00
import { enUS, nl, zhCN } from 'date-fns/locale';
2020-09-08 04:48:40 +02:00
export const messages = {
en: enMessages,
2020-09-08 10:35:24 +02:00
'nl-NL': nlMessages,
2020-09-08 04:48:40 +02:00
'zh-CN': zhCNMessages,
};
export const dateLocales = {
en: enUS,
2020-09-08 10:35:24 +02:00
'nl-NL': nl,
2020-09-08 04:48:40 +02:00
'zh-CN': zhCN,
};
export const menuOptions = [
{ label: 'English', value: 'en', display: 'EN' },
2020-09-08 10:35:24 +02:00
{ label: 'Nederlands', value: 'nl-NL', display: 'NL' },
2020-09-08 04:48:40 +02:00
{ label: '中文 (Chinese Simplified)', value: 'zh-CN', display: '中文' },
];
export function dateFormat(date, str, locale) {
return format(date, str, { locale: dateLocales[locale] || enUS });
}