#!/bin/sh # Convert all locales to utf-8. Not only is this probably the right thing # to do anyway, but SquirrelMail will corrupt charsets unless the charset # of the user's locale is a superset of the charset of any mail they reply to # https://sf.net/tracker/?func=detail&atid=423691&aid=1235345&group_id=311 sed -io -e "s/^\(\$languages\['\([^']*\)'\]\['CHARSET'].*= '\)\([^']*\)';/\1utf-8';/" \ -e "s/^\(\$languages\['\([^']*\)'\]\['LOCALE'].*=\).*/\1 '\2.UTF-8';/" functions/i18n.php # Hard-code Japanese to send iso-2022-jp due to XTRA_CODE hacks in SquirrelMail sed -io s/"$languages\['ja_JP'\]\['CHARSET'\] = 'utf-8';"/"$languages\['ja_JP'\]\['CHARSET'\] = 'iso-2022-jp';"/ functions/i18n.php rm -f functions/i18n.phpo for LOCALE in `ls locale/ | grep -v '[.]'` ; do SKIPINVALID= case $LOCALE in ja_JP) # ja_JP uses iso2022-jp for email but euc-jp in its interface. # Better don't touch this... continue ;; ko_KR) # ko_KR has broken help files in indeterminate charset. # Assume it's _mostly_ EUC-KR as it's supposed to be, and let # iconv drop invalid characters from the input. SKIPINVALID=-c ;; *) ;; esac CHARSET=`grep CHARSET locale/$LOCALE/setup.php | cut -f6 -d\'` # Check for locales where CHARSET isn't in LOCALE. #grep LOCALE locale/$LOCALE/setup.php | grep -vi $CHARSET || : if [ "$CHARSET" != "utf-8" -a "$CHARSET" != "UTF-8" ]; then for a in `ls help/$LOCALE/ 2>/dev/null` ; do iconv $SKIPINVALID -f $CHARSET -t utf-8 help/$LOCALE/$a > $a.new mv $a.new help/$LOCALE/$a done sed -e "s/CHARSET..[ ]*= [^;]*;/CHARSET'] = 'utf-8';/" \ -e "s/LOCALE..[ ]*= [^;]*;/LOCALE'] = '$LOCALE.UTF-8';/" \ locale/$LOCALE/setup.php > setup.php.new mv setup.php.new locale/$LOCALE/setup.php fi done # do the pofiles separately since they each specify their own charset for POFILE in `find locale -name \*.po` ; do CHARSET=`grep charset= $POFILE | cut -f2 -d= | cut -f1 -d\\\\` if [ "$CHARSET" != "utf-8" -a "$CHARSET" != "UTF-8" ]; then sed s/charset=$CHARSET/charset=utf-8/ $POFILE | iconv -f $CHARSET -t utf-8 > $POFILE.new && mv $POFILE.new $POFILE fi done for POFILE in `find . -name \*.po` ; do msgfmt $POFILE -c -o `echo $POFILE | sed s/\.po\$/.mo/` done