The untranslated-messages-file option lists keys that are missing from a locale. It does not compare a translation with the English it was made from. If you edit only app_en.arb, app_de.arb still has the key, the report is {}, and German users keep reading last quarter's cancellation terms.
To catch that, record which English text each translation was based on, then fail the pull request when that text changes. The script below does it with no dependencies. I ran it on Flutter 3.47.7 (Dart 3.13.5) with German, Polish and French files.
Why a green build hides outdated translations
In the gen-l10n source, a message counts as untranslated when the locale has no entry for it. Nothing remembers an earlier English value, so there is nothing to compare.
| Problem | Example | Who finds it | Fix |
|---|---|---|---|
| Missing | Key in app_en.arb, absent from app_pl.arb |
untranslated-messages-file and a CI gate for missing translations |
Translate it |
| Stale | Key in both, English changed afterwards | The lock file in this post | Retranslate or re-approve |
| Unused | Key in every ARB file, no Dart code calls it | A check for unused ARB keys | Delete it everywhere |
| Unreviewed | AI wrote the German, nobody read it | AI translation review | Review it |
The AI review script stores the source and the translation, so it also reopens a string when English changes. If you already run it, you do not need a second gate. Choose this lighter one when people translate and stale text is the only gap. New to the format? Start with the Flutter ARB guide.
Why git blame dates mislead
Comparing the last change date of each line looks easier. I tried it on a test repo where the German text was written in March and the English terms changed in September:
| Later commit to app_de.arb | git blame date on the German line |
git blame -w date |
|---|---|---|
| None | March (correct) | March (correct) |
| October: indentation only | October (wrong) | March (correct) |
| November: keys reordered | November (wrong) | November (wrong) |
After the reorder, the German line looks newer than the English edit, so a date check passes it. The -w flag ignores whitespace, not moved lines. Even an accurate date only says when a line moved, not which English the translator had read.
The lock file script
- my_app/
- lib/
- l10n/
- app_en.arbsource text
- app_de.arb
- app_fr.arb
- app_pl.arb
- l10n_lock/committed
- de.jsonkey: hash of the English it was based on
- fr.json
- pl.json
- tool/
- l10n_stale.dart
Save this as tool/l10n_stale.dart and adjust the four constants:
import 'dart:convert';
import 'dart:io';
const arbDir = 'lib/l10n';
const template = 'app_en.arb';
const prefix = 'app_';
const lockDir = 'l10n_lock';
Map<String, dynamic> readJson(File f) =>
jsonDecode(f.readAsStringSync()) as Map<String, dynamic>;
// 64-bit FNV-1a: detects edits, not a security hash. Run on the Dart VM.
String fnv1a(String text) {
var h = 0xcbf29ce484222325;
for (final byte in utf8.encode(text)) {
h = (h ^ byte) * 0x100000001b3;
}
String hex(int n) => n.toRadixString(16).padLeft(8, '0');
return hex(h >>> 32) + hex(h & 0xffffffff);
}
Object? sortKeys(Object? v) => v is Map
? {
for (final k in v.keys.cast<String>().toList()..sort())
k: sortKeys(v[k]),
}
: v;
// Source text plus placeholder names, types and formats.
// Descriptions and examples do not count as a change.
String sourceHash(Map<String, dynamic> en, String key) {
final meta = en['@$key'];
final raw = meta is Map ? meta['placeholders'] : null;
final placeholders = {
if (raw is Map)
for (final e in raw.entries)
'${e.key}': {...e.value as Map}
..remove('example')
..remove('description'),
};
return fnv1a(jsonEncode([en[key], sortKeys(placeholders)]));
}
Never fail(String message) {
stderr.writeln(message);
exit(64);
}
void main(List<String> args) {
final command = args.isEmpty ? 'check' : args.first;
final rest = args.skip(1);
final only = {
for (final a in rest)
if (a.startsWith('--locale=')) a.substring(9),
};
final keys = rest.where((a) => !a.startsWith('--locale=')).toSet();
if (!{'check', 'baseline', 'approve'}.contains(command) ||
(command == 'approve') == keys.isEmpty) {
fail('Use: check | baseline | approve [--locale=de] key...');
}
final en = readJson(File('$arbDir/$template'));
final source = en.keys.where((k) => !k.startsWith('@')).toList()..sort();
final unknown = keys.difference(source.toSet());
if (unknown.isNotEmpty) fail('Not in $template: ${unknown.join(', ')}');
final locales = <String, Map<String, dynamic>>{};
for (final f in Directory(arbDir).listSync().whereType<File>()) {
final name = f.uri.pathSegments.last;
if (name == template) continue;
if (!name.startsWith(prefix) || !name.endsWith('.arb')) continue;
locales[name.substring(prefix.length, name.length - 4)] = readJson(f);
}
if (!locales.keys.toSet().containsAll(only)) fail('No ARB file for $only');
final problems = <String>[];
for (final locale in locales.keys.toList()..sort()) {
if (only.isNotEmpty && !only.contains(locale)) continue;
final file = File('$lockDir/$locale.json');
final exists = file.existsSync();
if (command == 'baseline' && exists) continue; // never overwrite approvals
if (command != 'baseline' && !exists) {
problems.add('$locale: no lock file, run baseline');
continue;
}
final lock = exists ? readJson(file) : <String, dynamic>{};
final next = <String, dynamic>{};
for (final key in source.where(locales[locale]!.containsKey)) {
final now = sourceHash(en, key);
if (command == 'baseline' || keys.contains(key)) {
next[key] = now;
} else if (lock.containsKey(key)) {
next[key] = lock[key];
}
if (next[key] == null) {
problems.add('$locale NEW $key');
} else if (next[key] != now) {
problems.add('$locale STALE $key -> "${en[key]}"');
}
}
if (command == 'check') continue;
file.createSync(recursive: true);
file.writeAsStringSync(
'${const JsonEncoder.withIndent(' ').convert(next)}\n',
);
print('$locale: lock written');
}
problems.forEach(print);
if (problems.isEmpty) print('Every translation matches its source hash.');
if (command == 'check' && problems.isNotEmpty) exitCode = 1;
}
The script reads decoded JSON, so indentation and key order do not matter. I rewrote the whole English file in reverse order with 8-space indentation and check still passed.
Record the baseline once
dart run tool/l10n_stale.dart baseline
git add l10n_lock tool/l10n_stale.dart
Before committing it, have someone read the risky keys in every language: prices, terms, consent and cancellation. baseline skips any locale that already has a lock file, so a second run cannot approve everything by accident.
Then add the gate:
name: l10n
on: pull_request
jobs:
stale-translations:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: subosito/flutter-action@v2
with:
channel: stable
- run: flutter pub get
- run: dart run tool/l10n_stale.dart check
Mark the job as a required check, or a red result will not stop a merge.
Worked example: 14 days become 30
A developer changes cancelTerms from "Cancel any time up to 14 days before renewal." to 30 days, in English only. flutter gen-l10n still writes {} to the untranslated report. check exits with code 1:
de STALE cancelTerms -> "Cancel any time up to 30 days before renewal."
fr STALE cancelTerms -> "Cancel any time up to 30 days before renewal."
pl STALE cancelTerms -> "Cancel any time up to 30 days before renewal."
The lock holds a hash, so get the old wording from Git. Translators need both versions:
git log -G'"cancelTerms"' -p -U0 -- lib/l10n/app_en.arb
Once the German is updated and read, approve that locale only:
dart run tool/l10n_stale.dart approve --locale=de cancelTerms
French and Polish stay red until someone approves them. Editing app_de.arb does not clear the flag by itself, because an edit is not proof that anyone checked it against the new English.
Typos, placeholders and new keys
Typo-only edits. Fixing "recieve" in English changes the hash, but the translations are fine. Run approve someKey without --locale to accept every language at once. The lock diff shows that decision to the pull request reviewer.
Placeholder format or type. Changing yMMMd to yMMMMd leaves the text identical but changes what users see. The hash includes placeholder names, types and formats, so this is flagged. Descriptions and examples are left out.
Renamed placeholder. This one is nastier. I renamed {date} to {endDate} in English only. On 3.47.7, flutter gen-l10n exited with 0, reported {}, and generated this for every locale:
String renewsOn(DateTime endDate, Object date);
The old placeholder became an extra required argument. The stale check names the key and the locales to fix. It does not validate placeholders inside a translation, so fix the text before approving. See the ARB placeholders guide for the syntax.
New translations. A translated key with no hash shows as NEW and fails until approved. A key the locale does not have is skipped: that is the missing-key gate's job.
The manual step the script leaves
The script tells you a German string is out of date. It does not tell the translator. Someone still copies the old and new English into a message, waits, pastes the answer into the ARB file and runs approve. The lock shows who committed the hash, which may not be who read the German.
In FlutterLocalisation, when the source changes after a translation was made, that translation is marked Needs review in the dashboard. Every language sits side by side, translators can filter and comment on the string, and Git sync commits their edits back to the repo. You invite them by email with read or write access per project, so they never open an ARB file.
Lock file only
- CI names the stale keys
- You send old and new English by hand
- You paste the reply into app_de.arb
- A developer runs approve
Lock file plus dashboard
- CI still names the stale keys
- The translation shows as Needs review
- The translator edits and comments on the string
- Git sync commits the edit, then you approve the hash
Checklist
- Read price, terms and consent strings before the baseline
- Commit l10n_lock and run check on every pull request
- Make the job a required check
- Send translators the old and the new English
- Approve per locale, and all locales at once only for typos
- Keep the separate gates for missing and unused keys
Try FlutterLocalisation free
Import your ARB files, invite your translators, and let them see which translations need review after an English edit. The Free plan covers 2 projects, 3 members and 500 keys with no card (pricing). To inspect a file first, open it in the free ARB Editor or compare two in ARB Diff.