feat: Enhance localization compliance by enforcing usage of localized keys for user-facing strings and updating related documentation
This commit is contained in:
@@ -266,11 +266,29 @@ design_system/
|
||||
- Export `TranslationProvider` for `context.strings` access
|
||||
- Map domain failures to localized error messages via `ErrorTranslator`
|
||||
|
||||
**String Definition:**
|
||||
- Strings are defined in `packages/core_localization/lib/src/l10n/en.i18n.json` (English) and `es.i18n.json` (Spanish)
|
||||
- Both files MUST be updated together when adding/modifying strings
|
||||
- Generated output: `strings.g.dart`, `strings_en.g.dart`, `strings_es.g.dart`
|
||||
- Regenerate with: `cd packages/core_localization && dart run slang`
|
||||
|
||||
**Feature Integration:**
|
||||
```dart
|
||||
// Features access strings
|
||||
Text(context.strings.loginButton)
|
||||
// ✅ CORRECT: Access via Slang's global `t` accessor
|
||||
import 'package:core_localization/core_localization.dart';
|
||||
|
||||
Text(t.client_create_order.review.invalid_arguments)
|
||||
Text(t.errors.order.creation_failed)
|
||||
|
||||
// ❌ FORBIDDEN: Hardcoded user-facing strings
|
||||
Text('Invalid review arguments') // Must use localized key
|
||||
Text('Order created!') // Must use localized key
|
||||
```
|
||||
|
||||
**RESTRICTION:** ALL user-facing strings in the presentation layer (Text widgets, SnackBars, AppBar titles, hints, labels, error messages, dialogs) MUST use localized keys via `t.<section>.<key>`. No hardcoded English or Spanish strings.
|
||||
|
||||
**BLoC Error Flow:**
|
||||
```dart
|
||||
// BLoCs emit domain failures (not strings)
|
||||
emit(AuthError(InvalidCredentialsFailure()));
|
||||
|
||||
@@ -879,6 +897,11 @@ Navigator.push(context, MaterialPageRoute(...)); // ← Use Modular
|
||||
Modular.to.navigate('/profile'); // ← Use safe extensions
|
||||
```
|
||||
|
||||
❌ **Hardcoded user-facing strings**
|
||||
```dart
|
||||
Text('Order created successfully!'); // ← Use t.section.key from core_localization
|
||||
```
|
||||
|
||||
## Summary
|
||||
|
||||
The architecture enforces:
|
||||
|
||||
Reference in New Issue
Block a user