[Flutter]

Wrap Flutter widgets for gen-l10n automatically

Dart string literals become AppLocalizations getters, keys land in your ARB files (merged, never clobbered), and l10n.yaml drives Flutter's own code generation.

Flutter's official i18n is flutter gen-l10n: ARB catalogs in, generated AppLocalizations getters out. Polyglot automates the part the toolchain doesn't — finding your hardcoded strings and converting them.

The transformation

Before — lib/home.dart
import 'package:flutter/material.dart';

class Home extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Text("Welcome back");
  }
}
After — lib/home.dart
import 'package:flutter/material.dart';
import 'package:demo_app/l10n/app_localizations.dart';

class Home extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Text(AppLocalizations.of(context)!.welcome_back);
  }
}
  • The whole string literal is replaced with the getter — never a partial splice inside Dart interpolation.
  • const contexts are respected: a const Text(...) can't hold a runtime lookup, so those strings are skipped with a reason rather than broken.
  • The AppLocalizations import is added per file, and resolves via your l10n.yaml — which Polyglot scaffolds if missing.

ARB catalogs, merged

Written — lib/l10n/app_en.arb
{
  "@@locale": "en",
  "welcome_back": "Welcome back"
}
Translated — lib/l10n/app_de.arb
{
  "@@locale": "de",
  "@welcome_back": {
    "description": ""
  },
  "welcome_back": "Willkommen zurück"
}
Translated — lib/l10n/app_fr.arb
{
  "@@locale": "fr",
  "@welcome_back": {
    "description": ""
  },
  "welcome_back": "Bon retour"
}

Existing ARB entries are read and preserved; keys are flat identifiers exactly as gen-l10n requires, so the generated getters always match the wrapped call sites.

✓ 1 strings auto-wrapped · 0 flagged for manual review · 0 unsafe transforms → polyglot-i18n-report.md
✓ wiring checks passed (1 injected import(s), 1 catalog value(s), 1 catalog file(s))

Try it

$ curl -fsSL https://getpolyglot.ai/install.sh | bash
$ polyglot init --framework flutter
$ polyglot scan
$ polyglot wrap
$ polyglot translate --languages de   # 50 strings free, no signup

Start in your terminal

Stop hunting for untranslated strings.

Install the CLI, run a scan, and see exactly what you're missing. Free, no account required.

$curl -fsSL https://getpolyglot.ai/install.sh | bash
Wrap Flutter widgets for gen-l10n automatically | Polyglot