X-Git-Url: http://git.inspyration.org/?a=blobdiff_plain;f=gen_translations.sh;h=996ff1754e52018473edbac77b7f473bfc708d18;hb=11dd44ec360d4130c824bda10bd2bee1f8a31a2c;hp=62460c397d2beb9d65f205b11b8fb631cce43e74;hpb=a8286263fffb76d0117ebb62715f83caf1aad938;p=odoo%2Fodoo.git diff --git a/gen_translations.sh b/gen_translations.sh index 62460c3..996ff17 100755 --- a/gen_translations.sh +++ b/gen_translations.sh @@ -2,12 +2,13 @@ usage() { cat << EOF -usage: $0 -a -usage: $0 DIR OUTPUT_FILE +usage: $0 -a [DIR] +usage: $0 OPTIONS: - -a recreate the .pot file for all addons - -h print this message + -a [DIR] export the .pot files for all web addons found + at target path (default: ./addons) + -h print this message EOF exit 0 } @@ -30,21 +31,33 @@ shift $((OPTIND-1)) if [ -n "$do_all" ] then - echo "Extracting all the translations" + if [ "x$(which msgcat)" = "x" ] + then + echo "The msgcat command from the gettext tools is required in the PATH." + echo "On a Debian/Ubuntu system you may install gettext via 'sudo apt-get install gettext'" + exit 1 + fi + + echo "Extracting all web addons translations" executable=$0 - extract_module() { - $executable addons/$1 addons/$1/po/$1.pot - } - extract_module web - extract_module web_calendar - extract_module web_dashboard - extract_module web_diagram - extract_module web_gantt - extract_module web_graph - extract_module web_hello - extract_module web_chat - extract_module web_mobile - extract_module web_rpc + target_dir=${1:-./addons} + echo "Using target dir: ${target_dir}" + for mod in $(find ${target_dir} -type d -name 'static' -exec sh -c 'basename $(dirname {})' \;); do + echo ${mod} + mod_pot=${target_dir}/${mod}/i18n/${mod}.pot + web_pot=${mod_pot}.web + mkdir -p $(dirname ${web_pot}) + $executable ${target_dir}/${mod} ${web_pot} + if [ -f "${mod_pot}" ]; then + echo "Merging with existing PO file: ${mod_pot}" + msgcat --force-po -o "${mod_pot}.tmp" ${mod_pot} ${web_pot} + mv ${mod_pot}.tmp ${mod_pot} + rm ${web_pot} + else + echo "Renaming to final PO file: ${mod_pot}" + mv ${web_pot} ${mod_pot} + fi + done elif [ -n "$2" ] then ./npybabel.py extract -F babel.cfg -o $2 -k _t -k _lt --no-default-keywords $1