fix static method

FixReport fix(
  1. DialectProject project
)

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 @key metadata blocks (the writer only emits them when the source ARB shape is detected by a non-@@locale key matching the convention; translation files passed through _stripMetadata lose theirs).

Files that are already canonical are not touched. Returns a FixReport for terminal display.

Implementation

static FixReport fix(DialectProject project) {
  final changed = <String>[];

  _maybeRewrite(project.source, changed);
  for (final t in project.translations.values) {
    _maybeRewrite(_stripMetadata(t), changed);
  }

  return FixReport(changedFiles: changed);
}