# Localization Setup Guide ## Overview Ứng dụng đã được cấu hình hỗ trợ 2 ngôn ngữ: **English (en)** và **Tiếng Việt (vi)** sử dụng `expo-localization` và `i18n-js`. ## Cấu trúc thư mục ``` /config /localization - i18n.ts # Cấu hình i18n (khởi tạo locale, enable fallback, etc.) - localization.ts # Export main exports /locales - en.json # Các string tiếng Anh - vi.json # Các string tiếng Việt /hooks - use-i18n.ts # Hook để sử dụng i18n trong components /state - use-locale-store.ts # Zustand store cho global locale state management ``` ## Cách sử dụng ### 1. Import i18n hook trong component ```tsx import { useI18n } from "@/hooks/use-i18n"; export default function MyComponent() { const { t, locale, setLocale } = useI18n(); return ( {t("common.ok")} {t("navigation.home")} Current locale: {locale} ); } ``` ### 2. Thêm translation keys #### Mở file `/locales/en.json` và thêm: ```json { "myFeature": { "title": "My Feature Title", "description": "My Feature Description" } } ``` #### Mở file `/locales/vi.json` và thêm translation tương ứng: ```json { "myFeature": { "title": "Tiêu đề Tính năng Của Tôi", "description": "Mô tả Tính năng Của Tôi" } } ``` ### 3. Sử dụng trong component ```tsx const { t } = useI18n(); return {t("myFeature.title")}; ``` ## Cách thay đổi ngôn ngữ ```tsx const { setLocale } = useI18n(); // Thay đổi sang Tiếng Việt