internationalization
Skill168 starsChanged 3 months agoMITView on GitHub
Best practices for internationalization (i18n) and localization (l10n) in Flutter, using the built-in `flutter_localizations` and `intl` setup with ARB files as the single source of truth. Use when adding, modifying, or reviewing ARB translations, locale setup (`l10n.yaml`, `generate: true` in `pubspec.yaml`, `flutter gen-l10n`, `localizationsDelegates`, `supportedLocales`), BuildContext l10n extensions such as `context.l10n`, hardcoded user-facing strings that should be localized, localized strings passed into shared or reusable widgets, or RTL/directional layout support with `EdgeInsetsDirectional`. Also use when asked to add or configure any third-party i18n or translation package (easy_localization, slang, flutter_i18n, or intl_utils), and when shipping or fixing a screen for a right-to-left language such as Arabic, Hebrew, Farsi, or Urdu, including mirroring padding, alignment, icons, or images, and replacing `EdgeInsets` left/right.
1 other project uses a version of this.
Adopted by
Most recently taken up by
- ffsshhttiikk/opencode-agents-skillstheir own version, first seen Feb 28, 2026
Other versions1 project uses a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 1
- ffsshhttiikk/opencode-agents-skills★ 2same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository16 other files it gives its agents.
- AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- accessibilitySkill
- animationsSkill
- blocSkill
- create-projectSkill
- dart-flutter-sdk-upgradeSkill
- green-gateSkill
- layered-architectureSkill
- license-complianceSkill
- material-themingSkill
- navigationSkill
- static-securitySkill
- testingSkill
- ui-packageSkill
- very-good-analysis-upgradeSkill
The file
We split this skill into the rules it gives an agent
9 rules. About 0 are common, 4 are distinctive, and 5 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈4
Distinctive · estimate
This author's own choices. Worth a look.
5
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 40
Add flutter_localizations and intl as dependencies, enable generate: true in pubspec.yaml, configure l10n.yaml, create ARB files in …
- Distinctive: line 44
Create an extension for ergonomic l10n access throughout the codebase:
- Very specific: line 104
Use EdgeInsetsDirectional (start/end) instead of EdgeInsets (left/right) for all padding and margins.
- Very specific: line 114
Create app_<locale>.arb in lib/l10n/arb/ (e.g., app_fr.arb)
- Distinctive: line 115
Add translations for all keys from the template ARB file
- Very specific: line 121
Add the key-value pair to the template ARB file (app_en.arb)
- Very specific: line 122
Add the @key metadata with description and placeholders if needed
- Distinctive: line 123
Add translations in all other ARB files
- Distinctive: line 131
Add plural forms in all locale ARB files
≈ “Common” is an estimate: at least 1 in 5 of the 213,895 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Internationalization
Internationalization (i18n) and localization (l10n) best practices for Flutter applications using Flutter's built-in localization system with ARB files as the single source of truth.
Core Standards
Apply these standards to ALL internationalization work:
- Never hardcode user-facing strings — all text must go through the l10n system
- Use Flutter's built-in localization system —
flutter_localizations+intl, never third-party i18n libraries - ARB files are the single source of truth for all translations
BuildContextextension for cleaner l10n access — usecontext.l10ninstead ofAppLocalizations.of(context)- Pass localized strings as parameters to reusable widgets — never couple shared widgets directly to
AppLocalizations - Use
EdgeInsetsDirectional(start/end) instead ofEdgeInsets(left/right) — ensures correct layout in RTL languages - Handle RTL layout properly — use directional widgets for padding, positioning, and alignment
- Implement i18n early — even if only one language is planned initially, the overhead is small and the long-term benefit is significant
- Dart 3.13 primary constructors — on the Dart 3.13+ baseline (
very_good_core1.6 /very_good_analysis11), declare a reusable widget's localized-string fields as primary-constructor declaring parameters (class const ConfirmDialog({required final String title, super.key}) extends StatelessWidget) rather thanthis.field; keep the classic form only below 3.13
Setup Pipeline and ARB File Format
Add flutter_localizations and intl as dependencies, enable generate: true in pubspec.yaml, configure l10n.yaml, create ARB files in lib/l10n/arb/, run flutter gen-l10n, and wire up MaterialApp with localizationsDelegates and supportedLocales. ARB files support simple strings, placeholders, and ICU plural syntax.
BuildContext Extension
Create an extension for ergonomic l10n access throughout the codebase:
extension AppLocalizationsX on BuildContext {
AppLocalizations get l10n => AppLocalizations.of(this);
}Usage:
// Preferred
Text(context.l10n.helloWorld);
// Avoid
Text(AppLocalizations.of(context).helloWorld);Reusable Widget Strategy
Shared widgets that live in separate packages should not depend on AppLocalizations directly. Instead, pass localized strings as constructor parameters:
When someone asks to add AppLocalizations to a shared package, decline and say why — the package would carry its own translations and every consuming app would be locked to them — then rewrite their widget with the label as a final String constructor parameter and show the call site supplying context.l10n. Give both as Dart code; describing the change in prose leaves the caller to guess the signature.
// Shared widget — no l10n dependency
class const ConfirmDialog({
required final String title,
required final String message,
required final String confirmLabel,
required final String cancelLabel,
super.key,
}) extends StatelessWidget {
@override
Widget build(BuildContext context) {
return AlertDialog(
title: Text(title),
content: Text(message),
actions: [
TextButton(onPressed: () => Navigator.pop(context), child: Text(cancelLabel)),
FilledButton(onPressed: () => Navigator.pop(context, true), child: Text(confirmLabel)),
],
);
}
}
// App-level usage — passes localized strings
showDialog<bool>(
context: context,
builder: (_) => ConfirmDialog(
title: context.l10n.deleteTitle,
message: context.l10n.deleteMessage,
confirmLabel: context.l10n.confirm,
cancelLabel: context.l10n.cancel,
),
);Text Directionality
Use EdgeInsetsDirectional (start/end) instead of EdgeInsets (left/right) for all padding and margins. Use directional widget variants (PositionedDirectional, AlignDirectional, BorderDirectional) for RTL-aware layouts. Icons mirror automatically in RTL; images require matchTextDirection: true.
Backend Considerations
Store backend content with per-locale translations and require clients to transmit the user's locale. For error messages, map HTTP status codes or custom backend error constants to l10n keys on the frontend.
Common Patterns
Adding a New Locale
- Create
app_<locale>.arbinlib/l10n/arb/(e.g.,app_fr.arb) - Add translations for all keys from the template ARB file
- Run
flutter gen-l10n - The new locale is automatically available through
AppLocalizations.supportedLocales
Adding a New String
- Add the key-value pair to the template ARB file (
app_en.arb) - Add the
@keymetadata with description and placeholders if needed - Add translations in all other ARB files
- Run
flutter gen-l10n - Use via
context.l10n.newKey
Pluralization
- Define the plural string in the template ARB file using ICU message syntax
- Provide placeholder metadata with
"type": "int" - Add plural forms in all locale ARB files
- Use via
context.l10n.itemCount(items.length)
Additional Resources
- references/setup.md — full step-by-step setup pipeline and ARB file format examples
- references/directionality.md — visual vs directional widgets, icon/image mirroring, Material bidirectionality standards
- references/backend.md — multi-language content storage and error message localization
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

