summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJulian Andres Klode <julian.klode@canonical.com>2019-03-11 11:09:03 +0100
committerJulian Andres Klode <julian.klode@canonical.com>2019-03-11 11:09:03 +0100
commit1ab5b42353d2510d051731b4318564d3a7ddaaf7 (patch)
tree8cfce525a0f3c4827b50e2a8d4b88723271aa601
parentf541aec06bce1ccac98dabe61137b56ed563e0e9 (diff)
downloadapt-1ab5b42353d2510d051731b4318564d3a7ddaaf7.tar.gz
prepare-release: Add merge-translations command
This command allows merging translations from another branch. This is to be used strictly downwards, that is, translations should be merged from newest to oldest branch, without skipping any active branch, to ensure the best result. For example, consider branches 1 and 2 have the strings "a" and "b" to translate, but master only has the strings "a" and "c". Now, 2 has more translations for "b" than 1. By merging master into 2, and 2 into 1, 1 also gets any translations for "b" from 2.
-rwxr-xr-xprepare-release23
1 files changed, 22 insertions, 1 deletions
diff --git a/prepare-release b/prepare-release
index c93976f9a..ea749f85d 100755
--- a/prepare-release
+++ b/prepare-release
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/bin/bash
set -e
cd "$(readlink -f $(dirname $0))"
@@ -341,6 +341,23 @@ elif [ "$1" = 'spellcheckers' -o "$1" = 'lint' ]; then
-e '^I: po/es.po: duplicate-header-field X-POFile-SpellExtra$' \
|| true
fi
+elif [ "$1" = "merge-translations" ]; then
+ if [ -z "$2" ]; then
+ echo "Usage:\t$0 $1 <branch to merge from>" >&2
+ exit 1
+ fi
+ for i in {doc/,}po/*.po ; do
+ # 1. concatenate the translations, picking new translations
+ # 2. merge the translations so we only have matching translations left
+ # 3. remove any newly introduced obsolete translations (only in $2)
+ # 4. concatenate again to restore "old" obsolete translations
+ # 5. write output
+ msgcat --use-first <(git show $2:$i) $i \
+ | msgmerge --no-fuzzy --previous - $i \
+ | msgattrib --no-obsolete - \
+ | msgcat --use-first - $i \
+ | sponge $i
+ done
else
echo >&1 "Usage:\t$0 pre-export
\t$0 pre-build
@@ -373,6 +390,10 @@ runs all tests and generates a html report in the end.
»spellcheckers« runs »codespell« and »spellintian« on the appropiate files and
filters out obvious false positives.
+
+\t$0 merge-translations branch
+
+Merge translations from the given branch.
"
fi