chiark / gitweb /
set -e to make it easier to kill this
[bin.git] / rosetta-merge
index 2e8c1dab1e8f1ec88bb7c6e5b9de0fb60fb982d9..b34676cfc1dae68882259d28d295bcfd26f56285 100755 (executable)
@@ -6,24 +6,45 @@ if [ "$1" = --apply ]; then
        shift
 fi
 
-case $2 in
+KEEP_OLD=false
+if [ "$1" = --keep-old ]; then
+       KEEP_OLD=:
+       shift
+fi
+
+PREFIX=
+if [ "$1" = --prefix ]; then
+       PREFIX="$2-"
+       shift 2
+fi
+
+SOURCE="$1"
+shift
+
+MY_LANG="$1"
+case $MY_LANG in
        pa_IN)
                ROSETTA_LANG=pa
                ;;
        *)
-               ROSETTA_LANG="$2"
+               ROSETTA_LANG="$MY_LANG"
                ;;
 esac
 
-[ -e $1/$ROSETTA_LANG.po ] || exit
-msgmerge -q -N <(msgconv -t UTF-8 $1/$ROSETTA_LANG.po | msgattrib --no-obsolete -) *.pot | msgattrib --no-obsolete $MSGATTRIB_OPTS - | \
-       if [ -e $2.po ]; then
-               msgmerge -q -N - <(msgconv -t UTF-8 $2.po | msgattrib --no-obsolete -) | msgattrib --no-obsolete -
+[ -e $SOURCE/$PREFIX$ROSETTA_LANG.po ] || exit
+msgmerge -q -N <(msgconv -t UTF-8 $SOURCE/$PREFIX$ROSETTA_LANG.po | msgattrib --no-obsolete -) *.pot | msgattrib --no-obsolete $MSGATTRIB_OPTS - | \
+       if [ -e $MY_LANG.po ]; then
+               if $KEEP_OLD; then
+                       msgmerge -q -N <(msgconv -t UTF-8 $MY_LANG.po | msgattrib --no-obsolete -) *.pot -C -
+               else
+                       msgmerge -q -N - <(msgconv -t UTF-8 $MY_LANG.po | msgattrib --no-obsolete -)
+               fi | \
+               msgattrib --no-obsolete -
        else
                cat
        fi | \
        if $APPLY; then
-               sponge $2.po
+               sponge $MY_LANG.po
        else
-               diff -u --label $2.po <(msgconv -t UTF-8 $2.po) -
+               diff -u --label $MY_LANG.po <(msgconv -t UTF-8 $MY_LANG.po) -
        fi