From dcbba8c812e18a47f5a1a7050d0b644643bf18b4 Mon Sep 17 00:00:00 2001 From: lamvh Date: Tue, 24 Sep 2024 13:48:54 +0700 Subject: [PATCH] fix(mobile): #283 localize dates when app language is changed --- apps/mobile/locales/provider.tsx | 3 +++ packages/utilities/src/date/dayjs.ts | 1 + 2 files changed, 4 insertions(+) diff --git a/apps/mobile/locales/provider.tsx b/apps/mobile/locales/provider.tsx index 5cee3fb9..66eff0ef 100644 --- a/apps/mobile/locales/provider.tsx +++ b/apps/mobile/locales/provider.tsx @@ -1,3 +1,4 @@ +import { dayjsExtended } from '@6pm/utilities' import { i18n } from '@lingui/core' import { I18nProvider } from '@lingui/react' import AsyncStorage from '@react-native-async-storage/async-storage' @@ -18,6 +19,8 @@ const defaultLanguage = ['en', 'vi'].includes(deviceLanguage) ? deviceLanguage : 'en' +dayjsExtended.locale(deviceLanguage) + const messages = { en: enMessages, vi: viMessages, diff --git a/packages/utilities/src/date/dayjs.ts b/packages/utilities/src/date/dayjs.ts index adda2572..e61ff797 100644 --- a/packages/utilities/src/date/dayjs.ts +++ b/packages/utilities/src/date/dayjs.ts @@ -1,6 +1,7 @@ import dayjsExtended from 'dayjs' import isoWeek from 'dayjs/plugin/isoWeek' import quarterOfYear from 'dayjs/plugin/quarterOfYear' +import 'dayjs/locale/vi' dayjsExtended.extend(isoWeek) dayjsExtended.extend(quarterOfYear)