- add multiple languages

- switch from moment to dayjs
This commit is contained in:
Amruth Pillai
2020-07-21 11:07:19 +05:30
parent e4f40f04ff
commit 7aab7c74f6
28 changed files with 255 additions and 416 deletions

14
src/utils/dayjs.js Normal file
View File

@ -0,0 +1,14 @@
import dayjs from 'dayjs';
import 'dayjs/locale/da';
import 'dayjs/locale/de';
import 'dayjs/locale/en';
import 'dayjs/locale/es';
import 'dayjs/locale/fi';
import 'dayjs/locale/fr';
import 'dayjs/locale/kn';
import 'dayjs/locale/nl';
import 'dayjs/locale/pt';
import 'dayjs/locale/tr';
import relativeTime from 'dayjs/plugin/relativeTime';
dayjs.extend(relativeTime);

View File

@ -1,5 +1,5 @@
import dayjs from 'dayjs';
import { get, isEmpty } from 'lodash';
import moment from 'moment/min/moment-with-locales';
import { useTranslation } from 'react-i18next';
export const getModalText = (isEditMode, type) => {
@ -25,12 +25,12 @@ export const isFileImage = (file) => {
export const formatDateRange = ({ startDate, endDate }) => {
const { i18n } = useTranslation();
const start = `${moment(startDate)
const start = `${dayjs(startDate)
.locale(i18n.language.substr(0, 2))
.format('MMMM Y')}`;
.format('MMMM YYYY')}`;
const end = moment(endDate).isValid()
? `${moment(endDate).locale(i18n.language.substr(0, 2)).format('MMMM Y')}`
const end = dayjs(endDate).isValid()
? `${dayjs(endDate).locale(i18n.language.substr(0, 2)).format('MMMM YYYY')}`
: 'Present';
return `${start} - ${end}`;