From de34495d28fae47e822cb6dfc1af3e43e61d76b6 Mon Sep 17 00:00:00 2001 From: Hannu Nyman Date: Tue, 7 Jan 2020 18:58:33 +0200 Subject: [PATCH] build: sort location annotation table in i18n sync process 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 [apply a Schwartzian transform to sort locations by path, then line number] Signed-off-by: Jo-Philipp Wich (cherry picked from commit 460bdfe814a34ca5300e7a1a57efecff590dd414) --- build/i18n-scan.pl | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/build/i18n-scan.pl b/build/i18n-scan.pl index c19a4386c..b53e8bd98 100755 --- a/build/i18n-scan.pl +++ b/build/i18n-scan.pl @@ -157,7 +157,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; -- 2.25.1