3 # Update/create minetest po files
5 # an auxiliary function to abort processing with an optional error
8 test -n "$1" && echo >&2 "$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
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
38 if test ! -d $lang; then
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
50 potfile=po/minetest.pot
51 xgettext --package-name=minetest \
57 --keyword=strgettext \
58 --keyword=wstrgettext \
60 `find src/ -name '*.cpp' -o -name '*.h'` \
61 `find builtin/ -name '*.lua'`
63 # Now iterate on all languages and create the po file if missing, or update it
64 # if it exists already
65 for lang in $langs ; do # note the missing quotes around $langs
66 pofile=po/$lang/minetest.po
67 if test -e $pofile; then
68 echo "[$lang]: updating strings"
69 msgmerge --update --sort-by-file $pofile $potfile
71 # This will ask for the translator identity
72 echo "[$lang]: NEW strings"
73 msginit --locale=$lang --output-file=$pofile --input=$potfile