fix static method

FixReport fix(
  1. DialectProject project, {
  2. bool stamp = true,
})

Walk every ARB in project and re-emit it through ArbWriter. The writer's canonical form deterministically:

  • sorts keys byte-wise lexicographic,
  • hoists @@locale to the top,
  • places each @key block immediately after its key,
  • emits @@ file-level metadata (preserved verbatim) after @@locale,
  • drops orphanMetadata (by construction — writer never emits it),
  • in translation ARBs, strips descriptive @key metadata (namespace/description/context/placeholders — those live in the source), preserves state metadata (locked, source_hash), and stamps source_hash onto unlocked entries that lack one (see normalizeTranslation).

Files that are already canonical are not touched. Returns a FixReport for terminal display. Pass stamp as false (check --fix --no-stamp) to normalize without creating new source_hash entries — the authoring pass on a fresh locale, where stamping every key at once buries the translation review.

Implementation

static FixReport fix(DialectProject project, {bool stamp = true}) {
  final changed = <String>[];
  final sourceHashes = computeSourceHashes(project.source);

  _maybeRewrite(project.source, changed);
  for (final t in project.translations.values) {
    _maybeRewrite(
      normalizeTranslation(t, sourceHashes, stamp: stamp),
      changed,
    );
  }

  return FixReport(changedFiles: changed);
}