From a6d4d74c97b8e693d8716cd3ec179edd8b550d50 Mon Sep 17 00:00:00 2001 From: Rudolf Polzer Date: Thu, 30 Mar 2017 21:13:38 +0200 Subject: [PATCH] tx.sh: Allow syncing only pot/only po. --- tx.sh | 168 +++++++++++++++++++++++++++++++++------------------------- 1 file changed, 96 insertions(+), 72 deletions(-) diff --git a/tx.sh b/tx.sh index 2fefa8fa4..19568c991 100644 --- a/tx.sh +++ b/tx.sh @@ -7,85 +7,109 @@ mergebase=`git log --pretty=oneline -1 .tx/merge-base | cut -d ' ' -f 1` set -e -# Update the .pot. -sh check-translations.sh pot +mode=$1 +case "$mode" in + all) + push_pot=true + sync_po=true + ;; + pot) + push_pot=true + sync_po=false + ;; + po) + push_pot=false + sync_po=true + ;; + *) + echo "Usage: $0 [all|pot|po]" + exit 1 + ;; +esac -# First upload our current .pot. -mkdir -p translations/xonotic.commonpot/ -cp common.pot translations/xonotic.commonpot/en..po -tx push -s +if $push_pot; then + # Update the .pot. + sh check-translations.sh pot -# Then pull the rest. -tx pull -f -a + # First upload our current .pot. + mkdir -p translations/xonotic.commonpot/ + cp common.pot translations/xonotic.commonpot/en..po + tx push -s +fi -for f in common.*.po; do - lang=${f%.po} - lang=${lang#common.} - case "$lang" in - de_CH) - continue - ;; - esac - tcurfile=translations/xonotic.commonpot/$lang..po - goldfile=translations/xonotic.commonpot/$lang..po.orig - gnewfile=common.$lang.po - if [ -f "$tcurfile" ]; then - git show "$mergebase":"$gnewfile" > "$goldfile" - msgmerge -F -U "$tcurfile" common.pot - msgmerge -F -U "$goldfile" common.pot - msgmerge -F -U "$gnewfile" common.pot - if diff -u "$goldfile" "$gnewfile" >/dev/null; then - # no change on git, changed on tx only +if $sync_po; then + # Then pull the rest. + tx pull -f -a + + for f in common.*.po; do + lang=${f%.po} + lang=${lang#common.} + case "$lang" in + de_CH) + continue + ;; + esac + tcurfile=translations/xonotic.commonpot/$lang..po + goldfile=translations/xonotic.commonpot/$lang..po.orig + gnewfile=common.$lang.po + if [ -f "$tcurfile" ]; then + git show "$mergebase":"$gnewfile" > "$goldfile" msgmerge -F -U "$tcurfile" common.pot - cp "$tcurfile" "$gnewfile" - else - if ! diff -u "$goldfile" "$gnewfile" | patch "$tcurfile"; then - while :; do - vim -o "$tcurfile.rej" "$tcurfile" - echo "OK?" - read -r OK || exit 1 - [ x"$OK" != x"y" ] || break - done - rm -f "$tcurfile.rej" + msgmerge -F -U "$goldfile" common.pot + msgmerge -F -U "$gnewfile" common.pot + if diff -u "$goldfile" "$gnewfile" >/dev/null; then + # no change on git, changed on tx only + msgmerge -F -U "$tcurfile" common.pot + cp "$tcurfile" "$gnewfile" + else + if ! diff -u "$goldfile" "$gnewfile" | patch "$tcurfile"; then + while :; do + vim -o "$tcurfile.rej" "$tcurfile" + echo "OK?" + read -r OK || exit 1 + [ x"$OK" != x"y" ] || break + done + rm -f "$tcurfile.rej" + fi + msgmerge -F -U "$tcurfile" common.pot + cp "$tcurfile" "$gnewfile" fi - msgmerge -F -U "$tcurfile" common.pot + rm "$goldfile" + else + msgmerge -F -U "$gnewfile" common.pot + cp "$gnewfile" "$tcurfile" + fi + done + for f in translations/xonotic.commonpot/*..po; do + lang=${f%..po} + lang=${lang#translations/xonotic.commonpot/} + [ x"$lang" != x"en" ] || continue + tcurfile=translations/xonotic.commonpot/$lang..po + gnewfile=common.$lang.po + if ! [ -f "$gnewfile" ]; then + touch "$gnewfile" + git add "$gnewfile" cp "$tcurfile" "$gnewfile" fi - rm "$goldfile" - else - msgmerge -F -U "$gnewfile" common.pot - cp "$gnewfile" "$tcurfile" - fi -done -for f in translations/xonotic.commonpot/*..po; do - lang=${f%..po} - lang=${lang#translations/xonotic.commonpot/} - [ x"$lang" != x"en" ] || continue - tcurfile=translations/xonotic.commonpot/$lang..po - gnewfile=common.$lang.po - if ! [ -f "$gnewfile" ]; then - touch "$gnewfile" - git add "$gnewfile" - cp "$tcurfile" "$gnewfile" - fi -done -tx push -t --skip -date > .tx/merge-base + done + tx push -t --skip + date > .tx/merge-base -# Generate Swiss Standard German from German. -msgfilter -i common.de.po -o common.de_CH.po perl -pe ' - # Character filters go here. - s/ß/ss/g; - # Word filters go here. By default we match even inside words, as there - # are constructs like ^BGflag where "flag" is the actual word. Make - # sure to not commit the clbuttical mistake. - s/eventuell/allfällig/g; -' + # Generate Swiss Standard German from German. + msgfilter -i common.de.po -o common.de_CH.po perl -pe ' + # Character filters go here. + s/ß/ss/g; + # Word filters go here. By default we match even inside words, as there + # are constructs like ^BGflag where "flag" is the actual word. Make + # sure to not commit the clbuttical mistake. + s/eventuell/allfällig/g; + ' -# Build new languages list. -sh check-translations.sh txt > languages.txt.new -mv languages.txt.new languages.txt + # Build new languages list. + sh check-translations.sh txt > languages.txt.new + mv languages.txt.new languages.txt -# Report stats. -git diff --stat -git diff --color-words languages.txt + # Report stats. + git diff --stat + git diff --color-words languages.txt +fi -- 2.39.2