]> git.lizzy.rs Git - minetest.git/blob - util/updatepo.sh
Fix a README mistake on option SPATIAL_LIBRARY (#13162)
[minetest.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="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
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 \
52         --add-comments='~' \
53         --sort-by-file \
54         --add-location=file \
55         --keyword=N_ \
56         --keyword=wgettext \
57         --keyword=fwgettext \
58         --keyword=fgettext \
59         --keyword=fgettext_ne \
60         --keyword=strgettext \
61         --keyword=wstrgettext \
62         --keyword=core.gettext \
63         --keyword=showTranslatedStatusText \
64         --keyword=fmtgettext \
65         --output $potfile \
66         --from-code=utf-8 \
67         `find src/ -name '*.cpp' -o -name '*.h'` \
68         `find builtin/ -name '*.lua'`
69
70 # Now iterate on all languages and create the po file if missing, or update it
71 # if it exists already
72 for lang in $langs ; do # note the missing quotes around $langs
73         pofile=po/$lang/minetest.po
74         if test -e $pofile; then
75                 echo "[$lang]: updating strings"
76                 msgmerge --update --sort-by-file $pofile $potfile
77         else
78                 # This will ask for the translator identity
79                 echo "[$lang]: NEW strings"
80                 msginit --locale=$lang --output-file=$pofile --input=$potfile
81         fi
82 done