airglot
DocsPrivate beta
Docs menu

Over the air for Flutter

Ship new and corrected translations to installed apps without a store release. The airglot_l10n package downloads the app's signed release from the AirGlot CDN, verifies and caches it, and lays it over the strings compiled into the app. Your existing AppLocalizations.of(context) calls don't change.

Set up the Flutter quickstart first. Over the air works on top of it: the compiled strings stay the fallback.

1. Add the packages

dependencies:
  airglot_l10n: ^1.0.0
dev_dependencies:
  airglot_l10n_gen: ^1.0.0

2. Generate the overlay

Run the generator after flutter gen-l10n:

flutter gen-l10n
dart run airglot_l10n_gen

It reads l10n.yaml and the template ARB file and writes airglot_localizations.g.dart next to gen-l10n's output. Run it again whenever the template changes, the same way you run flutter gen-l10n.

3. Create the catalog

Open the app's settings in AirGlot, then Delivery. It shows the pointer URL and a ready-made snippet with the app's signing keys. Paste those values in:

final airglot = AirglotL10n(
  generated: airglotGenerated, // from airglot_localizations.g.dart
  config: AirglotConfig(
    pointerUrl: Uri.parse('https://cdn.airglot.com/i18n/<app>/public.json'),
    publicKeys: {'<kid>': '<base64 Ed25519 public key>'},
    onReport: (report) => log('$report'),
  ),
);

await airglot.load(); // reads the cache only, safe before runApp
runApp(App(airglot: airglot));
// after the first frame
unawaited(airglot.refresh());

load() never touches the network. refresh() checks for a new release at most once per cold start and per resume, and never more often than every 15 minutes. A failed refresh keeps the current release.

4. Use the overlay's delegates

ListenableBuilder(
  listenable: airglot,
  builder: (context, _) => MaterialApp(
    locale: airglot.activeLocale,
    supportedLocales: airglot.supportedLocales,
    localizationsDelegates: airglotLocalizationsDelegates(airglot),
  ),
)

airglotLocalizationsDelegates replaces AppLocalizations.localizationsDelegates. Flutter uses the first delegate it finds for a type, so an app that still lists AppLocalizations.delegate ahead of the overlay gets no remote strings. Debug builds report that as an error.

Outside the widget tree, call airglotLookupAppLocalizations(airglot, locale) instead of gen-l10n's lookupAppLocalizations(locale), which bypasses the overlay.

First launch

On a fresh install nothing is cached yet. To avoid drawing the first screen in the source language and switching a moment later, wait for the first release before runApp:

await airglot.load();
await airglot.awaitFirstRelease(); // at most 1.5 s, first launch only
runApp(App(airglot: airglot));
unawaited(airglot.refresh());

The platform keeps its launch screen up until the first frame, so you don't need a spinner. It returns at once when a release is already cached.

How it stays safe

  • Releases are signed. load() verifies the Ed25519 signature and each bundle's checksum.
  • A remote string is used only when it was translated from the exact source text compiled into the app, and it works with the arguments given. Otherwise the app falls back to the next layer, ending with the compiled strings.
  • Every problem is reported through onReport. Only updated is at info level, so filter on level before sending reports to crash reporting.

Language picker

airglot.availableLocales lists the compiled languages plus every language in the applied release, so a language shipped after the app was built appears after the next refresh. selectLocale(locale) downloads and applies a language and saves the choice. followDevice() goes back to the device's languages.

Apps that keep the language choice themselves, for example in a user profile, call useLocale(locale) after every load() instead.

Testers

Test builds can follow the internal channel or a test group, so testers see a release before it goes to everyone. Test groups and their enrolment links are under Delivery in the app's settings. Keep a channel URL out of your source code: read it from a --dart-define and use it only in tester builds. Add AirglotReleaseBadge so testers can see which release and channel they are on.

The airglot_l10n README on pub.dev covers every option.