incrementaltp: respect physics overrides
[waspsaliva.git] / util / updatepo.sh
blob168483bd44ea2f1370bf55f9534fab21d18d0b85
1 #!/bin/sh
3 # Update/create minetest po files
5 # an auxiliary function to abort processing with an optional error
6 # message
7 abort() {
8 test -n "$1" && echo >&2 "$1"
9 exit 1
12 # The po/ directory is assumed to be parallel to the directory where
13 # this script is. Relative paths are fine for us so we can just
14 # use the following trick (works both for manual invocations and for
15 # script found from PATH)
16 scriptisin="$(dirname "$(which "$0")")"
18 # The script is executed from the parent of po/, which is also the
19 # parent of the script directory and of the src/ directory.
20 # We go through $scriptisin so that it can be executed from whatever
21 # directory and still work correctly
22 cd "$scriptisin/.."
24 test -e po || abort "po/ directory not found"
25 test -d po || abort "po/ is not a directory!"
27 # Get a list of the languages we have to update/create
29 cd po || abort "couldn't change directory to po!"
31 # This assumes that we won't have dirnames with space, which is
32 # the case for language codes, which are the only subdirs we expect to
33 # find in po/ anyway. If you put anything else there, you need to suffer
34 # the consequences of your actions, so we don't do sanity checks
35 langs=""
37 for lang in * ; do
38 if test ! -d $lang; then
39 continue
41 langs="$langs $lang"
42 done
44 # go back
45 cd ..
47 # First thing first, update the .pot template. We place it in the po/
48 # directory at the top level. You a recent enough xgettext that supports
49 # --package-name
50 potfile=po/minetest.pot
51 xgettext --package-name=minetest \
52 --add-comments='~' \
53 --sort-by-file \
54 --add-location=file \
55 --keyword=N_ \
56 --keyword=wgettext \
57 --keyword=fgettext \
58 --keyword=fgettext_ne \
59 --keyword=strgettext \
60 --keyword=wstrgettext \
61 --keyword=showTranslatedStatusText \
62 --output $potfile \
63 --from-code=utf-8 \
64 `find src/ -name '*.cpp' -o -name '*.h'` \
65 `find builtin/ -name '*.lua'`
67 # Now iterate on all languages and create the po file if missing, or update it
68 # if it exists already
69 for lang in $langs ; do # note the missing quotes around $langs
70 pofile=po/$lang/minetest.po
71 if test -e $pofile; then
72 echo "[$lang]: updating strings"
73 msgmerge --update --sort-by-file $pofile $potfile
74 else
75 # This will ask for the translator identity
76 echo "[$lang]: NEW strings"
77 msginit --locale=$lang --output-file=$pofile --input=$potfile
79 done