add en/vi language

This commit is contained in:
Tran Anh Tuan
2025-11-15 16:58:07 +07:00
parent 1a534eccb0
commit e725819c01
31 changed files with 1843 additions and 232 deletions

View File

@@ -0,0 +1,27 @@
import en from "@/locales/en.json";
import vi from "@/locales/vi.json";
import { getLocales } from "expo-localization";
import { I18n } from "i18n-js";
// Set the key-value pairs for the different languages you want to support
const translations = {
en,
vi,
};
const i18n = new I18n(translations);
// Set the locale once at the beginning of your app
// This will be set from storage in the useI18n hook, default to device language or 'en'
i18n.locale = getLocales()[0].languageCode ?? "vi";
// Enable fallback mechanism - if a key is missing in the current language, it will use the key from English
i18n.enableFallback = true;
// Set default locale to English if no locale is available
i18n.defaultLocale = "vi";
// Storage key for locale preference
export const LOCALE_STORAGE_KEY = "app_locale_preference";
export default i18n;