build: sort location annotation table in i18n sync process
authorHannu Nyman <hannu.nyman@iki.fi>
Tue, 7 Jan 2020 16:58:33 +0000 (18:58 +0200)
committerJo-Philipp Wich <jo@mein.io>
Wed, 8 Jan 2020 19:21:23 +0000 (20:21 +0100)
The scanning routine has caused unnecessary changes to the .po files
if a string has been found in multiple files and those files have been
found in different order than the previous time.

Sort the location annotations to avoid unnecessary changes to the .po files.
(sort is alphabetic, so the line numbers are also sorted alphabetically)

Signed-off-by: Hannu Nyman <hannu.nyman@iki.fi>
[apply a Schwartzian transform to sort locations by path, then line number]
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
build/i18n-scan.pl

index 5ac1cb77d4986854051cb39b5adb51e83da4afcc..fc516c6a04bc81fb759d8f1e69bd0a0c5fc882e2 100755 (executable)
@@ -272,7 +272,11 @@ if( open C, "| msgcat -" )
        {
                if( length $key )
                {
-                       my @positions = @{$stringtable{$key}};
+                       my @positions =
+                               map { join ':', @$_ }
+                               sort { ($a->[0] cmp $b->[0]) || ($a->[1] <=> $b->[1]) }
+                               map { [ /^(.+):(\d+)$/ ] }
+                               @{$stringtable{$key}};
 
                        $key =~ s/\\/\\\\/g;
                        $key =~ s/\n/\\n/g;