X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=gosa-core%2Fupdate-locale;h=e93a247064e584c0ae48f877d5779f88cdbe8487;hb=1d023cf88eb787c06ca928914caff5e28c29500d;hp=4d69d1553fcd3cc17a7ebbe73868f1131612e94d;hpb=47d9abbc98056723fcde3131a70713d6fd075d8d;p=gosa.git diff --git a/gosa-core/update-locale b/gosa-core/update-locale index 4d69d1553..e93a24706 100755 --- a/gosa-core/update-locale +++ b/gosa-core/update-locale @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash generate_po() { ORIG=`pwd` @@ -29,23 +29,20 @@ generate_po() { mv $class.new $class done - echo "* converting strings from gosa.conf" - sed -e 's/headline="\([^"]*\)"//g;s/name="\([^"]*\)"//g' contrib/gosa.conf > contrib/gosa.conf.new - mv contrib/gosa.conf.new contrib/gosa.conf - echo "Extracting languages..." - rm locale/messages.po - (echo contrib/gosa.conf; find . -name '*.[ctpi][ophn][nlpc]') | xgettext -f - --keyword=must -d Domain -L PHP -n -o locale/messages.po + [ -f locale/${l_path}messages.po ] && rm locale/${l_path}messages.po + find . -name '*.[ctpi][ophn][nlpc]' | xgettext -f - --keyword=must -d Domain -L PHP -n -o locale/${l_path}messages.po echo "Merging po files with existing ones" error=0 - for f in locale/??/LC_MESSAGES; do + for f in locale/${l_path}??/LC_MESSAGES; do + [[ "$f" == "locale/${l_path}??/LC_MESSAGES" ]] && break echo -n "* merging $f/messages.po: " - [ -f $f/messages.po ] && msgmerge $f/messages.po locale/messages.po --output-file=$f/messages.po.new &> /dev/null + [ -f $f/messages.po ] && msgmerge $f/messages.po locale/${l_path}messages.po --output-file=$f/messages.po.new &> /dev/null # Do an extra check for dummy dir 'locale/en/LC_MESSAGES' if [ $? -ne 0 ]; then - [ "$f" == "locale/en/LC_MESSAGES" ] && $TRUE + [ "$f" == "locale/${l_path}en/LC_MESSAGES" ] && $TRUE fi if [ $? -eq 0 ]; then @@ -58,15 +55,13 @@ generate_po() { done echo "Copying new po files, making backups..." - find . -name messages.po | while read f; do + find locale/${l_path} -name messages.po | while read f; do if [ -f $ORIG/$f ]; then mv $ORIG/$f $ORIG/$f.orig - else - continue fi - echo $f | grep -q "locale/messages.po" + echo $f | grep -q "locale/${l_path}messages.po" if [ $? -ne 0 ]; then echo "* replaced $ORIG/$f" cp $f.new $ORIG/$f @@ -115,44 +110,21 @@ EOF popd &> /dev/null } -compile_po() -{ - po='messages.po' - mo='messages.mo' - - echo "Compiling po files..." - for f in locale/??/LC_MESSAGES; do - - if [ -f $f/$po ]; then - echo "* compiling $f/$po" - msgfmt $f/$po -o $f/$mo - else - echo "! skipped $f/$po - does not exist" - error=1 - continue - fi - - done -} - # # MAIN # GENERATE=0 -COMPILE=0 ASSUME_Y=0 -while getopts ":cgyh" opt +while getopts ":gyh" opt do case $opt in - c) COMPILE=1 - ;; g) GENERATE=1; ;; y) ASSUME_Y=1; ;; h|--help) - echo "Usage: $(basename $0) [-c] [-g] [-y]" - echo " -c compile existing po files into mo files" + echo "Usage: $(basename $0) [-g] [-y] method" + echo " method can be 'core' or 'plugin'" echo " -g extract strings from GOsa and generate po files" echo " -y assume yes" exit 1 @@ -161,12 +133,22 @@ do done shift $(($OPTIND - 1)) +# Check method +if [ "$1" != "plugin" -a "$1" != "core" ]; then + echo "Need explicit method 'core' or 'plugin' to create locale." + exit 1 +fi +if [ "$1" == "plugin" ]; then + l_path="" +else + l_path="core/" +fi + # Default to generate -if [ $GENERATE -eq 0 -a $COMPILE -eq 0 ]; then +if [ $GENERATE -eq 0 ]; then GENERATE=1 fi [ $GENERATE -eq 1 ] && generate_po -[ $COMPILE -eq 1 ] && compile_po # vim:tabstop=2:expandtab:shiftwidth=2:syntax:ruler: