chiark / gitweb /
my-debmirror: drop d-i images
[bin.git] / rosetta-merge
1 #! /bin/bash
2
3 usage () {
4         [ "$1" = 0 ] || exec >&2
5         echo "Usage: $0 [--apply] [--keep-old] [--prefix PREFIX] SOURCE LANG"
6         exit "$1"
7 }
8
9 die_getopt () {
10         echo "getopt failed" >&2
11         exit 1
12 }
13
14 APPLY=false
15 KEEP_OLD=false
16 PREFIX=
17 eval set -- "$(getopt -o '' -l apply,keep-old,prefix:,help -- "$@")" || die_getopt
18 while :; do
19         case $1 in
20                 --apply)
21                         APPLY=:
22                         shift
23                         ;;
24                 --keep-old)
25                         KEEP_OLD=:
26                         shift
27                         ;;
28                 --prefix)
29                         PREFIX="${2%-}-"
30                         shift 2
31                         ;;
32                 --help)
33                         usage 0
34                         shift
35                         ;;
36                 --)     shift; break ;;
37                 *)      die_getopt ;;
38         esac
39 done
40
41 [ "$1" ] || usage 1
42
43 SOURCE="$1"
44 shift
45
46 MY_LANG="$1"
47 case $MY_LANG in
48         pa_IN)
49                 ROSETTA_LANG=pa
50                 ;;
51         *)
52                 ROSETTA_LANG="$MY_LANG"
53                 ;;
54 esac
55
56 [ -e $SOURCE/$PREFIX$ROSETTA_LANG.po ] || exit
57 msgmerge -q -N <(msgconv -t UTF-8 $SOURCE/$PREFIX$ROSETTA_LANG.po | msgattrib --no-obsolete -) *.pot | msgattrib --no-obsolete $MSGATTRIB_OPTS - | \
58         if [ -e $MY_LANG.po ]; then
59                 if $KEEP_OLD; then
60                         msgmerge -q -N <(msgconv -t UTF-8 $MY_LANG.po | msgattrib --no-obsolete -) *.pot -C -
61                 else
62                         msgmerge -q -N - <(msgconv -t UTF-8 $MY_LANG.po | msgattrib --no-obsolete -)
63                 fi | \
64                 msgattrib --no-obsolete -
65         else
66                 cat
67         fi | \
68         if $APPLY; then
69                 sponge $MY_LANG.po
70         else
71                 diff -u --label $MY_LANG.po <(msgconv -t UTF-8 $MY_LANG.po) -
72         fi