[Debian-l10n-commits] [SCM] DDTP - Debian Descriptions Translation Project branch, master, updated. 20080812.0-116-g9d06ac3
Martijn van Oosterhout
kleptog at svana.org
Sat Jun 16 16:48:25 UTC 2012
The following commit has been merged in the master branch:
commit 9068fc67fc9ae5d5efde0e5ad4995ba6da423718
Author: Martijn van Oosterhout <kleptog at svana.org>
Date: Fri Jun 15 18:09:09 2012 +0200
Add changes to DDTSS accumulated over a long period. This includes, amongst other things:
- rosettaimport
- messages
- suggestions
- counting translations
diff --git a/ddtss/ddts_lib.pm b/ddtss/ddts_lib.pm
index 210b3b7..fcbcb00 100644
--- a/ddtss/ddts_lib.pm
+++ b/ddtss/ddts_lib.pm
@@ -41,6 +41,21 @@ my $mADDRwithUserName = qr/([ "\<\>\(\)\w+\.\@-]+)/;
# Must be greater than zero, otherwise we'll keep fetching the same description over and over
my $OWNER_EXPIRE = 15;
+sub get_parttrans ($) {
+ my $milestone = shift;
+
+ my @packages=();
+
+ my $sth = $dbh->prepare("SELECT package from description_milestone_tb join active_tb on description_milestone_tb.description_id=active_tb.description_id join description_tb on description_milestone_tb.description_id=description_tb.description_id where milestone=? order by package");
+ $sth->execute("$milestone");
+
+ my $package;
+ while(($package) = $sth->fetchrow_array) {
+ push @packages,"$package";
+ }
+ return (@packages);
+}
+
# This is _copied_ from /org/ddtp.debian.net/ddts.cgi
sub get_versions ($) {
my $desc_id = shift;
diff --git a/ddtss/ddtss-cgi b/ddtss/ddtss-cgi
index ec4b594..a52adb1 100755
--- a/ddtss/ddtss-cgi
+++ b/ddtss/ddtss-cgi
@@ -1,24 +1,33 @@
-#!/usr/bin/perl -wT
+#!/usr/bin/perl
use strict;
# This is the installation directory
use lib '/org/ddtp.debian.net/ddtss';
-use DDTSS;
+use DDTSS_Pg;
use LWP::Simple;
#use Text::Iconv;
use CGI qw/escapeHTML/;
use Encode;
+use Digest::MD5 qw(md5_hex);
$ENV{TZ} = "Europe/Amsterdam";
my $stylesheet = "/ddtss/ddtss.css";
-my @html_headers = ( -encoding => "UTF-8", -style => {-src => $stylesheet} );
+my $JSCRIPT=<<END;
+function popup (url) {
+ fenster = window.open(url, \"Popupfenster\", \"width=400,height=300,resizable=yes\");
+ fenster.focus();
+ return false;
+}
+END
+my @html_headers = ( -encoding => "UTF-8", -style => {-src => $stylesheet}, -script =>$JSCRIPT);
my $q = new CGI;
my $user = $q->cookie("id");
my $lang = "";
my $logged_in = 0;
+my $is_admin = 0;
#$user = "kleptog:S7xgBKLo,xx";
#$user = "80.61.178.170,xx";
@@ -45,6 +54,7 @@ $lang ||= 'xx';
my $path = $ENV{PATH_INFO} || '/';
# Later $self is overwritten for the per language page, so keep a copy of the real thing
my $self = $ENV{SCRIPT_NAME} || 'local';
+my $http_host = $ENV{HTTP_HOST} || 'local';
if( defined $q->param("_charset_") and uc($q->param("_charset_")) ne "UTF-8" )
{
@@ -76,6 +86,22 @@ elsif( $path eq "/logout" )
{
display_logout();
}
+elsif( $path eq "/rosettaimport" )
+{
+ rosettaimport();
+}
+elsif( $path =~ m,^/suggestion/([\d]+)$, )
+{
+ suggestion_display($1);
+}
+elsif( $path =~ m,^/messageto/([\w+.]+)$, )
+{
+ messageto_display($1);
+}
+elsif( $path =~ m,^/delmessage/([\d]+)$, )
+{
+ delmessage_display($1);
+}
elsif( $path eq "/createlogin" )
{
display_createlogin();
@@ -99,6 +125,10 @@ elsif( $path =~ m:^/(\w{2,5})(/.*)?$: )
{
main_display();
}
+ elsif( $path =~ m,^/forexternalreview/([-\w+.]+)$, )
+ {
+ forexternalreview_display($1);
+ }
elsif( $path =~ m,^/translate/([-\w+.]+)$, )
{
translate_display($1,$2);
@@ -161,6 +191,203 @@ sub wordlist_display
$q->end_html();
}
+sub delmessage_display
+{
+ my $msg_count = $1;
+
+ my $db = DDTSS_Open_Write();
+
+ if( not $logged_in )
+ {
+ display_error("You must logged in for this action!");
+ exit;
+ }
+
+ $user =~ s/:.*//;
+ my $s_messages="";
+ $db->get("aliases/$user/messages", $s_messages );
+ my @messages=split /~,~/,$s_messages;
+ my $del_msg=splice(@messages,$msg_count,1);
+ $s_messages=join ("~,~", at messages);
+ $db->put("aliases/$user/messages", $s_messages );
+ DDTSS_Close($db);
+
+ goto_main_display("Message was removed");
+ exit;
+}
+
+sub suggestion_display
+{
+ my $suggestion_id = $1;
+
+ my $db = DDTSS_Open_Write();
+
+ my %suggestion = DDTSS_Get_Suggestion_Infos($db,$suggestion_id);
+ my $msg;
+
+ $user =~ s/:.*//;
+
+ if( defined $q->param("comment") )
+ { $db->put("suggestion/$suggestion_id/comment", $q->param("comment") ); }
+
+ # If they asked to do nothing, then do nothing
+ if( defined $q->param("nothing") )
+ {
+ DDTSS_Log( $db, "suggestion/$suggestion_id/log", time()." change-comment-only by $user" );
+ DDTSS_Close($db);
+ goto_main_display("Changed comment only for suggestion $suggestion_id");
+ exit;
+ }
+
+ if( not $logged_in )
+ {
+ if (( defined $q->param("refuse") ) or ( defined $q->param("accept") )) {
+ $msg="For 'refuse' and 'accept' you need to login";
+ }
+ $q->delete('refuse','accept');
+ }
+
+ if( not DDTSS_Check_Valid_Language($db,$suggestion{'language'}) )
+ {
+ DDTSS_Close($db);
+ display_langlist();
+ return;
+ }
+
+ my $log=0;
+ $db->get("suggestion/$suggestion_id/log", $log );
+
+ my $comment = "";
+ $db->get("suggestion/$suggestion_id/comment", $comment);
+
+ if( defined $q->param("refuse") )
+ {
+ $suggestion{'refuse'}++;
+ $db->put("suggestion/$suggestion_id/refuse", $suggestion{'refuse'});
+ DDTSS_Log( $db, "suggestion/$suggestion_id/log", time()." refuse by $user" );
+ DDTSS_Close($db);
+ goto_main_display("Save refuse vote for suggestion $suggestion_id");
+ exit;
+ }
+
+ if( defined $q->param("accept") )
+ {
+ $suggestion{'refuse'}=100;
+ $db->put("suggestion/$suggestion_id/refuse", $suggestion{'refuse'});
+
+ my ($data, $short, $long, $oldshort, $oldlong);
+ if( own_a_description($suggestion{'description_id'},$suggestion{'language'},$user) == 0 )
+ {
+ $data= get_untrans_file_from_db($suggestion{'language'},$user,($suggestion{'description_id'}));
+ }
+ if( $data !~ /^# Package[^:]*: ([\w.+-]+)/m )
+ {
+ display_error( "Fetched description didn't contain package name -$data-$suggestion{'language'},$user,$suggestion{'description_id'}-" );
+ exit;
+ }
+ ($short, $long) = ($suggestion{'suggestion'} =~ /^Description-[^:]*: (.*)\n((?: .*\n)+)/m);
+ ($oldshort, $oldlong) = ($suggestion{'translation'} =~ /^Description-[^:]*: (.*)\n((?: .*\n)+)/m);
+ my $iter = 0;
+ $db->get("$suggestion{'language'}/packages/$suggestion{'package'}/iter", $iter );
+ $iter++;
+ $db->put("$suggestion{'language'}/packages/$suggestion{'package'}/comment", "the old suggestion comment:\n".$comment);
+ $db->put("$suggestion{'language'}/packages/$suggestion{'package'}", "forreview" );
+ $db->put("$suggestion{'language'}/packages/$suggestion{'package'}/timestamp", time() );
+ $db->put("$suggestion{'language'}/packages/$suggestion{'package'}/data", $data );
+ $db->put("$suggestion{'language'}/packages/$suggestion{'package'}/short", $short);
+ $db->put("$suggestion{'language'}/packages/$suggestion{'package'}/long", $long);
+ $db->put("$suggestion{'language'}/packages/$suggestion{'package'}/owner", $user);
+ $db->put("$suggestion{'language'}/packages/$suggestion{'package'}/oldshort", $oldshort);
+ $db->put("$suggestion{'language'}/packages/$suggestion{'package'}/oldlong", $oldlong);
+ $db->put("$suggestion{'language'}/packages/$suggestion{'package'}/log", "the old suggestion log:\n".$log."--- new log ---\n");
+ $db->del("$suggestion{'language'}/packages/$suggestion{'package'}/reviewers");
+
+ $db->put( "aliases/$user/timestamp", time() );
+ $db->put( "aliases/$user/lastlanguage", $lang );
+
+ DDTSS_Log( $db, "suggestion/$suggestion_id/log", time()." accept by $user" );
+ DDTSS_Close($db);
+ goto_main_display("Save accept vote for suggestion $suggestion_id");
+ exit;
+ }
+
+ print $q->header( -type =>'text/html', -charset => "UTF-8", -expires => '+1s' ),
+ $q->start_html( -title => "DDTSS: Work on the suggestion $suggestion_id", @html_headers ),
+ (defined $msg ? $q->h1($q->font({-color => 'red'}, escapeHTML $msg)) : ''),
+ $q->h1("Work on the suggestion $suggestion_id");
+ print $q->ul(
+ map { $q->li( $q->tt( $_ ) ) }
+ ("# Source: $suggestion{'source'}","# Package(s): $suggestion{'packages'}","# Prioritize: $suggestion{'prioritize'}","# Versions: $suggestion{'versions'}","# Submitter: $suggestion{'importer'}","# Importtime: $suggestion{'importtime'}",,"# Import-md5sum: $suggestion{'description_md5'}","# Import-Package: $suggestion{'package'}","# Import-Version: $suggestion{'version'}","# Refuses: $suggestion{'refuse'}")
+ );
+ print $q->start_table(),
+ $q->TR( $q->th ($q->h5("english description")), $q->th ($q->h5("diff"))),
+ $q->TR( $q->td ($q->pre($suggestion{'description'})), $q->td($q->pre(make_colour_diff($suggestion{'translation'},$suggestion{'suggestion'})))),
+ $q->TR( $q->th ($q->h5("translated description")), $q->th ($q->h5("suggested description"))),
+ $q->TR( $q->td ($q->pre($suggestion{'translation'})), $q->td ($q->pre($suggestion{'suggestion'}))),
+ $q->end_table();
+ print $q->start_form( { -method => 'post' } ),
+ "Comment field: (free form, for discussion about translation.<br>\n",
+ $q->textarea(-name => "comment", -default => $comment, -columns => 75, -rows => 4),
+ $q->br,
+ $q->submit(-name => "refuse", -label => "Refuse the suggestion"),
+ $q->submit(-name => "nothing", -label => "Change comment only"),
+ $q->submit(-name => "accept", -label => "Use the suggestion"),
+ $q->end_form();
+ print $q->br("Log: ".$q->pre("$log")) ;
+
+ print $q->end_html();
+
+ DDTSS_Close($db);
+
+}
+
+sub messageto_display
+{
+ my $to_user = $1;
+
+ my $db = DDTSS_Open_Write();
+
+ if( not $logged_in )
+ {
+ $q->delete('submit','message');
+ }
+
+ if( defined $q->param("submit") and defined $q->param("message"))
+ {
+ my $s_messages="";
+ $db->get("aliases/$to_user/messages", $s_messages );
+ $s_messages.="~,~" if $s_messages;
+ $user =~ s/:.*//;
+ $s_messages.="($user,".time()."):".$q->param("message");
+ $db->put("aliases/$to_user/messages", $s_messages );
+
+ print $q->header( -type =>'text/html', -charset => "UTF-8", -expires => '+1h' ),
+ $q->start_html( -title => "Write a message to $to_user", @html_headers ),
+ $q->h1("Message was sent to $to_user"),
+ "<form action=\"\">
+ <input type=\"button\" value=\"close window\" onclick=\"self.close()\">
+ </form>";
+ print $q->end_html();
+
+ DDTSS_Close($db);
+ exit;
+ }
+
+ DDTSS_Close($db);
+
+ print $q->header( -type =>'text/html', -charset => "UTF-8", -expires => '+1h' ),
+ $q->start_html( -title => "Write a message to $to_user", @html_headers ),
+ $q->h1("Message to $to_user");
+
+ print $q->start_form( { -method => 'post' } ),
+ $q->textarea(-name => "message", -columns => 45, -rows => 4),
+ $q->br,
+ $q->submit( {-name => "submit", -label => 'send message' } ),
+ $q->end_form();
+
+ print $q->end_html();
+}
+
sub display_langlist
{
my $db = DDTSS_Open_Read();
@@ -187,7 +414,7 @@ sub display_langlist
$q->start_html( -title => "DDTSS", @html_headers ),
$q->h1("DDTSS"),
$q->p("The DDTSS (DDTS Satellite or Debian Distributed Translation Server Satellite) is a web frontend to the DDTS email server. It provides facilities to request translations, enter a translation and review other peoples translations. Afterwards the updated translation can be sent via email to the DDTS server."),
- $q->p({-style => 'color: #ff0000'}, "Scheduled downtime: around 13:00 UTC on the 29th of August."),
+ $q->p({-style=>'color: #ff0000'}, "Scheduled downtime: 08:00-10:00 UTC on 5 June 2011"),
$q->p("The DDTSS was created by Martijn van Oosterhout <kleptog (at) svana.org>.\n"),
$q->p("More information about the DDTP and the DDTSS can be found ", $q->a({-href => 'http://www.debian.org/international/l10n/ddtp'},"here")."." );
print $q->h1("Select a language:"),
@@ -230,10 +457,33 @@ sub main_display
my $untranslated = DDTSS_Get_Untranslated($db,$lang,$user);
my $forreview = DDTSS_Get_ForReview($db,$lang,$user);
my $translated = DDTSS_Get_Translated($db,$lang);
+ my $suggestion = DDTSS_Get_Suggestions($db,$lang);
+
+ my $counttranslations=0;
+ $db->get("aliases/$user/counttranslations", $counttranslations );
+ my $countreviews=0;
+ $db->get("aliases/$user/countreviews", $countreviews );
+ my $realname="";
+ $db->get("aliases/$user/realname", $realname );
# Split into reviewed and unreviewed (by the user ofcourse)
my $reviewed = [ grep { not $_->[2] } @$forreview ];
$forreview = [ grep { $_->[2] } @$forreview ];
+
+ my $s_messages="";
+ $db->get("aliases/$user/messages", $s_messages );
+ $s_messages =~ s/\n/<br>/g;
+ my @messages = split /~,~/,$s_messages;
+
+ my $s_teammessages="";
+ $db->get("$lang/messages", $s_teammessages );
+ $s_teammessages =~ s/\n/<br>/g;
+ my @teammessages = split /~,~/,$s_teammessages;
+
+ my $s_projectmessages="";
+ $db->get("messages", $s_projectmessages );
+ $s_projectmessages =~ s/\n/<br>/g;
+ my @projectmessages = split /~,~/,$s_projectmessages;
my $requirelogin = 0;
my $minuntranslated = 5;
@@ -249,14 +499,50 @@ sub main_display
DDTSS_Close($db);
print $q->header( -type =>'text/html', -charset => "UTF-8", -refresh => "240; url=$self", -expires => '+10s', -cookie => $usercookie ),
- $q->start_html( -title => "DDTSS ($lang)", @html_headers, -xbase => $q->url(-base=>1)."$self/" );
+ $q->start_html( -title => "DDTSS ($lang)", @html_headers, -xbase => "http://$http_host$self/" );
print $q->h1("DDTSS for $lang");
- print $q->p("<div style='color: #ff0000'>The DDTSS has moved to a new system. Please report any issues to the <a href='mailto:debian-i18n\@lists.debian.org'>mailing list</a></div>");
+ print $q->p({-style=>'color: #ff0000'}, "Scheduled downtime: 08:00-10:00 UTC on 5 June 2011");
+
+# print "<div class=messages>\n",
+# $q->h3("Project-Messages (".scalar(@projectmessages)."):", help("Messages for the DDTP"));
+# @projectmessages=reverse (@projectmessages);
+ my $msg_count=scalar(@projectmessages);
+# @projectmessages=(splice (@projectmessages,0,5));
+# print (scalar(@projectmessages)
+# ? $q->ul(map {
+# my ($userfrom,$timestamp,$message) = ($_ =~ /\(([\w]+)(?:,([0-9]+))?\):(.*)/);
+# $msg_count--;
+# $q->li( "(".$q->a( {href=>"$realself/messageto/$userfrom", onclick=>"return popup(this.href)"}, "$userfrom" )."): ".localtime($timestamp)." ",(($is_admin) ? $q->a( {href=>"$realself/delprojectmessage/$msg_count"}, "DEL" ) : "" ),"<br>",$q->b($message));
+# } (@projectmessages) )
+# : "None"),
+# "</div>\n";
+
+ if( not $logged_in )
+ {
+ print $q->p($q->b("Please login... Only with a login, you can use all features! Go to " .
+ $q->a({-href => "$realself/login"}, "Login")
+ ));
+ };
print $q->p("The DDTSS is a queue-based system. New translations are automatically fetched only when there are only a few pending translation. Translations will only be sent off after they have received a certain amount of review. New translations will be fetched in priority order, so the goal is to get your priority numbers as low as possible!");
print $q->p("The rate of getting new descriptions to translate is not automatic. If you find you keep running low on things to translate, ask me to increase it.");
print $q->p( $q->a({-href => 'http://www.debian.org/international/l10n/ddtp#rules'}, "Common translation rules") );
+# print "<div class=messages>\n",
+# $q->h3("$lang-Team-Messages (".scalar(@teammessages)."):", help("Messages from your language team"));
+# @teammessages=reverse (@teammessages);
+# $msg_count=scalar(@teammessages);
+# @teammessages=(splice (@teammessages,0,5));
+# print (scalar(@teammessages)
+# ? $q->ul(map {
+# my ($userfrom,$timestamp,$message) = ($_ =~ /\((\w+)(?:,([0-9]+))?\):(.*)/);
+# $msg_count--;
+# $q->li( "(".$q->a( {href=>"$realself/messageto/$userfrom", onclick=>"return popup(this.href)"}, "$userfrom" )."): ".localtime($timestamp)." ",(($is_admin)
+# ? $q->a( {href=>"$realself/delteammessage/$msg_count"}, "DEL" ) : "" ),"<br>",$q->b($message));
+# } (@teammessages) )
+# : "None"),
+# "</div>\n";
+
if( $requirelogin )
{
print $q->p( "Note: this language requires a login to do edits. Please sign up to the language mailing list to learn the procedures before doing anything." );
@@ -266,6 +552,11 @@ sub main_display
{
$extra = $q->br().$q->a( {href=>"fetch"}, "Fetch new description" );
}
+ print $q->start_table(),
+ $q->col( { -width => '60%' }) ,
+ $q->col( { -width => '40%' }) ;
+# $q->col( { -width => '200px' } ) ;
+ print "<tr><td valign='top' >\n";
print "<div class=untranslated>\n",
$q->h2("Pending translation", help("List of descriptions needing translation.\nWhen you select a description, it will be locked for you for 15 minutes.")),
(scalar(@$forreview) > 15 ? $q->b("The number of translations pending review has gotten quite large.<br>Consider reviewing some translations first.") : ""),
@@ -285,6 +576,36 @@ sub main_display
? $q->ol(map { $q->li( $q->a({href=>"forreview/$_->[0]?$_->[3]"}, $_->[0]), $_->[1]) } @$forreview)
: "None"),
"</div>\n";
+# print "<div class=suggestion>\n",
+# $q->h2("Suggestions (".scalar(@$suggestion).") ", help("List of suggestions that need review.")),
+# (scalar(@$suggestion)
+# ? $q->ol(map { ( ($_->[5] < 4) ? $q->li( $q->a({href=>"$realself/suggestion/$_->[0]"}, $_->[1]), $_->[3], $_->[4]) : "" ) } @$suggestion)
+# : "None"),
+# "</div>\n";
+ print "</td><td valign='top' >\n";
+ print "<div class=infobox>\n",
+ $q->h2("Infos about $realname:", help("About your account, some stats,....")),
+ "<ul>\n";
+ print $q->li( "Account: ".$user);
+ print $q->li( "logged_in (" . $q->a({-href => "$realself/logout"}, "Logout") . ")") if ($logged_in);
+ print $q->li( "not logged in (" . $q->a({-href => "$realself/login"}, "Login") . ")") if (not $logged_in);
+ print $q->li( "Translations: $counttranslations");
+ print $q->li( "Reviews: $countreviews");
+ print "</ul>\n",
+ "</div>\n";
+ print "<div class=messages>\n",
+ $q->h2("Messages for you (".scalar(@messages).") ", help("Messages from other users for you"));
+ @messages=reverse (@messages);
+ $msg_count=scalar(@messages);
+ @messages=(splice (@messages,0,10));
+ print (scalar(@messages)
+ ? $q->ul(map {
+ my ($userfrom,$timestamp,$message) = ($_ =~ /\(([\w]+)(?:,([0-9]+))?\):(.*)/);
+ $msg_count--;
+ $q->li( "(".$q->a( {href=>"$realself/messageto/$userfrom", onclick=>"return popup(this.href)"}, "$userfrom" )."): ".localtime($timestamp)." ".$q->a( {href=>"$realself/delmessage/$msg_count"}, "DEL" )."<br>",$q->b($message));
+ } @messages )
+ : "None"),
+ "</div>\n";
print "<div class=reviewed>\n",
$q->h2("Reviewed by you (".scalar(@$reviewed).") ", help("List of translations you have already reviewed.\nYou can still make changes though.")),
(scalar(@$reviewed)
@@ -297,6 +618,8 @@ sub main_display
? $q->ol(map { $q->li( $q->a({href=>"translated/$_->[3]"}, $_->[0]), "($_->[1]) $_->[2]") } @$translated)
: "None"),
"</div>\n";
+ print "</td></tr>\n";
+ print $q->end_table();
print $q->a({-href => $self}, 'Refresh'),
" ",
$q->a({-href => "$realself/xx"}, "Another language"), # Illegal language triggers selection page
@@ -374,6 +697,7 @@ sub translate_display
# the lag between submission and acceptance.
if( $db->get("$lang/packages/$package", $state) )
{
+ DDTSS_Close($db);
print $q->header( -type =>'text/html', -refresh => "1; url=$self/fetch?package=$package" ),
$q->start_html( -title => "DDTSS", @html_headers ),
@@ -395,12 +719,16 @@ sub translate_display
if( $db->get($key, $data) )
{ display_error("Package translation for $package gone, sorry...\n" ) }
# print STDERR "line 374\n";
+ print STDERR "$key => $data\n";
my $msg;
if( defined $q->param("submit") )
{
$msg = submit_translation( $db, $package, $key, $q->param("short"), $q->param("long") );
if( not defined $msg )
{
+ my $count=0;
+ $db->get("aliases/$user/counttranslations", $count );
+ $db->put("aliases/$user/counttranslations", ++$count );
DDTSS_Unlock( $db, "$lang/packages/$package", $user );
DDTSS_Close($db);
# print STDERR "line 383\n";
@@ -424,7 +752,7 @@ sub translate_display
if( not defined $short )
{
print STDERR "Error retreiving template for $package($lang)\n";
- display_error("Internal error: Couldn't retreive translation template")
+ display_error("Internal error: Couldn't retreive translation template [\n$data\n]")
}
}
@@ -454,6 +782,178 @@ sub translate_display
}
# Display the screen that reviewers see
+sub forexternalreview_display
+{
+ my $package = shift;
+
+ $q->charset("UTF-8");
+
+ my $db = DDTSS_Open_Write();
+
+ if( not DDTSS_Check_Valid_Language($db,$lang) )
+ {
+ DDTSS_Close($db);
+ display_langlist();
+ return;
+ }
+
+ my $requirelogin = 0;
+
+ my($owner, $short, $long, $data, $reviewers, $timestamp );
+
+ my $msg = '';
+
+ # Description adjusted, submit new version ... (mailing list etc)
+ if( defined $q->param("submit") )
+ {
+ $msg = submit_externalreview( $db, $package, $q->param("short"), $q->param("long"), $q->param("comment").$q->param("NameEMail") );
+ if( not defined $msg )
+ {
+ DDTSS_Close($db);
+ goto_main_display("Changes and comments for $package sent to the team, thanks for your contribution");
+ exit;
+ }
+ }
+
+ eval {
+ $data = get_untrans( $lang, "", $package, "1" );
+ };
+
+ # Any error/warning procuded, display it
+ if( $@ )
+ {
+ display_error($@);
+ }
+ if( not defined $data )
+ {
+ display_error("Couldn't fetch an untranslated description: $lang, $package");
+ }
+
+ if( not defined $data or $data !~ /Description:/ or $data !~ /Description-[a-z_A-Z]+:/)
+ {
+ display_error("Couldn't fetch package description");
+ }
+
+ if( $data !~ /^# Package[^:]*: ([\w.+-]+)/m )
+ { display_error( "Fetched description didn't contain package name" ) }
+
+ eval {
+ my $str = Encode::decode_utf8($data, Encode::FB_CROAK);
+ };
+ if($@)
+ {
+ print STDERR "Encoding error ($@)\n";
+ print STDERR "Data: [$data]\n";
+ display_error("Encoding error retreiving data for package $package");
+ }
+ $data =~ s,^# patch http*,# patch http,m; # don't show patch-box
+
+ ($short, $long) = ($data =~ /^Description-$lang: (.*)\n((?: .*\n)+)/m);
+
+ my($oldshort,$oldlong,$diffshort,$difflong);
+
+ if( defined $oldshort and $short ne $oldshort )
+ {
+ $diffshort = make_colour_diff( $oldshort, $short );
+ }
+
+ if( defined $oldlong and $long ne $oldlong )
+ {
+ $difflong = make_colour_diff( $oldlong, $long );
+ }
+
+ my $trailer = $q->h5("Name and EMail-Address" ).
+ $q->ul(
+ $q->input( { -type => 'text', -size => 52, -name => 'NameEMail' } ),
+ $q->br(),
+ ("With a email-Address the translator team can contact you, if they have questions.")
+ ).
+ $q->br().
+ $q->submit(-name => "submit", -label => "Send to team").
+ $q->br().
+ ("'Send to team' send the changes and the comments to the translator team.");
+
+ my $comment = "";
+ DDTSS_Close($db);
+
+ display_translate_screen( $data, "External Reviewing $package", $msg, $comment, $trailer,
+ $short, $long, $diffshort, $difflong );
+}
+
+# Display the screen for the rosettaimort
+sub rosettaimport
+{
+ $q->charset("UTF-8");
+
+ my ($packagename, $version, $md5sum, $language, $translation);
+
+ if( defined $q->param("packagename") )
+ {
+ $packagename=$q->param("packagename");
+ } else {
+ display_error("no packagename defined");
+ exit;
+ }
+
+ if( defined $q->param("md5sum") )
+ {
+ $md5sum=$q->param("md5sum");
+ } else {
+ display_error("no md5sum defined");
+ exit;
+ }
+
+ if( defined $q->param("language") )
+ {
+ $language=$q->param("language");
+ } else {
+ display_error("no language defined");
+ exit;
+ }
+
+ if( defined $q->param("translation") )
+ {
+ $translation=$q->param("translation");
+ } else {
+ display_error("no translation defined");
+ exit;
+ }
+
+ if( defined $q->param("version") )
+ {
+ $version=$q->param("version");
+ } else {
+ display_error("no version defined");
+ exit;
+ }
+
+# my $db = DDTSS_Open_Write();
+#
+# if( not DDTSS_Check_Valid_Language($db,$lang) )
+# {
+# DDTSS_Close($db);
+# display_langlist();
+# return;
+# }
+
+ #my $requirelogin = 1;
+
+ $translation =~ s/\s+$//; # Trailing newlines
+ $translation =~ s/\r\n?/\n/g; # Fix line endings
+ $translation =~ s/[ \t]+$//mg;
+
+ my $importer="rosetta";
+ my $return=submit_one_suggestion($packagename,$version,$md5sum,$translation,$language,$importer);
+
+ if (defined($return)) {
+ display_error($return);
+ }
+
+ goto_main_display("Add as suggestion, thanks for your contribution");
+
+}
+
+# Display the screen that reviewers see
sub forreview_display
{
my $package = shift;
@@ -479,7 +979,11 @@ sub forreview_display
my($owner, $short, $long, $data, $reviewers, $timestamp );
if( $db->get( "$lang/packages/$package/owner", $owner ) )
- { display_error("Package $package no longer available for review"); }
+ {
+ $db->del("$lang/packages/$package");
+ DDTSS_Close($db);
+ display_error("Package $package no longer available for review");
+ }
# The timestamp is to identify if the translation changed during review
$db->get( "$lang/packages/$package/timestamp", $timestamp );
@@ -516,14 +1020,21 @@ sub forreview_display
if( scalar( grep { $_ eq $user } @a ) == 0 )
{
$db->put("$lang/packages/$package/reviewers", $reviewers.",".$user);
+ my $count=0;
+ $db->get("aliases/$user/countreviews", $count );
+ $db->put("aliases/$user/countreviews", ++$count );
DDTSS_Log( $db, "$lang/packages/$package/log", time()." reviewed by $user" );
}
}
else
{
$db->put("$lang/packages/$package/reviewers",$user);
+ my $count=0;
+ $db->get("aliases/$user/countreviews", $count );
+ $db->put("aliases/$user/countreviews", ++$count );
DDTSS_Log( $db, "$lang/packages/$package/log", time()." reviewed by $user" );
}
+ $db->put( "aliases/$user/timestamp", time() );
$db->put( "aliases/$user/lastlanguage", $lang );
}
DDTSS_Close($db);
@@ -582,6 +1093,20 @@ sub forreview_display
}
}
+ if( $logged_in) {
+ $trailer .= $q->br("Note: the owner is: ".$q->b("$owner").$q->a( {href=>"$realself/messageto/$owner", onclick=>"return popup(this.href)"}, "(Write a message)" ).", reviewer are: ") ;
+ my @reviewerlist=split /,/, $reviewers;
+ $trailer .= join(" | ",map { $q->b($_).$q->a( {href=>"$realself/messageto/$_", onclick=>"return popup(this.href)"}, "(Write a message)" ) } @reviewerlist);
+ } else {
+ $trailer .= $q->br("Note: the owner is: ".$q->b("$owner").", reviewer are: ") ;
+ my @reviewerlist=split /,/, $reviewers;
+ $trailer .= join(" | ",map { $q->b($_) } @reviewerlist);
+ }
+
+ my $log=0;
+ $db->get("$lang/packages/$package/log", $log );
+ $trailer .= $q->br("Log: ".$q->pre("$log")) ;
+
my $comment = "";
$db->get("$lang/packages/$package/comment", $comment);
DDTSS_Close($db);
@@ -714,6 +1239,113 @@ sub translated_display
}
+sub submit_externalreview
+{
+ my( $db, $package, $short, $long, $comment ) = @_;
+
+ $short =~ s/^\s+//;
+ $short =~ s/\s+$//;
+ $short =~ s/\s+/ /g;
+ $long =~ s/\s+$//; # Trailing newlines
+ $long =~ s/\r\n?/\n/g; # Fix line endings
+ $long =~ s/^[ \t]*$/./mg; # Don't use \s because that matches \n
+ $long =~ s/[ \t]+$//mg;
+ $long =~ s/^/ /mg; # Insert leading space
+
+ eval {
+ my $shortx = Encode::decode_utf8($short, Encode::FB_CROAK);
+ my $longx = Encode::decode_utf8($long, Encode::FB_CROAK);
+
+ if( length($shortx) > 80 or $longx =~ /^.{80}/m )
+ {
+ return "Translation contains line longer than 80 characters";
+ }
+ };
+ if( $@ )
+ {
+ print STDERR "Encoding failure: charset=[".$q->param("_charset_")."], browser=[$ENV{HTTP_USER_AGENT}], err=[$@]\n";
+ print STDERR "short=[$short]\n";
+ print STDERR "long=[$long]\n";
+ return "Entered data was not validly encoded. Please check your translation contains no invalid characters. If this error persists, contact me at <kleptog\@svana.org>";
+ }
+
+ my $data;
+ my ($engshort,$englong);
+ my ($oldshort,$oldlong);
+ eval {
+ $data = get_untrans( $lang, "", $package, "1" );
+ };
+
+ # Any error/warning procuded, display it
+ if( $@ )
+ {
+ return ($@);
+ }
+ if( not defined $data )
+ {
+ return("Couldn't fetch an untranslated description: $lang, $package");
+ }
+
+ if( not defined $data or $data !~ /Description:/ or $data !~ /Description-[a-z_A-Z]+:/)
+ {
+ return("Couldn't fetch package description");
+ }
+
+ if( $data !~ /^# Package[^:]*: ([\w.+-]+)/m )
+ { return( "Fetched description didn't contain package name" ) }
+
+ eval {
+ my $str = Encode::decode_utf8($data, Encode::FB_CROAK);
+ };
+ if($@)
+ {
+ print STDERR "Encoding error ($@)\n";
+ print STDERR "Data: [$data]\n";
+ display_error("Encoding error retreiving data for package $package");
+ }
+ $data =~ s,^# patch http*,# patch http,m; # don't show patch-box
+
+ ($oldshort, $oldlong) = ($data =~ /^Description-$lang: (.*)\n((?: .*\n)+)/m);
+ ($engshort, $englong) = ($data =~ /^Description: (.*)\n((?: .*\n)+)/m);
+ (my $packagename) = ($data =~ /# Package[^:]*: ([\w.+-]+)/m);
+ (my $version) = ($data =~ /# Version[^:]*: (.+)/m);
+ my $md5sum=md5_hex("$engshort\n$englong");
+
+ my $str1 = $oldshort . "\n" . $oldlong;
+ my $str2 = $short . "\n" . $long;
+
+ my $words = 1;
+ if( $lang eq "ja" )
+ { $words = 0 }
+
+ my $diff = DDTSS_CreateDiff( $str1, $str2, $words );
+ my $res = "";
+ for my $hunk (@$diff)
+ {
+ my($type,$str) = @$hunk;
+ $str = $q->escapeHTML($str);
+
+ if( $type eq "" )
+ {
+ $res .= $str;
+ }
+ elsif( $type eq "-" )
+ {
+ $res .= "-(".$str.")";
+ }
+ elsif( $type eq "+" )
+ {
+ $res .= "+(".$str.")";
+ }
+ }
+ $diff=$res;
+
+ submit_one_suggestion($packagename,$version,$md5sum,"Description-$lang: $short\n$long",$lang,"externalreview");
+
+ return undef;
+}
+
+
sub submit_translation
{
my( $db, $package, $key, $short, $long ) = @_;
@@ -924,7 +1556,8 @@ sub fetch_translation
my $path;
# If we already have this package in the system, overwrite untranslated...
- if( $db->get( "$lang/packages/$package/data", $temp ) == 0 )
+ # Checking for the root key added because it appeared to be missing sometimes, reason unknown
+ if( $db->get( "$lang/packages/$package", $temp ) == 0 and $db->get( "$lang/packages/$package/data", $temp ) == 0 )
{
$db->put( "$lang/packages/$package/data", $data );
}
@@ -1047,7 +1680,7 @@ sub display_createlogin
$sender->MailMsg({to => $email,
subject => 'Confirm DDTSS account',
msg => "To confirm you account ($alias) on the DDTSS, please follow this link\n".
- $q->url(-base=>1)."$self/verifylogin?a=$alias&k=$key\n\n".
+ "http://$http_host$self/verifylogin?a=$alias&k=$key\n\n".
"If you did not create an account, please ignore this email.\n".
"DDTSS (Debian Distributed Translation Server Satelite)\n"});
@@ -1179,6 +1812,7 @@ sub display_login
print $q->p("A login on the DDTSS is only used so you can keep the status
of what you've reviewed between machines."),
+ $q->p("(To create a account go to " . $q->a({-href => "$realself/createlogin"}, "Create Login") . ")"),
$q->start_form( -method => 'post' ),
$q->start_table( -id => 'login' ),
$q->TR( $q->td( $q->label( { -for => 'alias' }, "Alias:" ) ),
--
DDTP - Debian Descriptions Translation Project
More information about the Debian-l10n-commits
mailing list