Overview
Invenicum supports multiple languages out of the box with Flutter’s built-in internationalization (i18n) system. Users can switch languages on-the-fly, and all UI text adapts automatically.Supported Languages
Invenicum currently supports 6 languages:| Language | Code | Native Name |
|---|---|---|
| English | en | English |
| Spanish | es | Español |
| Italian | it | Italiano |
| Portuguese | pt | Português |
| French | fr | Français |
| German | de | Deutsch |
The default language is Spanish (
es), but this changes based on user preferences.Localization Configuration
l10n.yaml
The localization setup is defined inl10n.yaml:1-11:
pubspec.yaml
Localization dependencies are configured inpubspec.yaml:33-45:
main.dart
Localization delegates are registered inmain.dart:296-304:
Translation Files
Translation files are stored in ARB (Application Resource Bundle) format:ARB File Structure
File:lib/l10n/app_en.arb:1-493
Example entries:
Entries starting with
@ define metadata like placeholders. The actual translation follows with the same key minus the @.Changing Language
User Interface
Select Language
Click the dropdown and choose your preferred language:
- English
- Español (Spanish)
- Italiano (Italian)
- Português (Portuguese)
- Français (French)
- Deutsch (German)
Programmatic Usage
Preferences Provider:lib/providers/preferences_provider.dart
lib/data/services/preferences_service.dart:42-48
PUT /api/v1/preferences/language
Using Translations in Code
Access Localizations
Simple Strings
Strings with Placeholders
Integration-Specific Translations
Adding New Translations
Add to All Language Files
Add the same keys to all other ARB files:
app_es.arb:"myNewFeature": "Mi Nueva Función"app_it.arb:"myNewFeature": "La Mia Nuova Funzione"app_pt.arb:"myNewFeature": "Meu Novo Recurso"app_fr.arb:"myNewFeature": "Ma Nouvelle Fonctionnalité"app_de.arb:"myNewFeature": "Meine Neue Funktion"
Generate Code
Run Flutter’s code generator:Or simply build/run the app:This generates
lib/l10n/app_localizations.dart and language-specific classes.Adding a New Language
Update Language Dropdown
Add the language option to the language selection UI in your settings screen.
RTL (Right-to-Left) Support
To add RTL support in the future:- Add RTL locale to
l10n.yaml(e.g.,arfor Arabic) - Create ARB file with translations
- Flutter automatically handles text direction based on locale
- Test all UI layouts for RTL compatibility
Best Practices
Missing translations: The
missing_translations.txt file will list any keys missing from language files after code generation.Generated Files
Do not edit these files manually (they’re auto-generated):lib/l10n/app_localizations.dart- Base classlib/l10n/app_localizations_en.dart- Englishlib/l10n/app_localizations_es.dart- Spanishlib/l10n/app_localizations_it.dart- Italianlib/l10n/app_localizations_pt.dart- Portugueselib/l10n/app_localizations_fr.dart- Frenchlib/l10n/app_localizations_de.dart- German
