Skip to content

Instantly share code, notes, and snippets.

@y-ogi
Created December 6, 2011 06:12
Show Gist options
  • Save y-ogi/1436986 to your computer and use it in GitHub Desktop.
Save y-ogi/1436986 to your computer and use it in GitHub Desktop.
i18n helper shell
#!/bin/bash
RETVAL=0
TARGET=$2
PYTHON_BIN=/usr/bin/python2.5
NKF_BIN=/opt/local/bin/nkf
dircheck() {
if [ -d "$1" ]; then
return 1
else
echo "dirname $1 does not exist"
return 0
fi
}
generate() {
if dircheck "$TARGET"; then
RETVAL=1
return
fi
echo "Extract messages..."
$PYTHON_BIN manage.py extract_messages $TARGET
echo "Update translations..."
$PYTHON_BIN manage.py update_translations $TARGET -l ja
$PYTHON_BIN manage.py update_translations $TARGET -l en
echo "Change line ends..."
$NKF_BIN --overwrite -Lw $TARGET/i18n/messages.pot
$NKF_BIN --overwrite -Lw $TARGET/i18n/ja/LC_MESSAGES/messages.po
$NKF_BIN --overwrite -Lw $TARGET/i18n/en/LC_MESSAGES/messages.po
}
compile() {
if dircheck "$TARGET"; then
RETVAL=1
return
fi
echo "Compile translations..."
$PYTHON_BIN manage.py compile_translations $TARGET
}
usage() {
echo "Usage..."
echo "$0 (generate|compile) [target]"
}
case $1 in
generate)
generate
;;
compile)
compile
;;
*)
usage
RETVAL=255
esac
exit $RETVAL
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment