Overview
Estudio Three supports 4 languages out of the box:- 🇪🇸 Spanish (ES) — Default
- 🇬🇧 English (EN) — Fallback
- 🇫🇷 French (FR)
- 🇮🇹 Italian (IT)
Technology Stack
| Package | Purpose |
|---|---|
i18next | Core i18n framework |
react-i18next | React bindings (hooks, components) |
i18next-browser-languagedetector | Auto-detect browser language |
Configuration
i18n Setup
Initialization Flow
-
Language Detection:
LanguageDetectorchecks (in order):localStorage(key:i18nextLng)- URL query parameter (
?lng=en) - Browser language (
navigator.language) - Fallback to
en
-
Settings Override: If user set language in Settings, load from
focus-settings-storage -
React Integration:
initReactI18nextprovidesuseTranslationhook and<Trans>component
Translation File Structure
File Organization
JSON Structure
Translations are organized by feature/page:Nested Keys
Use dot notation for nested access:Usage in Components
useTranslation Hook
Interpolation (Variables)
Pluralization
Trans Component (for HTML)
Language Switching
Settings Store Integration
Language Selector Component
Language Detection
Detection Order
i18next-browser-languagedetector checks sources in this order:
- localStorage (
i18nextLngkey) - sessionStorage (
i18nextLngkey) - URL query parameter (
?lng=en) - URL path (
/en/dashboard) - Cookie (
i18nextcookie) - Browser language (
navigator.language) - Fallback (
en)
Custom Detection Logic
Estudio Three adds custom logic ini18n.ts:
Adding a New Language
Step 1: Create Translation File
de.json.
Step 2: Import in i18n.ts
Step 3: Add to Language Selector
Step 4: Update TypeScript Types (Optional)
Translation Management
Finding Missing Translations
Usei18next-parser to extract translation keys from code:
.ts/.tsx files for t('...') calls and updates JSON files.
Translation Validation
Check for missing keys across languages:RTL (Right-to-Left) Support
Adding Arabic
For RTL languages like Arabic, enable RTL mode:Tailwind RTL Plugin
Namespaces (Advanced)
Split translations into multiple namespaces for large apps:Performance Optimization
Lazy Load Translations
Load translation files on demand:Disable Suspense
Estudio Three disables suspense to avoid loading flickers:Testing Translations
Mock Translations in Tests
Test Language Switching
Common Patterns
Dynamic Keys
Arrays of Translations
Date/Number Formatting
Troubleshooting
Translation Not Updating
Symptoms: Changed translation in JSON but app still shows old text Solutions:- Hard refresh browser (
Ctrl+Shift+R/Cmd+Shift+R) - Clear localStorage (
localStorage.clear()) - Restart dev server (
npm run dev) - Check if key is correct (case-sensitive)
Language Stuck on English
Symptoms: App always shows English despite settings Solutions:- Check
focus-settings-storagein localStorage - Verify
setLanguage()is updating i18next:i18n.changeLanguage(lang) - Check browser console for i18next errors
- Ensure translation file is imported in
i18n.ts
Missing Translation Shows Key
Symptoms:tasks.addTask displayed instead of “Add Task”
Solutions:
- Translation key doesn’t exist in JSON file
- Check spelling and nesting (use dot notation)
- Ensure language file is loaded:
i18n.hasResourceBundle('en', 'translation') - Set
fallbackLngto show English if translation missing
Future Enhancements
Database-Backed Translations
The schema includes atranslations table for dynamic translations:
- User-submitted translations
- A/B testing copy changes
- Dynamic content translation
Supabase i18n Backend
Create a custom backend to load translations from Supabase:- Translations sync across devices instantly
- No app redeployment for copy changes
- Collaborative translation via UI