umami/lib/lang.js

44 lines
1.4 KiB
JavaScript
Raw Normal View History

import { format } from 'date-fns';
2020-09-12 05:49:41 +02:00
import { enUS, nl, zhCN, tr, ru, de, ja } from 'date-fns/locale';
2020-09-12 12:49:31 +02:00
import enMessages from 'lang-compiled/en-US.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';
2020-09-08 23:01:26 +02:00
import trTRMessages from 'lang-compiled/tr-TR.json';
2020-09-09 17:13:27 +02:00
import ruRUMessages from 'lang-compiled/ru-RU.json';
2020-09-09 19:24:55 +02:00
import deDEMessages from 'lang-compiled/de-DE.json';
2020-09-12 05:49:41 +02:00
import jaMessages from 'lang-compiled/ja-JP.json';
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,
2020-09-09 19:24:55 +02:00
'de-DE': deDEMessages,
2020-09-09 17:13:27 +02:00
'ru-RU': ruRUMessages,
2020-09-08 23:01:26 +02:00
'tr-TR': trTRMessages,
2020-09-12 05:49:41 +02:00
'ja-JP': jaMessages,
2020-09-08 04:48:40 +02:00
};
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,
2020-09-09 19:24:55 +02:00
'de-DE': de,
2020-09-09 17:13:27 +02:00
'ru-RU': ru,
2020-09-08 23:01:26 +02:00
'tr-TR': tr,
2020-09-12 05:49:41 +02:00
'ja-JP': ja,
2020-09-08 04:48:40 +02:00
};
export const menuOptions = [
{ label: 'English', value: 'en', display: 'EN' },
{ label: '中文 (Chinese Simplified)', value: 'zh-CN', display: '中文' },
{ label: 'Nederlands (Dutch)', value: 'nl-NL', display: 'NL' },
2020-09-12 12:22:14 +02:00
{ label: 'Deutsch (German)', value: 'de-DE', display: 'DE' },
{ label: '日本語 (Japanese)', value: 'ja-JP', display: '日本語' },
{ label: 'Русский (Russian)', value: 'ru-RU', display: 'РУ' },
2020-09-08 23:01:26 +02:00
{ label: 'Turkish', value: 'tr-TR', display: 'TR' },
2020-09-08 04:48:40 +02:00
];
export function dateFormat(date, str, locale) {
return format(date, str, { locale: dateLocales[locale] || enUS });
}