index 32ab55b2abc8544c7f24c76b55aa1fee7dd07896..65f4ec9d93a50636d03ece3b7498486dda29bf82 100755 (executable)
--- a/gosa-core/update-locale
+++ b/gosa-core/update-locale
-#!/bin/sh
+#!/bin/bash
generate_po() {
ORIG=`pwd`
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
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
- for f in locale/${l_path}??/LC_MESSAGES; do
- [[ "$f" == "locale/${l_path}??/LC_MESSAGES" ]] && break
+ 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/${l_path}messages.po --output-file=$f/messages.po.new &> /dev/null
+ [ ! -f $f/messages.po ] && touch $f/messages.po
+
+ # 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
y) ASSUME_Y=1;
;;
h|--help)
- echo "Usage: $(basename $0) [-g] [-y] method"
- echo " method can be 'core' or 'plugin'"
+ echo "Usage: $(basename $0) [-g] [-y]"
echo " -g extract strings from GOsa and generate po files"
echo " -y assume yes"
exit 1
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
+# If there's a plugin.dsc in ., then assume "plugin"
+if [ -f plugin.dsc ]; then
l_path=""
else
l_path="core/"