1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798 |
- #!/bin/sh
- abort() {
- test -n "$1" && echo >&2 "$1"
- exit 1
- }
- if [[ -n $1 ]] && [[ ! $1 == "--po" ]]; then
- abort "'$1' is not a valid option"
- fi
- scriptisin="$(dirname "$(which "$0")")"
- # Commands below are executed from the parent of po/, which is also the
- # parent of this script's directory and of the src/ directory.
- # We go through $scriptisin so that this script can be executed from whatever
- # directory and still work correctly
- cd "$scriptisin/.."
- test -e po || abort "po/ directory not found"
- test -d po || abort "po/ should be a directory, but is not!"
- # Create a list of the languages we have to update/create.
- # This assumes that we won't have dirnames with spaces, which is
- # the case for language codes, which are the only subdirs we expect to
- # find in po/ anyway. If you put anything else there, you need to suffer
- # the consequences of your actions, so we don't do sanity checks
- cd po || abort "couldn't change directory to po!"
- langs=""
- for lang in * ; do
- if test ! -d $lang; then
- continue
- fi
- langs="$langs $lang"
- done
- # First thing first, update the .pot template. We place it in the po/
- # directory at the top level.
- echo "updating the pot file"
- # go to parent dir of po/ and src/
- cd ..
- potfile=po/voxelands.pot
- xgettext --package-name=voxelands --copyright-holder="Lisa 'darkrose' Milne" -kN_ -kwgettext -F -n -o $potfile src/*.cpp src/*.h
- # We just updated the pot file, now update po files if --po was specified.
- if [[ $1 == "--po" ]]; then
- # Now iterate on all language dirs in po/ and create the po file if
- # nonexistent, or update it if it exists already
- for lang in $langs ; do # note the missing quotes around $langs
- pofile=po/$lang/voxelands.po
- if test -e $pofile; then
- echo "[$lang]: updating strings"
- msgmerge -F -U $pofile $potfile
- else
- # This creates a new po file and asks for the translator's identity
- echo "[$lang]: creating $lang localization files"
- msginit -l $lang -o $pofile -i $potfile
- fi
- done
- fi
|