Skip to content
All work
OPEN SOURCE2024

flutter_auto_localizations

A Dart CLI that takes a project from one language to dozens without hand-editing ARB.

A Dart CLI tool that automates Flutter localization end to end. It parses ARB files, preserves ICU plural and select structure through machine translation, and generates the delegates and accessors, turning a multi-day chore into a command.

The problem

Machine translation and ICU message syntax are natural enemies. A plural or select block is a small program embedded in a string, and a translation API happily returns a fluent sentence with the braces rearranged and the argument names translated, which compiles to nothing or, worse, compiles and renders wrong for exactly one locale. The tool had to translate the prose and leave the program alone.

The approach

  • Parse, don't regex

    A real ARB parser walks the file and isolates translatable prose from ICU structure and placeholders, so the syntax survives a round trip through a translation API intact.

  • Translate the text, preserve the program

    Google Translate is applied only to the extracted prose segments; braces, argument names, plural categories and select cases are reassembled afterwards.

  • Generate what Flutter expects

    Localization delegates and typed string accessors are emitted in the shape flutter gen-l10n consumers already use, so adopting it changes nothing downstream.

System architecture

How it is put together

  1. ARB parser

    Key extraction with ICU plural and select structure held separately from prose

  2. Translation stage

    Prose-only calls to the translation API, with placeholders masked

  3. Code generation

    Delegates and typed accessors matching the standard Flutter localization surface

Engineering decisions

The calls worth defending

Machine translation is a first draft, and the tool should say so

The output is for development, review and testing. It unblocks building a multi-locale app before a translator is hired, rather than pretending to replace one. Framing it that way is the difference between a useful tool and a shipped mistranslation.

Interface

What shipped

  • flutter_auto_localizations: CLI in action

    CLI in action

    One command from a single-language project to dozens of locales