jellyfish-web/src/scripts/dfnshelper.js

72 lines
1.4 KiB
JavaScript
Raw Normal View History

2021-01-24 21:41:46 +01:00
import { af, arDZ, be, bg, bn, ca, cs, da, de, el, enGB, enUS, eo, es, faIR, fi, fr, frCA, he, hi, hr, hu, gl, id, is, it, ja, kk, ko, lt, ms, nb,
nl, pl, ptBR, pt, ro, ru, sk, sl, sv, ta, th, tr, uk, vi, zhCN, zhTW } from 'date-fns/locale';
2020-08-14 08:46:34 +02:00
import globalize from './globalize';
const dateLocales = (locale) => ({
2020-12-29 11:28:11 -05:00
'af': af,
2020-11-26 01:39:36 -05:00
'ar': arDZ,
'be-by': be,
'bg-bg': bg,
2020-12-29 11:28:11 -05:00
'bn': bn,
'ca': ca,
'cs': cs,
'da': da,
'de': de,
'el': el,
'en-gb': enGB,
'en-us': enUS,
2020-12-29 11:28:11 -05:00
'eo': eo,
'es': es,
'es-ar': es,
2020-12-29 11:28:11 -05:00
'es-do': es,
'es-mx': es,
'fa': faIR,
'fi': fi,
'fr': fr,
'fr-ca': frCA,
2020-12-29 11:28:11 -05:00
'gl': gl,
'gsw': de,
'he': he,
'hi-in': hi,
'hr': hr,
'hu': hu,
'id': id,
2020-12-29 11:28:11 -05:00
'is': is,
'it': it,
'ja': ja,
'kk': kk,
'ko': ko,
'lt-lt': lt,
'ms': ms,
'nb': nb,
'nl': nl,
'pl': pl,
2020-12-29 11:28:11 -05:00
'pt': pt,
'pt-br': ptBR,
'pt-pt': pt,
'ro': ro,
'ru': ru,
'sk': sk,
'sl-si': sl,
'sv': sv,
2020-12-29 11:28:11 -05:00
'ta': ta,
'th': th,
'tr': tr,
'uk': uk,
'vi': vi,
'zh-cn': zhCN,
'zh-hk': zhCN,
'zh-tw': zhTW
})[locale];
export function getLocale() {
return dateLocales(globalize.getCurrentLocale()) || enUS;
}
export const localeWithSuffix = { addSuffix: true, locale: getLocale() };
export default {
getLocale: getLocale,
localeWithSuffix: localeWithSuffix
};