Code

- Update of french locale for dhcp plugin
[gosa.git] / gen_locale.sh
1 #!/bin/sh
3 ORIG=`pwd`
4 TEMPDIR="/tmp/gosa-locale"
5 TRUE=`which true`
7 echo
8 echo "Creating temporary directory..."
9 [ -d $TEMPDIR ] && rm -rf $TEMPDIR
10 mkdir $TEMPDIR
12 echo "Creating copy of GOsa..."
13 tar c . | tar x -C $TEMPDIR
15 echo -n "Converting .tpl files: "
16 pushd . &> /dev/null
17 cd $TEMPDIR
19 for template in $(find . -name '*.tpl'); do
20   echo -en "\rConverting .tpl files: $(basename $template)                 \r"
21   sed -e 's/{t}/<?php $t= _("/g;s!{/t}!");?>!g' $template > $template.new
22   mv $template.new $template
23 done
25 for class in $(find . -name 'class_*.inc'); do
26   echo -en "\rConverting class_*.inc files: $(basename $template)                 \r"
27   sed -e 's/\($pl[DH][^=]*\)= *"\([^"]*\)";$/\1= _("\2");/g' $class > $class.new
28   mv $class.new $class
29 done
30 echo -e "\rConverting .tpl files: done                    "
32 echo "Converting strings from gosa.conf..."
33 sed -e 's/headline="\([^"]*\)"/<?php $headline=_("\1");?>/g;s/name="\([^"]*\)"/<?php $t= _("\1");?>/g' contrib/gosa.conf > contrib/gosa.conf.new
34 mv contrib/gosa.conf.new contrib/gosa.conf
36 echo "Extracting languages..."
37 rm locale/messages.po
38 (echo contrib/gosa.conf; find . -name '*.[ctpi][ophn][nlpc]') | xgettext -f - --keyword=must -d Domain -L PHP -n -o locale/messages.po
40 echo "Merging po files with existing ones:"
41 error=0
42 for f in locale/??/LC_MESSAGES; do
43   echo -n "* merging $f/messages.po: "
44   [ -f $f/messages.po ] && msgmerge $f/messages.po locale/messages.po --output-file=$f/messages.po.new &> /dev/null
46   # Do an extra check for dummy dir 'locale/en/LC_MESSAGES'
47   if [ $? -ne 0 ]; then
48     [ "$f" == "locale/en/LC_MESSAGES" ] && $TRUE
49   fi
51   if [ $? -eq 0 ]; then
52     echo "done";
53   else
54     echo "failed";
55     error=1
56   fi
58 done
60 echo "Copying new po files, making backups:"
61 find . -name messages.po | while read f; do
63   if [ -f $ORIG/$f ]; then
64     mv $ORIG/$f $ORIG/$f.orig
65   else
66     echo "! skipped $ORIG/$f because of errors during the conversation"
67     error=1
68     continue
69   fi
71   echo $f | grep -q "locale/messages.po"
72   if [ $? -ne 0 ]; then
73     echo "* replaced $ORIG/$f"
74     cp $f.new $ORIG/$f
75   else
76     cp $f $ORIG/$f
77   fi
79 done
81 rm -rf $TEMPDIR
83 echo
84 if [ $error -eq 0 ]; then
85   read -p "Do you want to erase the message.po.orig files? (y/n)" -n1 ans
87   if [ "$ans" == "y" -o "$ans" == "Y" ]; then
88     find $ORIG/ -type f -name 'messages.po.orig' -exec rm -f {} \;
89   fi
91 else
92   echo "There were errors during the transition. Please fix!"
93   exit 1
94 fi
96 cat << EOF
98 ---------------------------------------------------------------------
100 Now edit all files that have been replaced above (i.e. using kbabel
101 or gtranslator) and mail the changes to gosa@oss.gonicus.de to be 
102 included in the next release.
104 To see the changes you've made in GOsa, run "msgfmt messages.po" on
105 your freshly edited files and restart your apache after that. Set
106 the webbrowser to the language you've edited and go back to the
107 login screen.
109 ---------------------------------------------------------------------
110 EOF
112 popd &> /dev/null
114 # vim:tabstop=2:expandtab:shiftwidth=2:syntax:ruler: