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