#!/bin/bash
#
# Author: Runa A. Sandvik, <runa.sandvik@gmail.com>
# For The Tor Project, Inc.
#
# This is Free Software (GPLv3)
# http://www.gnu.org/licenses/gpl-3.0.txt
#
# This script will convert translated po files back to manpages. Before
# running the script, checkout the translation directory from
# https://svn.torproject.org, and clone the tor repository from
# git.torproject.org.
#
### Start config ###
# Location of the translated manpages
translated="$PWD"
# Location of the website directory
wml="`dirname $translated`"
# Location of the English manpages. Assuming that the git clone of the
# tor repository is relative to the website
mandir="`dirname $wml`/tor/doc"
# Location of the po files. Assuming that the translation directory is
# relative to the website
podir="`dirname $wml`/translation/projects/manpages/po"
### End config ###
# Find po files to convert
po=`find $podir -type f -name \*.1.po`
# For every po found, create and/or update the translated manpage.
for file in $po ; do
# Validate input and write results to a log file
validate_script="/home/runa/tor/translation/tools/validate.py"
validate_log="/home/runa/tor/validate/manpages-validate.log"
python "$validate_script" -i "$file" -l "$validate_log"
# Get the basename of the file we are dealing with
pofile=`basename $file`
# Strip the file for its original extension and add .txt
manfile="${pofile%.*}.txt"
# Figure out which language we are dealing with.
lang=`dirname $file | sed "s#$podir/##"`