// Smart App City — Internationalization (i18n) import i18n from 'i18next'; import { initReactI18next } from 'react-i18next'; import * as Localization from 'expo-localization'; import { translations, Language } from '../stores/uiStore'; // Build i18next resources from our translation map const resources: Record }> = {}; for (const [lang, trans] of Object.entries(translations)) { resources[lang] = { translation: trans }; } i18n .use(initReactI18next) .init({ resources, lng: Localization.locale?.split('-')[0] ?? 'fr', fallbackLng: 'fr', interpolation: { escapeValue: false }, }); export default i18n; // Helper: change language at runtime export const changeLanguage = (lang: Language) => { return i18n.changeLanguage(lang); }; // Helper: get current language export const getCurrentLanguage = (): Language => { return (i18n.language?.split('-')[0] as Language) ?? 'fr'; };