#!/bin/sh
#
# Run this script in the top level directory to create the translated man pages:
#
# Once the TP module has been created, this command gets the latest po files:
# echo "Getting the latest translations from translationproject.org..."
# rsync -Lrtvz  translationproject.org::tp/latest/parted-man/  man
# rsync -Lrtvz  translationproject.org::tp/latest/parted-texi/  texi

# This threshold is the minumum percentage of translated strings per resulting
# document (not per po file). It defaults to 80 and can be screwed down for
# testing purposes, even to zero. But keep in mind, users doesn't really
# benefit from translations with less than 80%, so better keep the default.
threshold=10

cd doc/man

for lang in *.po
  do
  if [ -d ${lang%.*} ] ; then
  echo "${lang%.*}: directory exists, will be reused"
  else
    mkdir -p man/${lang%.*}/man8
  fi
    po4a-translate -f man -k ${threshold} -m ../C/parted.8 -p ${lang} -l man/${lang%.*}/man8/parted.8
    po4a-translate -f man -k ${threshold} -m ../C/partprobe.8 -p ${lang} -l man/${lang%.*}/man8/partprobe.8

done

cd ../texi

for lang in *.po
  do
    po4a-translate -f texinfo -k ${threshold} -m ../parted.texi -p ${lang} -l parted-${lang%.*}.texi

done