#!/usr/bin/perl # This is an experimental tool script to create a nice HTML page from the CATS database to help translating # a test into another language and to review the result. # Adjust the test id of the language you want to translate into (look for $sth_q->execute), probably modify # the header of the page, then start the script with the database password as parameter. use strict; use DBI; sub PrintHeader { print <<'ENDHEADER';

Translation Sheet for CATS Test CZ

Please verify that the translation conserves the intention of the english text. It does not have to be a word-by-word translation. Links may be adjusted to point to translated content, if available.

The grayed out questions are currently disabled, so they won't be shown and translating them is purely optional. Don't worry about true/false answers, those are translated automatically by CATS.

Forward information about typos and bad language to the translator. Normally such issues should not block publication of the translation, unless the mistakes are quite serious.

Note: The lines of english and translated answers do not necessarily match, since the link between the answers was only recently implemented...

ENDHEADER } sub PrintFooter { print <<'ENDFOOTER'; ENDFOOTER } my $dsn="DBI:mysql:database=cats_db"; my $dbh = DBI->connect($dsn, "cats_user", $ARGV[0]); PrintHeader(); my $sth_aen = $dbh->prepare( "SELECT a_en.a_id IDEN, a_en.answer TEXTEN ". " FROM answers a_en". " WHERE a_en.q_id=?". " ORDER BY a_en.a_id" ); my $sth_alg = $dbh->prepare( "SELECT a_lg.a_id IDLG, a_lg.answer TEXTLG, a_lg.ref_a_id REF ". " FROM answers a_lg". " WHERE a_lg.q_id=?". " ORDER BY a_lg.ref_a_id" ); my $sth_q = $dbh->prepare( "SELECT q_en.q_id IDEN, q_lg.q_id IDLG, q_en.question Q_EN, q_lg.question Q_LG, ". " qd_en.description DESCEN, qd_lg.description DESCLG, ". " q_en.active ACTIVEEN, q_lg.active ACTIVELG ". " FROM questions q_lg left outer join questions q_en on (q_en.q_id=q_lg.ref_q_id) ". " LEFT OUTER JOIN question_description qd_en ON (qd_en.q_id=q_en.q_id) ". " LEFT OUTER JOIN question_description qd_lg ON (qd_lg.q_id=q_lg.q_id) ". " WHERE q_lg.t_id=? ". " ORDER BY q_en.q_id"); $sth_q->execute(9); # for language cz #$sth_q->execute(5); # for language fr while(my $ref = $sth_q->fetchrow_hashref()) { print '
'."\n"; print "
{ACTIVEEN} != 1 || $ref->{ACTIVELG} != 1); print "\">
$ref->{Q_EN}
$ref->{Q_LG}
\n"; print "
{ACTIVEEN} != 1 || $ref->{ACTIVELG} != 1); print "\">
$ref->{DESCEN}
$ref->{DESCLG}
\n"; $sth_aen->execute($ref->{IDEN}); $sth_alg->execute($ref->{IDLG}); while(my $ref2 = $sth_aen->fetchrow_hashref()) { my $ref3 = $sth_alg->fetchrow_hashref(); print "
{ACTIVEEN} != 1 || $ref->{ACTIVELG} != 1); print "\">"; print "
$ref2->{IDEN}
$ref2->{TEXTEN}
"; print "
$ref3->{IDLG}($ref3->{REF})
$ref3->{TEXTLG}
"; print "
\n"; } print "
\n"; } PrintFooter();