Follow-up to r29036: Now that the "mergeinfo" transaction file is no
[svn.git] / tools / po / po-update.sh
blobf8b839e41adfda843a7ec4e122648e92e6b651ec
1 #!/bin/sh
3 # Usage:
4 # ./po-update.sh pot
5 # - to generate just the pot file
6 # ./po-update.sh
7 # - to update all locales
8 # ./po-update.sh LL
9 # - to update one the LL locale
11 set -e
13 XGETTEXT=${XGETTEXT:-xgettext}
14 MSGMERGE=${MSGMERGE:-msgmerge}
16 svn_base=
17 for i in . .. ../..; do
18 if [ -d "$i/subversion/po" ]; then
19 svn_base="$i"
20 break
22 done
23 if [ -z "$svn_base" ]; then
24 echo "E: You must run po-update.sh from within a Subversion source tree." >&2
25 exit 1
28 pot_done=
30 make_pot()
32 if [ -z "$pot_done" ]; then
33 echo "Building subversion.pot..."
34 (cd $svn_base/subversion/po && \
35 find .. \
36 -name .svn -prune -or \
37 -name tests -prune -or \
38 -name bindings -prune -or \
39 -name "*.c" -print -or \
40 -name "svn_error_codes.h" -print | \
41 $XGETTEXT --sort-by-file -k_ -kN_ -kSVN_ERRDEF:3 \
42 --flag=_:1:pass-c-format \
43 --flag=N_:1:pass-c-format \
44 --flag=svn_cmdline_printf:2:c-format \
45 --flag=svn_cmdline_fprintf:3:c-format \
46 --flag=svn_error_createf:3:c-format \
47 --flag=svn_error_wrap_apr:2:c-format \
48 --flag=svn_stream_printf:3:c-format \
49 --flag=svn_stream_printf_from_utf8:4:c-format \
50 --flag=svn_string_createf:2:c-format \
51 --flag=svn_string_createv:2:c-format \
52 --flag=svn_stringbuf_createf:2:c-format \
53 --flag=svn_stringbuf_createv:2:c-format \
54 --flag=svn_fs_bdb__dberrf:3:c-format \
55 --flag=file_printf_from_utf8:3:c-format \
56 --flag=do_io_file_wrapper_cleanup:3:c-format \
57 --flag=do_io_file_wrapper_cleanup:4:c-format \
58 --msgid-bugs-address=dev@subversion.tigris.org \
59 --add-comments --files-from=- -o subversion.pot )
60 pot_done=1
64 update_po()
66 (cd $svn_base/subversion/po &&
67 for i in $1.po; do
68 echo "Updating $i..."
69 # In a display of truly bizarre behaviour, msgmerge (at least, the
70 # GNU gettext-tools 0.14.6 implementation) inverts the order of obsolete
71 # messages every time it is run. Therefore, run it twice, to invert and
72 # then re-invert, to minimize spurious diffs.
73 $MSGMERGE --sort-by-file --no-wrap --update $i subversion.pot
74 $MSGMERGE --sort-by-file --no-wrap --update $i subversion.pot
75 done )
78 if [ $# -eq 0 ]; then
79 make_pot
80 update_po \*
81 else
82 langs=
83 while [ $# -ge 1 ]; do
84 case $1 in
85 pot) ;;
87 if [ -e $svn_base/subversion/po/$1.po ]; then
88 langs="$langs $1"
89 else
90 echo "E: No such .po file '$1.po'" >&2
91 exit 1
93 esac
94 shift
95 done
96 make_pot
97 for lang in $langs; do
98 update_po $lang
99 done