-
-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add i18n support (en and fr bundled for now)
- Loading branch information
1 parent
a8e7a63
commit daad756
Showing
22 changed files
with
211 additions
and
109 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import { format, parse, toDate } from 'date-fns' | ||
import localeFr from 'date-fns/locale/fr' | ||
|
||
export { localeFr } | ||
|
||
export const localeDateFormatFr = (date, dateFormat = 'D MMMM YYYY') => | ||
format(toDate(date), dateFormat, { locale: localeFr }) | ||
|
||
export const formatDayFr = day => localeDateFormatFr(day, 'ddd ll') | ||
|
||
export const formatMonthTitleFr = date => localeDateFormatFr(date, 'MMMM YYYY') | ||
|
||
export const formatWeekdayShortFr = day => | ||
localeFr.localize.weekday(day, { type: 'short' }).replace(/.$/, '') | ||
|
||
export const formatWeekdayLongFr = day => | ||
localeFr.localize.weekday(day, { type: 'long' }) | ||
|
||
// Fix this when date-fns has a first day of week | ||
export const getFirstDayOfWeekFr = () => 1 | ||
|
||
export const getMonthsFr = () => | ||
Array(12) | ||
.fill() | ||
.map((_, i) => localeFr.localize.months(i, { type: 'long' })) | ||
|
||
export const formatDateFr = (date, format = 'L') => | ||
localeDateFormatFr(date, format) | ||
|
||
export const parseDateFr = (str, format = 'L') => | ||
parse(str, format, new Date(), { locale: localeFr }) | ||
|
||
export const CalendarFr = { | ||
formatDay: formatDayFr, | ||
formatMonthTitle: formatMonthTitleFr, | ||
formatWeekdayShort: formatWeekdayShortFr, | ||
formatWeekdayLong: formatWeekdayLongFr, | ||
getFirstDayOfWeek: getFirstDayOfWeekFr, | ||
getMonths: getMonthsFr, | ||
formatDate: formatDateFr, | ||
parseDate: parseDateFr, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.