Bug 34983: Force a sort order in JSON output of po2json

This patch does so by default. If you do not want them sorted,
export CANONICAL-0 on the command line.

Test plan:
Copy a staff PO file from misc/translator to test.po
Now run:   time misc/translator/po2json test.po > json1
And do:    time misc/translator/po2json test.po > json2
Run:       diff json1 json2; #They should be the same.
Now:       export CANONICAL=0
And run:   time misc/translator/po2json test.po > json3
And again: time misc/translator/po2json test.po > json4
And run:   diff json3 json4; # Lots of changes
Remove the created cruft. And signoff :)

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: David Nind <david@davidnind.com>

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
This commit is contained in:
Marcel de Rooy 2023-10-04 15:04:27 +02:00 committed by Tomas Cohen Arazi
parent 21315eb8dc
commit a5fc346403
Signed by: tomascohen
GPG key ID: 0A272EA1B2F3C15F

View file

@ -165,7 +165,7 @@ sub main
}
my $jsonobj = JSON->new;
my $jsonobj = JSON->new->canonical( $ENV{CANONICAL} // 1 ); # if you dont want sorted keys, export CANONICAL=0
my $basename = basename($src);
$basename =~ s/\.pot?$//;
if ($pretty)