chiark / gitweb /
add --prefix option; add --keep-old option
authorColin Watson <cjwatson@chiark.greenend.org.uk>
Tue, 15 Apr 2008 15:52:37 +0000 (15:52 +0000)
committerColin Watson <cjwatson@chiark.greenend.org.uk>
Tue, 15 Apr 2008 15:52:37 +0000 (15:52 +0000)
rosetta-merge

index 2e8c1da..b34676c 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