feat: Flutter client localisation (12 languages)
Add flutter_localizations + intl, 12 ARB files (en/ru/es/de/fr/it/pt/zh/ja/ko/ar/hi), replace all hardcoded Russian UI strings with AppLocalizations, detect system locale on first launch, localise bottom nav bar labels, document rule in CLAUDE.md. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
50
CLAUDE.md
50
CLAUDE.md
@@ -91,3 +91,53 @@ Single- or two-letter names are only allowed when the abbreviation *is* the full
|
||||
This rule applies to all languages in this repo (Go and Dart).
|
||||
In Go, name variables to avoid shadowing the `error` built-in and the `context` package —
|
||||
use descriptive prefixes: `parseError`, `requestContext`, etc.
|
||||
|
||||
## Flutter Client Localisation
|
||||
|
||||
**Rule:** Every UI string in `client/` must go through `AppLocalizations`.
|
||||
Never hardcode user-visible text in Dart source files.
|
||||
|
||||
### Current setup
|
||||
|
||||
- `flutter_localizations` (sdk: flutter) + `intl: ^0.20.2` in `client/pubspec.yaml`
|
||||
- `generate: true` under `flutter:` in `client/pubspec.yaml`
|
||||
- `client/l10n.yaml` — generator config (arb-dir, template-arb-file, output-class)
|
||||
- Generated class: `package:food_ai/l10n/app_localizations.dart`
|
||||
|
||||
### Supported languages
|
||||
|
||||
`en`, `ru`, `es`, `de`, `fr`, `it`, `pt`, `zh`, `ja`, `ko`, `ar`, `hi`
|
||||
|
||||
### ARB files
|
||||
|
||||
All translation files live in `client/lib/l10n/`:
|
||||
|
||||
- `app_en.arb` — English (template / canonical)
|
||||
- `app_ru.arb`, `app_es.arb`, `app_de.arb`, `app_fr.arb`, `app_it.arb`
|
||||
- `app_pt.arb`, `app_zh.arb`, `app_ja.arb`, `app_ko.arb`, `app_ar.arb`, `app_hi.arb`
|
||||
|
||||
### Usage pattern
|
||||
|
||||
```dart
|
||||
import 'package:food_ai/l10n/app_localizations.dart';
|
||||
|
||||
// Inside build():
|
||||
final l10n = AppLocalizations.of(context)!;
|
||||
Text(l10n.someKey)
|
||||
```
|
||||
|
||||
### Adding new strings
|
||||
|
||||
1. Add the key + English value to `client/lib/l10n/app_en.arb` (template file).
|
||||
2. Add the same key with the correct translation to **all other 11 ARB files**.
|
||||
3. Run `flutter gen-l10n` inside `client/` to regenerate `AppLocalizations`.
|
||||
4. Use `l10n.<newKey>` in the widget.
|
||||
|
||||
For parameterised strings use the ICU placeholder syntax in ARB files:
|
||||
|
||||
```json
|
||||
"queuePosition": "Position {position}",
|
||||
"@queuePosition": { "placeholders": { "position": { "type": "int" } } }
|
||||
```
|
||||
|
||||
Then call `l10n.queuePosition(n)` in Dart.
|
||||
|
||||
Reference in New Issue
Block a user