From 6670104be395915d84688ee529d78d91bf81a416 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Qu=E1=BB=91c=20Kh=C3=A1nh?= Date: Mon, 10 Jun 2024 05:12:26 +0700 Subject: [PATCH] feat(mobile): setup lingui (#63) Resolves https://github.com/sixpm-ai/6pm/issues/26 --- .babelrc | 3 + apps/mobile/app/(app)/(tabs)/_layout.tsx | 9 +- apps/mobile/app/(app)/(tabs)/settings.tsx | 46 +- apps/mobile/app/(app)/_layout.tsx | 11 +- apps/mobile/app/(app)/appearance.tsx | 25 +- apps/mobile/app/(app)/language.tsx | 37 + apps/mobile/app/(auth)/login.tsx | 43 +- apps/mobile/app/+not-found.tsx | 21 +- apps/mobile/app/_layout.tsx | 43 +- apps/mobile/babel.config.js | 12 +- apps/mobile/components/auth/auth-email.tsx | 18 +- apps/mobile/components/auth/auth-social.tsx | 9 +- apps/mobile/components/common/menu-item.tsx | 34 + apps/mobile/components/common/toolbar.tsx | 5 +- apps/mobile/components/home/header.tsx | 5 +- apps/mobile/index.js | 7 +- apps/mobile/locales/en/messages.po | 149 ++++ apps/mobile/locales/en/messages.ts | 1 + apps/mobile/locales/provider.tsx | 68 ++ apps/mobile/locales/vi/messages.po | 149 ++++ apps/mobile/locales/vi/messages.ts | 1 + apps/mobile/package.json | 6 + lingui.config.js | 12 + package.json | 22 +- pnpm-lock.yaml | 762 +++++++++++++++++++- 25 files changed, 1388 insertions(+), 110 deletions(-) create mode 100644 .babelrc create mode 100644 apps/mobile/app/(app)/language.tsx create mode 100644 apps/mobile/components/common/menu-item.tsx create mode 100644 apps/mobile/locales/en/messages.po create mode 100644 apps/mobile/locales/en/messages.ts create mode 100644 apps/mobile/locales/provider.tsx create mode 100644 apps/mobile/locales/vi/messages.po create mode 100644 apps/mobile/locales/vi/messages.ts create mode 100644 lingui.config.js diff --git a/.babelrc b/.babelrc new file mode 100644 index 00000000..0cfbbd83 --- /dev/null +++ b/.babelrc @@ -0,0 +1,3 @@ +{ + "plugins": ["macros"] +} diff --git a/apps/mobile/app/(app)/(tabs)/_layout.tsx b/apps/mobile/app/(app)/(tabs)/_layout.tsx index a4cb1631..563f0aa3 100644 --- a/apps/mobile/app/(app)/(tabs)/_layout.tsx +++ b/apps/mobile/app/(app)/(tabs)/_layout.tsx @@ -1,10 +1,13 @@ import { useColorScheme } from '@/hooks/useColorScheme' import { theme } from '@/lib/theme' +import { t } from '@lingui/macro' +import { useLingui } from '@lingui/react' import { Tabs } from 'expo-router' import { CogIcon, LandPlotIcon, ScanTextIcon, WalletIcon } from 'lucide-react-native' export default function TabLayout() { const colorScheme = useColorScheme() + const { i18n } = useLingui() return ( , }} @@ -44,7 +47,7 @@ export default function TabLayout() { , }} @@ -52,7 +55,7 @@ export default function TabLayout() { , }} diff --git a/apps/mobile/app/(app)/(tabs)/settings.tsx b/apps/mobile/app/(app)/(tabs)/settings.tsx index cd21d08c..11e96c3f 100644 --- a/apps/mobile/app/(app)/(tabs)/settings.tsx +++ b/apps/mobile/app/(app)/(tabs)/settings.tsx @@ -2,14 +2,20 @@ import { Avatar, AvatarFallback, AvatarImage } from '@/components/Avatar' import { Badge } from '@/components/Badge' import { Button } from '@/components/Button' import { IconButton } from '@/components/IconButton' +import { MenuItem } from '@/components/common/menu-item' +import { useLocale } from '@/locales/provider' import { useAuth, useUser } from '@clerk/clerk-expo' +import { t } from '@lingui/macro' +import { useLingui } from '@lingui/react' import { Link } from 'expo-router' -import { LogOutIcon, PencilIcon, SwatchBookIcon } from 'lucide-react-native' +import { ChevronRightIcon, EarthIcon, LogOutIcon, PencilIcon, SwatchBookIcon } from 'lucide-react-native' import { Alert, ScrollView, Text, View } from 'react-native' export default function SettingsScreen() { const { signOut } = useAuth() const { user } = useUser() + const { i18n } = useLingui() + const { language } = useLocale() return ( @@ -40,30 +46,44 @@ export default function SettingsScreen() { - App settings + {t(i18n)`App settings`} -