Παρασκευή, Αυγούστου 05, 2005

Using translation memories

As I was translating to English an article of Simos Xenitellis about creating translating memories, I wrote the following script:

#! /bin/bash
echo -n "Receiving the statistic's webpages"
wget -O desktop.html http://l10n-status.gnome.org/gnome-2.12/el/desktop/index.html

wget -O developer-libs.html http://l10n-status.gnome.org/gnome-2.12/el/developer-libs/index.html

echo -n "Press any key to continue"
read -e
echo -n "Receiving po files"

grep 'el.po' desktop.html developer-libs.html | awk -F\" '{print $6}' | sort | uniq | awk '{printf "wget http://l10n-status.gnome.org/gnome-2.12/el/desktop/%s\n", $1}' | sh

echo -n "Press any key to continue"
read -e
echo -n "Creating the directories"
mkdir GNOME050805
mv *.el.po GNOME050805
echo -n "Press any key to continue"
read -e
echo -n "Creating the translation file"
msgcat -o GNOME050805.compendium GNOME050805/*.el.po
echo -n "Press any key to continue"
read -e
echo -n "Using the compendium with an empty translation"
msgmerge --compendium GNOME212.05Aug2005.compendium -o el.po /dev/null file.pot


The last command is used for an empty translation. The alternative (for a file that contains translated messages) is the following :

% msgcat --use-first -o update.po GNOME050805.compendium file.po
% msgmerge update.po file.pot | sed -e '/^#~/d' > file.po

without the char %.

Be careful because the grep...sh must be written in one line, it is not three commands.
The script can be optimized with parameters like the name of the new directory and the target file(empty or not), with checkings about the existence of the directory and the "dependance" of wget and gettext etc.

For more information you can see here and here. The greek articles can be found here and here.

2 σχόλια:

Simon είπε...

Μπορείς να προσθέσεις

TMVERSION=`date '+%d%h%y'`

οπότε να καθορίζεται αυτόματα η ημερομηνία της μεταφραστικής μνήμης.
Το χρησιμοποιείς στον κώδικα ως $TMVERSION.

Petros είπε...

Σε ευχαριστώ.
Οπότε το σενάριο εντολών είναι έτσι:

#! /bin/bash
echo -n "Receiving the statistic's webpages"
wget -O desktop.html http://l10n-status.gnome.org/gnome-2.12/el/desktop/index.html

wget -O developer-libs.html http://l10n-status.gnome.org/gnome-2.12/el/developer-libs/index.html

echo -n "Press any key to continue"
read -e
echo -n "Receiving po files"

grep 'el.po' desktop.html developer-libs.html | awk -F\" '{print $6}' | sort | uniq | awk '{printf "wget http://l10n-status.gnome.org/gnome-2.12/el/desktop/%s\n", $1}' | sh

echo -n "Press any key to continue"
read -e
echo -n "Creating the directories"

TMVERSION=`date '+%d%h%y'`
mkdir GNOME.$TMVERSION
mv *.el.po GNOME.$TMVERSION
echo -n "Press any key to continue"
read -e
echo -n "Creating the translation file"
msgcat -o GNOME.$TMVERSION.compendium GNOME.$TMVERSION/*.el.po
echo -n "Press any key to continue"
read -e
echo -n "Using the compendium with an empty translation"
msgmerge --compendium GNOME212.$TMVERSION.compendium -o el.po /dev/null file.pot