]> git.lizzy.rs Git - minetest-m13.git/blob - util/updatepo.sh
Update code style to C++11
[minetest-m13.git] / util / updatepo.sh
1 #!/bin/sh
2
3 # Update/create minetest po files
4
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
10 }
11
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")")"
17
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/.."
23
24 test -e po || abort "po/ directory not found"
25 test -d po || abort "po/ is not a directory!"
26
27 # Get a list of the languages we have to update/create
28
29 cd po || abort "couldn't change directory to po!"
30
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=""
36
37 for lang in * ; do
38         if test ! -d $lang; then
39                 continue
40         fi
41         langs="$langs $lang"
42 done
43
44 # go back
45 cd ..
46
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 -kN_ -kwgettext -F -n -o $potfile src/*.cpp src/*.h
52
53 # Now iterate on all languages and create the po file if missing, or update it
54 # if it exists already
55 for lang in $langs ; do # note the missing quotes around $langs
56         pofile=po/$lang/minetest.po
57         if test -e $pofile; then
58                 echo "[$lang]: updating strings"
59                 msgmerge -F -U $pofile $potfile
60         else
61                 # This will ask for the translator identity
62                 echo "[$lang]: NEW strings"
63                 msginit -l $lang -o $pofile -i $potfile
64         fi
65 done