source: trunk/i18n.sh @ 705

Revision 705, 1.4 KB checked in by fma, 5 years ago (diff)

Rebuild po/mo file only if modified

  • Property svn:executable set to *
Line 
1#/bin/sh
2
3APP_NAME="papywizard"
4TMP_DIR="tmp"
5POT_FILE="$APP_NAME.pot"
6PO_FILE="$APP_NAME.po"
7MO_FILE="$APP_NAME.mo"
8LOCALE_DIR="locale"
9
10mkdir -p $TMP_DIR
11
12# Extract strings from python files
13python_files="scripts/papywiz.py"
14python_files="$python_files `find papywizard -type f -name \"*.py\"`"
15
16xgettext --language=Python --from-code=utf-8 --default-domain=$APP_NAME --keyword=_ --no-wrap --output=$TMP_DIR/$APP_NAME $python_files
17
18# Extract strings from glade files
19glade_files=`ls papywizard/view/*.glade`
20for file in $glade_files; do
21    intltool-extract -l --type=gettext/glade $file
22done
23
24xgettext --language=Python --from-code=utf-8 --default-domain=$APP_NAME --keyword=_ --keyword=N_ --no-wrap --output=$TMP_DIR/$POT_FILE $python_files $TMP_DIR/*.h
25
26# Generate PO and MO files
27for lang in 'en' 'fr'; do
28    if [ $LOCALE_DIR/$lang/LC_MESSAGES/$PO_FILE -nt $LOCALE_DIR/$lang/LC_MESSAGES/$MO_FILE ]; then
29        mkdir -p $LOCALE_DIR/$lang/LC_MESSAGES
30        if [ -e $LOCALE_DIR/$lang/LC_MESSAGES/$PO_FILE ]; then
31            msgmerge -U $LOCALE_DIR/$lang/LC_MESSAGES/$PO_FILE $TMP_DIR/$POT_FILE
32        else
33            msginit --input=$TMP_DIR/$POT_FILE --locale=$lang --no-translator --no-wrap --output=$LOCALE_DIR/$lang/LC_MESSAGES/$PO_FILE
34        fi
35        msgfmt -v --output-file=$LOCALE_DIR/$lang/LC_MESSAGES/$MO_FILE $LOCALE_DIR/$lang/LC_MESSAGES/$PO_FILE
36    fi
37done
Note: See TracBrowser for help on using the repository browser.