[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[or-cvs] r22429: {} a directory for the translated manpages with a template wml (in website/trunk: . manpages)
Author: runa
Date: 2010-05-27 17:25:58 +0000 (Thu, 27 May 2010)
New Revision: 22429
Added:
website/trunk/manpages/
website/trunk/manpages/po2man.sh
website/trunk/manpages/tor-manual-dev.wml
Log:
a directory for the translated manpages with a template wml and a script
Added: website/trunk/manpages/po2man.sh
===================================================================
--- website/trunk/manpages/po2man.sh (rev 0)
+++ website/trunk/manpages/po2man.sh 2010-05-27 17:25:58 UTC (rev 22429)
@@ -0,0 +1,115 @@
+#!/bin/bash
+#
+# Author: Runa A. Sandvik, <runa.sandvik@xxxxxxxxx>
+# 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"
+
+### 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
+
+ # 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/##"`
+
+ # The translated document is written if 80% or more of the po
+ # file has been translated. Also, po4a-translate will only write
+ # the translated document if 80% or more has been translated.
+ # However, it will delete the translated txt if less than 80%
+ # has been translated. To avoid having our current, translated
+ # txt files deleted, convert the po to a temp txt first. If this
+ # file was actually written, rename it to txt.
+
+ # Convert translated po files back to manpages.
+ function convert {
+ po4a-translate -f text -m "$mandir/$manfile" -p "$file" -l "$translated/$lang/tmp-$manfile" --master-charset utf-8 -L utf-8
+
+ # Check to see if the file was written. If yes, rename
+ # it.
+ if [ -e "$translated/$lang/tmp-$manfile" ]
+ then
+ mv "$translated/$lang/tmp-$manfile" "$translated/$lang/$manfile"
+
+ # If tor.1.po has been translated, we need to
+ # create tor-manual-dev.wml in the correct
+ # language directory.
+ if [ $manfile = "tor.1.txt" ]
+ then
+ if [ ! -e "$wml/$lang/tor-manual.wml" ]
+ then
+ # Copy template file for
+ # tor-manual-dev.wml, and
+ # replace "lang" with the
+ # correct name of the language
+ # directory.
+ cp "$translated/tor-manual-dev.wml" "$wml/$lang"
+ sed -i "0,/lang/ s/lang/"$lang"/" "$wml/$lang/tor-manual-dev.wml"
+ fi
+ fi
+ fi
+ }
+
+ # We have a few cases where the name of the language directory
+ # in the translations module is not equal the name of the
+ # language directory in the website module.
+
+ # For "zh_CN" use "zh-cn" instead
+ if [ $lang = "zh_CN" ]
+ then
+ lang="zh-cn"
+ convert
+ fi
+
+ # For "nb" use "no" instead
+ if [ $lang = "nb" ]
+ then
+ lang="no"
+ convert
+ fi
+
+ # For "sv" use "se" instead
+ if [ $lang = "sv" ]
+ then
+ lang="se"
+ convert
+ fi
+
+ # Convert everything else
+ if [[ $lang != "zh_CN" && $lang != "nb" && $lang != "sv" ]]
+ then
+ convert
+ fi
+done
Property changes on: website/trunk/manpages/po2man.sh
___________________________________________________________________
Added: svn:executable
+ *
Added: website/trunk/manpages/tor-manual-dev.wml
===================================================================
--- website/trunk/manpages/tor-manual-dev.wml (rev 0)
+++ website/trunk/manpages/tor-manual-dev.wml 2010-05-27 17:25:58 UTC (rev 22429)
@@ -0,0 +1,21 @@
+## translation metadata
+# Revision: $Revision: 21567 $
+
+#include "head.wmi" TITLE="Tor: manual"
+
+# Translators shouldn't translate this file, unless they want
+# to translate the whole man page too.
+
+<div class="main-column">
+
+<:
+ die "Missing git clone" unless -d "$(TORGIT)";
+ my $man = `cat manpages/lang/tor.1.txt | asciidoc -d manpage -s -o - -`;
+ die "No manpage because of asciidoc error or file not available from git" unless $man;
+
+ print $man;
+:>
+
+</div><!-- #main -->
+
+#include <foot.wmi>