Code

Macro setting will be saved in Extension_table for asterisk
[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   [ -f $f/messages.po ] && msgmerge $f/messages.po locale/messages.po --output-file=$f/messages.po.new &> /dev/null || /bin/true
44   if [ $? -eq 0 ]; then
45     echo "done";
46   else
47     echo "failed";
48     error=1
49   fi
51 done
53 echo "Copying new po files, making backups:"
54 find . -name messages.po | while read f; do
56   if [ -f $ORIG/$f ]; then
57     mv $ORIG/$f $ORIG/$f.orig
58   else
59     echo "! skipped $ORIG/$f because of errors during the conversation"
60     error=1
61     continue
62   fi
64   echo $f | grep -q "locale/messages.po"
65   if [ $? -ne 0 ]; then
66     echo "* replaced $ORIG/$f"
67     cp $f.new $ORIG/$f
68   else
69     cp $f $ORIG/$f
70   fi
72 done
74 rm -rf $TEMPDIR
76 echo
77 if [ $error -eq 0 ]; then
78   read -p "Do you want to erase the message.po.orig files? (y/n)" -n1 ans
80   if [ "$ans" == "y" -o "$ans" == "Y" ]; then
81     find $ORIG -type f -name 'messages.po.orig' -exec rm -f {} \;
82   fi
84 else
85   echo "There were errors during the transition. Please fix!"
86   exit 1
87 fi
89 cat << EOF
91 ---------------------------------------------------------------------
93 Now edit all files that have been replaced above (i.e. using kbabel)
94 and mail the changes to gosa@oss.gonicus.de to be included in the
95 next release.
97 To see the changes you've made in GOsa, run "msgfmt messages.po" on
98 your freshly edited files and restart your apache after that. Set
99 the webbrowser to the language you've edited and go back to the
100 login screen.
102 ---------------------------------------------------------------------
103 EOF
105 popd &> /dev/null
107 # vim:tabstop=2:expandtab:shiftwidth=2:syntax:ruler: