Code

Updating spanish admin manual at 20050714
[gosa.git] / gen_locale.sh
1 #!/bin/sh
3 ORIG=`pwd`
4 TEMPDIR="/tmp/gosa-locale"
6 echo
7 echo "Creating temporary directory..."
8 [ -d $TEMPDIR ] && rm -rf $TEMPDIR
9 mkdir $TEMPDIR
11 echo "Creating copy of GOsa..."
12 tar c . | tar x -C $TEMPDIR
14 echo -n "Converting .tpl files: "
15 pushd . &> /dev/null
16 cd $TEMPDIR
18 for template in $(find -name '*.tpl'); do
19   echo -en "\rConverting .tpl files: $(basename $template)                 \r"
20   sed -e 's/{t}/<?php $t= _("/g;s!{/t}!");?>!g' $template > $template.new
21   mv $template.new $template
22 done
24 for class in $(find -name 'class_*.inc'); do
25   echo -en "\rConverting .tpl files: $(basename $template)                 \r"
26   sed -e 's/\($pl[DH][^=]*\)= *"\([^"]*\)";$/\1= _("\2");/g' $class > $class.new
27   mv $class.new $class
28 done
29 echo -e "\rConverting .tpl files: done                    "
31 echo "Converting strings from gosa.conf..."
32 sed -e 's/headline="\([^"]*\)"/<?php $headline=_("\1");?>/g;s/name="\([^"]*\)"/<?php $t= _("\1");?>/g' contrib/gosa.conf > contrib/gosa.conf.new
33 mv contrib/gosa.conf.new contrib/gosa.conf
35 echo "Extracting languages..."
36 rm locale/messages.po
37 (echo contrib/gosa.conf; find . -name '*.[ctpi][ophn][nlpc]') | xgettext -f - --omit-header --keyword=must -d Domain -L PHP -n -o locale/messages.po
39 echo "Merging po files with existing ones:"
40 error=0
41 for f in locale/??/LC_MESSAGES; do
42   echo -n "* merging $f/messages.po: "
43   msgmerge $f/messages.po locale/messages.po --output-file=$f/messages.po.new &> /dev/null
44   
45   if [ $? -eq 0 ]; then
46     echo "done";
47   else
48     echo "failed";
49     error=1
50   fi
52 done
54 echo "Copying new po files, making backups:"
55 find . -name messages.po | while read f; do
57   if [ -f $ORIG/$f ]; then
58     mv $ORIG/$f $ORIG/$f.orig
59   else
60     echo "! skipped $ORIG/$f because of errors during the conversation"
61     error=1
62     continue
63   fi
65   echo $f | grep -q "locale/messages.po"
66   if [ $? -ne 0 ]; then
67     echo "* replaced $ORIG/$f"
68     cp $f.new $ORIG/$f
69   else
70     cp $f $ORIG/$f
71   fi
73 done
75 rm -rf $TEMPDIR
77 echo
78 if [ $error -eq 0 ]; then
79   read -p "Do you want to erase the message.po.orig files? (y/n)" -n1 ans
81   if [ "$ans" == "y" -o "$ans" == "Y" ]; then
82     find $ORIG -type f -name 'messages.po.orig' -exec rm -f {} \;
83   fi
85 else
86   echo "There were errors during the transition. Please fix!"
87   exit 1
88 fi
90 cat << EOF
92 ---------------------------------------------------------------------
94 Now edit all files that have been replaced above (i.e. using kbabel)
95 and mail the changes to gosa@oss.gonicus.de to be included in the
96 next release.
98 To see the changes you've made in GOsa, run "msgfmt messages.po" on
99 your freshly edited files and restart your apache after that. Set
100 the webbrowser to the language you've edited and go back to the
101 login screen.
103 ---------------------------------------------------------------------
104 EOF
106 popd &> /dev/null
108 # vim:tabstop=2:expandtab:shiftwidth=2:syntax:ruler: