Code

Removed div list for users
[gosa.git] / gosa-core / update-locale
index fce0d7db318ab4fa988c26bef7ec915a3fef5001..a0363215c8a3d3e511a9d0ad43f4698b0055e6f9 100755 (executable)
@@ -23,6 +23,12 @@ generate_po() {
     mv $template.new $template
   done
 
+  for template in $(find . -name '*.xml'); do
+    echo "* converting .xml files: $(basename $template)"
+    sed -e 's/<label>/<?php $t= _("/g;s!</label>!");?>!g' $template > $template.new
+    mv $template.new $template
+  done
+
   for class in $(find . -name 'class_*.inc'); do
     echo "* converting class_*.inc files: $(basename $class)"
     sed -e 's/\($pl[DH][^=]*\)= *"\([^"]*\)";$/\1= _("\2");/g' $class > $class.new
@@ -31,7 +37,7 @@ generate_po() {
 
   echo "Extracting languages..."
   [ -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
+  find . -name '*.[ctpix][mophn][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
@@ -39,7 +45,18 @@ generate_po() {
     [[ "$f" == "locale/${l_path}??/LC_MESSAGES" ]] && break
     echo -n "* merging $f/messages.po: "
     [ ! -f $f/messages.po ] && touch $f/messages.po
-    msgmerge $f/messages.po locale/${l_path}messages.po --output-file=$f/messages.po.new &> /dev/null
+
+    # If we're in a plugin of a trunk checkout, we can use the gosa-all messages.po as a dictionary
+    DICT_FILE_ALL="$ORIG/../../gosa-all/gosa/${f/locale/locale/core}/messages.po"
+    DICT_FILE_CORE="$ORIG/../../gosa-core/${f/locale/locale/core}/messages.po"
+    DICT=""
+    [ -r $DICT_FILE_ALL ] && DICT="-C $DICT_FILE_ALL"
+    [ ${#DICT} -eq 0 ] && [ -r $DICT_FILE_CORE ] && DICT="-C $DICT_FILE_CORE"
+    msgmerge $DICT $f/messages.po locale/${l_path}messages.po --output-file=$f/messages.po.tmp &> /dev/null
+
+    # Filter out duplicates
+    msguniq $f/messages.po.tmp --output-file=$f/messages.po.new &> /dev/null
+    rm $f/messages.po.tmp
 
     # Do an extra check for dummy dir 'locale/en/LC_MESSAGES'
     if [ $? -ne 0 ]; then