spaghetti
I am, in a weird way, quite proud of this hideous abomination:
pushd doc
# italian is already unicode, leave it out.
for i in es hu pl ru sr; do pushd $i; \
# this is ugly, but assume same encoding as .po file for each language.
iconv --from-code=`grep charset= ../../po/$i.po | cut -c36- | head -c-4 | tr "[:lower:]" "[:upper:]"` --to-code=UTF-8 mc.1.in > mc.1.in.new; \
mv -f mc.1.in.new mc.1.in; popd; done
popd
pushd lib
# rename zh to zh_TW, which is what it really is (I think)
mv mc.hint.zh mc.hint.zh_TW
# hardcode the list as we need to leave italian out and it just gets ugly doing it 'smartly'...
for i in cs es hu nl pl ru sr uk zh_TW; \
# this is ugly, but assume same encoding as .po file for each language.
do iconv --from-code=`grep charset= ../po/$i.po | cut -c36- | head -c-4 | tr "[:lower:]" "[:upper:]"` --to-code=UTF-8 mc.hint.$i > mc.hint.$i.new; \
mv -f mc.hint.$i.new mc.hint.$i; done
popd
pushd po
# remove the original .mo files
rm -f *.gmo
# find stuff that's not Unicode already
for i in `file *.po | grep -v Unicode | cut -d: -f1`; \
# convert it: the grep, cut, head, tr grabs the source encoding from the .po file header, there's no other way to find it
do iconv --from-code=`grep charset= $i | cut -c36- | head -c-4 | tr "[:lower:]" "[:upper:]"` --to-code=UTF-8 $i > $i.new; \
# change the header to say UTF-8
mv -f $i.new $i; perl -pi -e 's,charset=.*$,charset=UTF-8\\n",g' $i; done
# regenerate the .mo files
for i in `ls *.po | cut -d. -f1`; do /usr/bin/msgfmt -c --statistics -o $i.gmo $i.po; done
popd
that's what you need to do to convert all of mc's documentation, help files etc to Unicode when packaging it. Elegance, I've heard of it...
Comments