- From: Olivier Thereaux via cvs-syncmail <cvsmail@w3.org>
- Date: Thu, 01 Mar 2007 02:52:58 +0000
- To: www-validator-cvs@w3.org
Update of /sources/public/validator/httpd/cgi-bin In directory hutz:/tmp/cvs-serv21353/httpd/cgi-bin Modified Files: check Log Message: Adding a bit of complexity to the code for the sake of localization. Instead of having messages like "no error" or "1 error" or "2 error" directly created in the check script, the script will instead pass parameters to the templates stating whether there is 0, 1, 2 or more error(s) (and warnings alike). This should keep translation work away from check - we want it contained in documentation and templates. Index: check =================================================================== RCS file: /sources/public/validator/httpd/cgi-bin/check,v retrieving revision 1.470 retrieving revision 1.471 diff -u -d -r1.470 -r1.471 --- check 20 Feb 2007 02:19:27 -0000 1.470 +++ check 1 Mar 2007 02:52:56 -0000 1.471 @@ -694,7 +694,8 @@ eval { local $SIG{__DIE__}; require HTML::Tidy; - my $tidy = HTML::Tidy->new(); + my $tidy = HTML::Tidy->new({config_file => "/Users/ot/Sites/cvs/public/validator/HEAD/htdocs/config/tidy.conf"}); + $File->{'Tidy'} = $tidy->clean(join"\n",@{$File->{Content}}); $File->{'Tidy_OK'} = TRUE; }; @@ -853,22 +854,56 @@ my $number_of_errors = ""; # textual form of $num_errors my $number_of_warnings = ""; # textual form of $num_errors +# The following is a bit hack-ish, but will enable us to have some logic +# for a human-readable display of the number, with cases for 0, 1, 2 and above +# (the case of 2 appears to be useful for localization in some languages where the plural is different for 2, and above) + if ($num_errors > 1) { - $number_of_errors = "$num_errors errors" + $T->param(number_of_errors_is_0 => FALSE ); + $T->param(number_of_errors_is_1 => FALSE); + if ($num_errors eq 2) { + $T->param(number_of_errors_is_2 => TRUE); + } + else { $T->param(number_of_errors_is_2 => FALSE ); } + $T->param(number_of_errors_is_plural => TRUE ); } - else { - $number_of_errors = "$num_errors error" + elsif ($num_errors eq 1) { + $T->param(number_of_errors_is_0 => FALSE ); + $T->param(number_of_errors_is_1 => TRUE ); + $T->param(number_of_errors_is_2 => FALSE ); + $T->param(number_of_errors_is_plural => FALSE ); } + else { # 0 + $T->param(number_of_errors_is_0 => TRUE ); + $T->param(number_of_errors_is_1 => FALSE ); + $T->param(number_of_errors_is_2 => FALSE ); + $T->param(number_of_errors_is_plural => FALSE ); + } + if ($num_warnings > 1) { - $number_of_warnings = "$num_warnings warnings" + $T->param(number_of_warnings_is_0 => FALSE ); + $T->param(number_of_warnings_is_1 => FALSE); + if ($num_warnings eq 2) { + $T->param(number_of_warnings_is_2 => TRUE); + } + else { $T->param(number_of_warnings_is_2 => FALSE ); } + $T->param(number_of_warnings_is_plural => TRUE ); } - else { - $number_of_warnings = "$num_warnings warning" + elsif ($num_warnings eq 1) { + $T->param(number_of_warnings_is_0 => FALSE ); + $T->param(number_of_warnings_is_1 => TRUE ); + $T->param(number_of_warnings_is_2 => FALSE ); + $T->param(number_of_warnings_is_plural => FALSE ); } + else { # 0 + $T->param(number_of_warnings_is_0 => TRUE ); + $T->param(number_of_warnings_is_1 => FALSE ); + $T->param(number_of_warnings_is_2 => FALSE ); + $T->param(number_of_warnings_is_plural => FALSE ); + } + $T->param(file_errors => $reported_errors); - $T->param(number_of_errors => $number_of_errors); - $T->param(number_of_warnings => $number_of_warnings); if ($File->{'Is Valid'}) { $T->param(VALID => TRUE); $T->param(valid_status => 'Valid');
Received on Thursday, 1 March 2007 02:53:03 UTC