#!/bin/bash -e
LANG=$1

for doci in en/*.1; do
  docfilename=${doci#*/}
  doc=${docfilename%.*}
  if [[ $LANG == "" ]]; then
    for i in *.po
    do
       ILANG=${i%.*}
       echo "Producing man "$doc" for locale "$ILANG
       po4a-translate -k 0 --format man --master-charset utf-8 --localized-charset utf-8 \
         --master en/${doc}.1 --po $ILANG.po --localized $ILANG/${doc}.1
    done
  else
    echo "Producing man of "$doc" for locale "$LANG
    po4a-translate -k 0 --format man --master-charset utf-8 --localized-charset utf-8 \
      --master en/${doc}.xml --po $LANG.po --localized $LANG/${doc}.1
  fi
done
