agentleFS
NarekManukyanNarekManukyan/flutter-mobx-kit/skills/add-localization/SKILL.md

add-localization

Skill0 starsChanged 56 days agoMITView on GitHub

Add a user-visible string via easy_localization — key naming, where it goes in en-US.json, LocaleKeys codegen, plurals, interpolation, enum-keyed strings, and adding a new locale. Use whenever any text will be rendered to a user, including error messages, semantics labels and accessibility hints.

2 other projects use a version of this.

Adopted by

Most recently taken up by

The file

We split this skill into the rules it gives an agent

7 rules. About 0 are common, 2 are distinctive, and 5 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈2

    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
  1. Very specific:

    Add the key to assets/translations/en-US.json.

    line 14
  2. Very specific:

    Run melos run translations — regenerates lib/gen/locale_keys.g.dart.

    line 15
  3. Very specific:

    Use LocaleKeys.key.tr() in the widget.

    line 16
  4. Distinctive:

    Use named args, never string concatenation — word order differs between languages, and a concatenated sentence cannot be translated.

    line 57
  5. Distinctive:

    Never build a plural with a ternary in Dart.

    line 69
  6. Very specific:

    Add assets/translations/{lang}-{COUNTRY}.json with the same key tree as en-US.json.

    line 98
  7. Very specific:

    Add the value to SupportedLocals in lib/core/constants/supported_locals.dart and map it in getLocal.

    line 99

≈ “Common” is an estimate: at least 1 in 5 of the 350,495 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.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Add a localized string

Governed by ADR-0012. No string that a user can see or a screen reader can read may be a literal in lib/.

That includes: labels, buttons, hints, validation messages, error text, empty-state copy, snackbars, dialog titles, and Semantics labels.

The loop

  1. Add the key to assets/translations/en-US.json.
  2. Run melos run translations — regenerates lib/gen/locale_keys.g.dart.
  3. Use LocaleKeys.key.tr() in the widget.
// ❌
Text('Continue with email')

// ✅
Text(LocaleKeys.loginPage_continueWithEmail.tr())

Never hand-edit lib/gen/locale_keys.g.dart.

Key naming

Nested JSON; _ in the generated Dart key marks each level.

{
  "keywords":   { "cancel": "Cancel", "retry": "Retry" },
  "loginPage":  { "title": "Sign in", "emailHint": "Email" },
  "homePage":   { "emptyTitle": "Nothing here yet" }
}
  • keywords — strings reused across features: Cancel, Close, Save, Retry, Continue. Check here first; do not add a second "Cancel".
  • {feature}Page — everything scoped to one screen. Match the page name (loginPage, homePage, todoDetailsPage).
  • enums — one sub-object per enum, keyed by the enum value's name.

Key names describe the role, not the text. emptyTitle, not nothingHereYet — the copy will change, the role will not.

Interpolation

{ "homePage": { "greeting": "Hello, {name}", "counter": "{done} of {total} done" } }
LocaleKeys.homePage_greeting.tr(namedArgs: {'name': user.firstName});
LocaleKeys.homePage_counter.tr(namedArgs: {'done': '$done', 'total': '$total'});

Use named args, never string concatenation — word order differs between languages, and a concatenated sentence cannot be translated.

Plurals

{ "homePage": { "todoCount": { "one": "{} todo", "other": "{} todos" } } }
LocaleKeys.homePage_todoCount.plural(count);

Never build a plural with a ternary in Dart.

Enum-keyed strings

For a value the server sends, key on the enum name so an unmapped value is visible in the JSON rather than crashing:

{ "enums": { "appVersionTranslationsTitle": { "MINOR": "New tools are ready", "MAJOR": "A new version is available" } } }
LocaleKeys.enums_appVersionTranslationsTitle.tr(gender: type.name);
// or: '${LocaleKeys.enums_appVersionTranslationsTitle}.${type.name}'.tr()

Semantics labels are localized too

Accessibility labels are user-visible strings. Maestro selects by accessibility id, so these labels are also part of the E2E contract (ADR-0015).

Semantics(
  label: LocaleKeys.homePage_addTodoA11y.tr(),
  button: true,
  child: const Icon(Icons.add),
)

Adding a locale

  1. Add assets/translations/{lang}-{COUNTRY}.json with the same key tree as en-US.json.
  2. Add the value to SupportedLocals in lib/core/constants/supported_locals.dart and map it in getLocal.
  3. melos run translations.

A key present in en-US.json and missing elsewhere renders the raw key path to the user. Keep the trees identical.

Checklist

  • No string literal reaching the UI, including errors and semantics labels
  • Reusable words in keywords; screen copy under {feature}Page
  • Key names describe the role, not the current copy
  • Interpolation via namedArgs; plurals via .plural()
  • melos run translations run after editing JSON
  • lib/gen/locale_keys.g.dart not edited by hand
  • Every locale file carries the same key tree

Download now (ZIP)

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
What did you use it for? e.g. Reviewing pull requests in a Rails app

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.