i18n: Order of trans-units in source.xlf seems random

🐞 bug report

Note: i’m not sure if this is a feature request or a bug report, altough it does feel like buggy behavior.

Affected Package

The issue is likely caused by package @angular/localize

Is this a regression?

Not sure, i believe it got worse with v. 11.0 but i cannot exactly pinpoint a specific version.


In a fairly big project with a lot of different development environments (Mac, Windows, Linux), it is close to impossible to efficiently work with i18n. The main problem we are facing is that many engineers touch the translation files in parallel merge requests. Since Angular 11, it has worsened so far that the diffs are at 1k lines+ for every change in translations, even if just a single translation was added. This has two reasons:

a) the line numbers fluctuate between windows and linux, and likely even on the same OS but on different machines
b) the messages appear to be sorted randomly, which cannot be automatically merged by git

point b) seems to be way worse, as the line numbers changing can easily be resolved by just accepting either one, altough it is quite a pain if you have some thousands of translations.

🔬 Minimal Reproduction

not possible to setup, you’d need at least two different systems, and you do need to make code changes for the order to change.

These are changes made by i18n, altough i only added ONE actually new trans-unit, with the previous i18n run also done by myself. it’s even worse when someone else runs it on linux.

🔥 Exception or Error


🌍 Your Environment

Angular Version:

Angular CLI: 11.0.6
Node: 10.16.0
OS: win32 x64

Angular: 11.0.6
... animations, cli, common, compiler, compiler-cli, core, forms
... language-service, localize, platform-browser
... platform-browser-dynamic, router, service-worker, upgrade
Ivy Workspace: Yes

Package                            Version
@angular-devkit/architect          0.1100.6
@angular-devkit/build-angular      0.1100.6
@angular-devkit/core               11.0.6
@angular-devkit/schematics         11.0.6
@angular/cdk                       11.0.3
@angular/flex-layout               11.0.0-beta.33
@angular/material                  11.0.3
@angular/material-moment-adapter   11.0.3
@schematics/angular                11.0.6
@schematics/update                 0.1100.6
rxjs                               6.6.3
typescript                         4.0.5

note that OS: win32 x64 is just one of potentially many.

1 possible answer(s) on “i18n: Order of trans-units in source.xlf seems random

  1. This will be fixed in 11.1 – #40192 – which is already in release-candidate.
    Can you try out the 11.1.0-rc.0 release and see if this solves the problem for you?