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 \
58 --keyword=fgettext_ne \
59 --keyword=strgettext \
60 --keyword=wstrgettext \
61 --keyword=showTranslatedStatusText \
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
75 # This will ask for the translator identity
76 echo "[$lang]: NEW strings"
77 msginit
--locale=$lang --output-file=$pofile --input=$potfile