translations library

Which translation key is on which screen, and a picture of it.

Two halves that meet at a catalog name:

  • indexTranslations is the seam. Hand it to whatever the project's catalog already funnels its reads through, in a test, and every string it renders can be traced back to the key it came from — by object identity, so nothing is inserted into the text and no pixel moves.
  • TranslationExport reads what the export wrote, typed, so pushing screenshots to a translation service is a few lines rather than a map walk.

Plain Dart on purpose — nothing here may import package:flutter. The script that talks to a translation service runs under a bare dart run, exactly like tool/flutterware.dart does.

The seam is also re-exported from package:flutterware/flutter_test.dart, which is where a test already imports from.

Classes

ExportedCatalog
A declared catalog, as the export found it.
ExportedExpansionBreak
A screen a max-length probe broke — a fact about the app, not about any one string, because under batch expansion every value on it moved at once.
ExportedKey
One key, everything the run learned about it.
ExportedKeyRef
A key named by one of the two coverage lists.
ExportedLocaleFinding
A key whose rendered words were not what its locale's file says.
ExportedMaxLength
How long one key's text can get, measured — with the experiment that proved it.
ExportedRect
A box on a captured frame, in the image's own pixels.
ExportedShot
One place a key was seen, on one captured frame.
ExportedUnkeyed
Words on a screen that belonged to no catalog.
ExportFindings
Everything the export noticed that is worth acting on.
TranslationExport
A written export, read back.
TranslationIndex
What the catalogs said, and how to ask what a rendered string came from.
TranslationKey
One catalog read.

Constants

translationExportFile → const String
The file an export's index is written to, inside its directory.
translationExportVersion → const int
The format keys.json is written in.

Functions

indexExpansions(String catalog) → String Function(String key, String expanded)
The same seam again, for a string the catalog built rather than stored.
indexTranslations(String catalog) → String Function(String key, String expanded)
The wrapper for one catalog — hand it to whatever seam the project's translations expose.
indexTranslationsIn<T extends Object>(String? text(T widget)) → void
Read this widget's translated text off a property, for widgets that render a string their own way instead of handing it to a paragraph.