From 13196ed2e2f2913375f6e64ad65750dfd6ca2316 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Tue, 7 Dec 2021 11:04:19 +0100 Subject: [PATCH] CI: sort .desktop entries for i18n The ordering of entries jumps around sometimes when reading from Transifex (this might be Python unordered dictionaries, or based on translation statistics -- I can't tell). Force an order by sorting on language code and key-name so they all end up grouped by language code, sorted Name Icon GenericName Comment. Although this shuffles some more entries now, longer-term it will reduce churn in the .desktop file. --- ci/txpull.sh | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/ci/txpull.sh b/ci/txpull.sh index 1c5c11a45..a6e4127af 100755 --- a/ci/txpull.sh +++ b/ci/txpull.sh @@ -108,6 +108,21 @@ awk ' skip=0; print $0; }}' < calamares.desktop > calamares.desktop.new mv calamares.desktop.new calamares.desktop +# Now group translated key-names (Name, Icon, Description, ..) by sorted +# language key rather than random-ish language-key order (which shuffles +# entries around). +# +# First, the non-translated lines +grep -v '\[.*\]=' calamares.desktop > calamares.desktop.new +# The translated lines: +# - replace (the first) [] by | so we have a consistent field separator +# - sort based on field 2, then 1 (language code, then reversed key-name) +# - replace the first | by [, the first (remaining) | by ] +# Effectively this puts the fields in this order: Name, Icon, Generic Name, +# Comment -- within each language key. This keeps churn down since the +# language codes and key-names are constant. +grep '\[.*\]=' calamares.desktop | sed -e 's/\[/|/' -e 's/\]/|/' | sort -t '|' -k 2,2 -k 1,1r | sed -e 's/|/\[/' | sed -e 's/|/\]/' >> calamares.desktop.new +mv calamares.desktop.new calamares.desktop git add --verbose calamares.desktop git commit "$AUTHOR" --message="i18n: [desktop] $BOILERPLATE" | true