#!/bin/sh

# This should solve issues with debiandoc for Polish quotation
# Any global fix can be done similary.

# $1 locale (lower case)
# $2 directory

locale=$1
dir=$2

cd $dir

case $locale in
("pl")
	for xx in *.html ;
	do
		perl -i -p -e 's/##AMP##/&#/g;' $xx
	done
	;;					
("zh-tw")
	for xx in *.html ;
	do
		perl -i -p -e 's/(|`)\n/$1 /s;' $xx
		perl -i -p -e 's/(|`)\s*(\w+(?:\.\w*)*)(\s|\<)/ $2 $1$3/g;'  $xx
	done
	;;					
(*)
	: # do nothing
;;
esac

# Correct words in which accents such as '' where replaced by 'e' to be
# compatible with the encoding. (Let's hope that there's no linebreak in
# the text which is to substitute, but it seems to be as in .sgml files.)
# This is related to qref only!
for file in *.html; do
  sed -e 's/Bartosz Fenski/Bartosz Fe\&#x0144;ski/g' \
      -e 's/Radoslaw Grzanka/Rados\&#x0142;aw Grzanka/g' \
      -e 's/Rafal Michaluk/Rafa\&#x0142; Michaluk/g' \
      -e 's/Tomasz Z.  Napierala/Tomasz Z.  Napiera\&#x0142;a/g' \
      -e 's/Tomasz Piekos/Tomasz Pi\&#x0119;ko\&#x015B;/g' \
      -e 's/Pawel Rozanski/Pawe\&#x0142; R\&oacute;\&#x017C;a\&#x0144;ski/g' \
      -e 's/Krzysztof Scierski/Krzysztof \&#x015A;cierski/g' \
      -e 's/Przemyslaw Adam Smiejek/Przemys\&#x0142;aw Adam \&#x015A;miejek/g'\
      -e 's/Bartosz Zapalowski/Bartosz Zapa\&#x0142;owski/g'\
      -e 's/pour le francais/pour le fran\&ccedil;ais/g' $file > $file.tmp
   mv $file.tmp $file
done
