localization
Apply when adding, modifying, or fixing localized strings in Flutter projects using .arb files.
Files1
View on GitHubSKILL.mdskills/flutter/localization/SKILL.md
GitHubFlutter Localization (ARB-based)
Context
Apply when adding, modifying, or fixing localized strings in Flutter projects using .arb files.
Instructions
- Never hardcode user-facing strings — always use localization keys.
- ARB file structure: One
.arbfile per locale (e.g.,app_en.arb,app_zh.arb). - Key naming: Use
camelCase, prefixed by feature:walletSendTitle,walletGasFeeLabel,profileEditButton
- Placeholders: Define placeholders with types in the
@keymetadata:"walletBalance": "Balance: {amount} {unit}", "@walletBalance": { "placeholders": { "amount": { "type": "String" }, "unit": { "type": "String" } } } - Parameter ordering: Ensure call-sites pass arguments in the same order as declared in the
@keyplaceholders. Mismatched order is a common source of bugs. - Always update ALL locale files when adding a new key.
- Run code generation after modifying
.arbfiles:flutter gen-l10n
Examples
Adding a new key
// app_en.arb
"gasFeeValue": "Fee {value} {unit}",
"@gasFeeValue": {
"placeholders": {
"value": { "type": "String" },
"unit": { "type": "String" }
}
}
// Usage in widget
Text(context.l10n.gasFeeValue(fee.value, fee.unit))
Anti-patterns
- ❌ Hardcoded strings in widgets
- ❌ Mismatched parameter order between
.arbdefinition and call-site - ❌ Adding keys to only one locale file
- ❌ Using string interpolation instead of ARB placeholders
Resources
- https://docs.flutter.dev/ui/internationalization
- https://docs.flutter.dev/release/breaking-changes/flutter-generate-i10n-source
- https://docs.flutter.dev/release/breaking-changes/material-localized-strings
- https://docs.flutter.dev/release/breaking-changes/text-field-material-localizations
- https://docs.flutter.dev/release/breaking-changes/cupertino-tab-bar-localizations