From 56d4b3ed57e20359e5ea46feabb850cf4a94caf2 Mon Sep 17 00:00:00 2001
From: Frank Lichtenheld ".
+ _g( "All packages" ) ." ".
- gettext( "All packages" ) ." You can download the requested file from the ";
- $$page_content .= join( '/', @file_components).'/';
- $$page_content .= " subdirectory at";
- $$page_content .= $archive ne 'security' ? " any of these sites:" : ":";
- $$page_content .= " ".sprintf( _( 'You can download the requested file from the %s subdirectory at any of these sites:' ), $directory )." ".sprintf( _( 'You can download the requested file from the %s subdirectory at:' ), $directory )." Debian security updates are currently officially distributed only via
- security.debian.org. '._( 'Debian security updates are currently officially distributed only via security.debian.org.' ).'';
+ my $i = 0; my $num_sections = keys %{$subsections->{$s}{$a}};
+ foreach my $ssec ((keys %{$subsections->{$s}{$a}}, 'virtual')) {
+ next if $ssec eq '-';
+ if ($sections_descs{$ssec}) {
+ print {$pages{$key}{$lang}{index}{fh}} "
\n\n";
+ }
+ }
+ }
+
+ print {$pages{$key}{$lang}{index}{fh}} '
(".
+ _g( "compact compressed textlist" ).")';
- print {$pages{$key}{index}{fh}} header( title => $index_title,
- title_keywords => "debian, $s",
- desc => encode_entities( $index_title, '"' ),
- lang => 'en' ),
- title( $index_title ), '
', trailer( "$root../" );
close $pages{$key}{fh} or
warn "can't close index file $wwwdir/$key/allpackages.en.html.new: $!";
diff --git a/cgi-bin/dispatcher.pl b/cgi-bin/dispatcher.pl
index 3dca95c..f54cd87 100755
--- a/cgi-bin/dispatcher.pl
+++ b/cgi-bin/dispatcher.pl
@@ -17,14 +17,17 @@ use URI::Escape;
use HTML::Entities;
use DB_File;
use Benchmark ':hireswallclock';
+use I18N::AcceptLanguage;
+use Locale::gettext;
use Deb::Versions;
-use Packages::Config qw( $DBDIR $ROOT @SUITES @SECTIONS @ARCHIVES @ARCHITECTURES );
+use Packages::Config qw( $DBDIR $ROOT @SUITES @SECTIONS @ARCHIVES @ARCHITECTURES @LANGUAGES $LOCALES );
use Packages::CGI;
use Packages::DB;
use Packages::Search qw( :all );
use Packages::HTML ();
use Packages::Sections;
+use Packages::I18N::Locale;
use Packages::DoSearch;
use Packages::DoSearchContents;
@@ -34,7 +37,12 @@ use Packages::DoFilelist;
&Packages::CGI::reset;
+# clean up env
$ENV{PATH} = "/bin:/usr/bin";
+delete $ENV{'LANGUAGE'};
+delete $ENV{'LANG'};
+delete $ENV{'LC_ALL'};
+delete $ENV{'LC_MESSAGES'};
# Read in all the variables set by the form
my $input;
@@ -55,10 +63,19 @@ $Packages::CGI::debug = $debug;
&Packages::Config::init( '../' );
&Packages::DB::init();
+my $acc = I18N::AcceptLanguage->new();
+my $http_lang = $acc->accepts( $input->http("Accept-Language"),
+ \@LANGUAGES );
+debug( "LANGUAGES=@LANGUAGES header=".
+ $input->http("Accept-Language").
+ " http_lang=$http_lang", 2 );
+bindtextdomain ( 'pdo', $LOCALES );
+textdomain( 'pdo' );
+
my $what_to_do = 'show';
my $source = 0;
if (my $path = $input->path_info() || $input->param('PATH_INFO')) {
- my @components = grep { $_ } map { lc $_ } split /\//, $path;
+ my @components = grep { $_ } map { lc $_ } split /\/+/, $path;
debug( "components[0]=$components[0]", 2 ) if @components>0;
if (@components > 0 and $components[0] eq 'source') {
@@ -69,11 +86,10 @@ if (my $path = $input->path_info() || $input->param('PATH_INFO')) {
shift @components;
$what_to_do = 'search';
# Done
- fatal_error( "search doesn't take any more path elements" )
+ fatal_error( _( "search doesn't take any more path elements" ) )
if @components > 0;
} elsif (@components == 0) {
- fatal_error( "We're supposed to display the homepage here, instead of
- getting dispatch.pl" );
+ fatal_error( _( "We're supposed to display the homepage here, instead of getting dispatch.pl" ) );
} elsif (@components == 1) {
$what_to_do = 'search';
} else {
@@ -98,7 +114,7 @@ if (my $path = $input->path_info() || $input->param('PATH_INFO')) {
sub set_param_once {
my ($cgi, $params_set, $key, $val) = @_;
if ($params_set->{$key}++) {
- fatal_error( "$key set more than once in path" );
+ fatal_error( sprintf( _( "%s set more than once in path" ), $key ) );
} else {
$cgi->param( $key, $val );
}
@@ -128,7 +144,7 @@ if (my $path = $input->path_info() || $input->param('PATH_INFO')) {
@components = @tmp;
if (@components > 1) {
- fatal_error( "two or more packages specified (@components)" );
+ fatal_error( sprintf( _( "two or more packages specified (%s)" ), "@components" ) );
}
} # else if (@components == 1)
@@ -156,6 +172,7 @@ my %params_def = ( keywords => { default => undef,
replace => { all => \@ARCHIVES,
default => [qw(us security non-US)]} },
exact => { default => 0, match => '^(\w+)$', },
+ lang => { default => $http_lang, match => '^(\w+)$', },
source => { default => 0, match => '^(\d+)$', },
searchon => { default => 'names', match => '^(\w+)$', },
section => { default => 'all', match => '^([\w-]+)$',
@@ -172,6 +189,19 @@ my %params_def = ( keywords => { default => undef,
my %opts;
my %params = Packages::Search::parse_params( $input, \%params_def, \%opts );
+my $locale = get_locale($opts{lang});
+my $charset = get_charset($opts{lang});
+setlocale ( LC_ALL, $locale )
+ or do { debug( "couldn't set locale $locale, using default" );
+ setlocale( LC_ALL, get_locale() )
+ or do {
+ debug( "couldn't set default locale either" );
+ next if ($opts{lang} ne 'en');
+ setlocale( LC_ALL, "C" );
+ };
+ };
+debug( "locale=$locale charset=$charset", 2 );
+
$opts{h_suites} = { map { $_ => 1 } @suites };
$opts{h_sections} = { map { $_ => 1 } @sections };
$opts{h_archives} = { map { $_ => 1 } @archives };
@@ -193,7 +223,7 @@ my $pet1 = new Benchmark;
my $petd = timediff($pet1, $pet0);
debug( "Parameter evaluation took ".timestr($petd) );
-print $input->header( -charset => 'utf-8' );
+print $input->header( -charset => $charset );
my (%html_header, $menu, $page_content);
unless (@Packages::CGI::fatal_errors) {
@@ -201,12 +231,12 @@ unless (@Packages::CGI::fatal_errors) {
&{"do_$what_to_do"}( \%params, \%opts, \%html_header,
\$menu, \$page_content );
} else {
- %html_header = ( title => 'Error',
- lang => 'en',
+ %html_header = ( title => _('Error'),
+ lang => $opts{lang},
print_title => 1,
print_search_field => 'packages',
search_field_values => {
- keywords => 'search for a package',
+ keywords => _('search for a package'),
searchon => 'default',
arch => 'any',
suite => 'all',
diff --git a/conf/apache.conf b/conf/apache.conf
index d4bbb8b..5c1248c 100644
--- a/conf/apache.conf
+++ b/conf/apache.conf
@@ -70,7 +70,7 @@
AddLanguage zh-TW .zh-tw
LanguagePriority en fr de it es ja pl hr da pt pt-pt pt-br fi zh-cn zh-hk zh-tw cs sv sv-se ko no nb ru tr uk eo ar nl hu ro sk el ca en-us en-gb id lt sl bg
- DirectoryIndex index index.html index.shtml index.htm
+ DirectoryIndex index
# RSS stuff
AddType application/rss+xml .rdf .xml
@@ -103,7 +103,7 @@
RewriteEngine on
RewriteLog /var/log/apache/rewrite.log
- RewriteLogLevel 0
+ RewriteLogLevel 9
# we never want to rewrite those URLs
RewriteRule ^/cgi-(bin|old)/ - [L]
diff --git a/config.sh b/config.sh
index 3e8b2c6..a5aa6db 100644
--- a/config.sh
+++ b/config.sh
@@ -11,7 +11,7 @@ filesdir=${topdir}/files
htmldir=${topdir}/www
archivedir=${topdir}/archive
podir=${topdir}/po
-localedir=${topdir}/locale
+localedir=/org/packages.debian.org/locale
staticdir=${topdir}/static
configdir=${topdir}/conf
@@ -41,6 +41,7 @@ bug_url="http://bugs.debian.org/"
src_bug_url="http://bugs.debian.org/src:"
qa_url="http://packages.qa.debian.org/"
ddpo_url="http://qa.debian.org/developer.php?email="
+cn_help_url="http://www.debian.org/intro/cn"
# Architectures
#
diff --git a/cron.d/500update_mo b/cron.d/500update_mo
new file mode 100755
index 0000000..ec37c4f
--- /dev/null
+++ b/cron.d/500update_mo
@@ -0,0 +1,63 @@
+#! /bin/bash
+
+. `dirname $0`/../config.sh
+
+gettextfiles=$(find cgi-bin lib -not -name 'LanguageNames.pm' -a -not -name 'Sections.pm' -a \( -name '*.pl' -o -name '*.pm' \));
+gettextfiles="$gettextfiles bin/create_index_pages"
+podomains="pdo sections langs"
+
+# Update pot
+#
+# Common options for all calls
+xgettext_opts="--language=Perl --keyword=_ --keyword=N_ --keyword=_g --foreign-user --add-comments"
+
+echo gettextfiles=$gettextfiles
+xgettext $xgettext_opts -d pdo -o ${podir}/pdo.pot ${gettextfiles}
+xgettext $xgettext_opts -d sections -o ${podir}/sections.pot ${libdir}/Packages/Sections.pm
+xgettext $xgettext_opts -d langs -o ${podir}/langs.pot ${libdir}/Packages/I18N/LanguageNames.pm
+
+cd $podir
+
+# normalize paths in .pot files
+for domain in ${podomains}
+do
+ perl -p -i -e "s,^#:\s*\Q${topdir}\E,#: .,go" ${domain}.pot
+done
+
+# Create missing po files
+#
+for lang in ${polangs}
+do
+ for domain in ${podomains}
+ do
+ test -f ${domain}.${lang}.po || cp ${domain}.pot ${domain}.${lang}.po
+ done
+done
+
+# Update po
+#
+for lang in ${polangs}
+do
+ for domain in ${podomains}
+ do
+ mv ${domain}.${lang}.po ${domain}.${lang}.po.tmp
+ msgmerge -q -F -o ${domain}.${lang}.po ${domain}.${lang}.po.tmp ${domain}.pot
+ rm ${domain}.${lang}.po.tmp
+ # normalize paths in .po files
+ perl -p -i -e "s,^#:\s*\Q${topdir}\E,#: .,go" ${domain}.${lang}.po
+ done
+done
+
+# Update mo
+#
+test -d ${localedir} || mkdir -p ${localedir}
+for lang in ${polangs}
+do
+ test -d ${localedir}/${lang}/LC_MESSAGES \
+ || mkdir -p ${localedir}/${lang}/LC_MESSAGES
+ for domain in ${podomains}
+ do
+ echo domain=$domain language=$lang
+ msgfmt --statistics -o ${localedir}/${lang}/LC_MESSAGES/${domain}.mo ${domain}.${lang}.po
+ done
+done
diff --git a/lib/Packages/Config.pm b/lib/Packages/Config.pm
index 73d3542..0645d58 100644
--- a/lib/Packages/Config.pm
+++ b/lib/Packages/Config.pm
@@ -9,13 +9,13 @@ use Packages::CGI;
our @ISA = qw( Exporter );
our ( $TOPDIR, $DBDIR, $ROOT, $HOME, $CONTACT_MAIL, $WEBMASTER_MAIL,
- $SEARCH_PAGE, $SEARCH_URL,
+ $SEARCH_PAGE, $SEARCH_URL, @LANGUAGES, $LOCALES,
$SRC_SEARCH_URL, $CONTENTS_SEARCH_CGI,
$CN_HELP_URL, $BUG_URL, $SRC_BUG_URL, $QA_URL, $DDPO_URL,
@SUITES, @SECTIONS, @ARCHIVES, @ARCHITECTURES,
%FTP_SITES );
our @EXPORT_OK = qw( $TOPDIR $DBDIR $ROOT $HOME $CONTACT_MAIL
- $WEBMASTER_MAIL
+ $WEBMASTER_MAIL @LANGUAGES $LOCALES
$SEARCH_PAGE $SEARCH_URL
$SRC_SEARCH_URL $CONTENTS_SEARCH_CGI
$CN_HELP_URL $BUG_URL $SRC_BUG_URL $QA_URL $DDPO_URL
@@ -39,6 +39,7 @@ sub init {
$TOPDIR = $1 if /^\s*topdir="?([^\"]*)"?\s*$/o;
$ROOT = $1 if /^\s*root="?([^\"]*)"?\s*$/o;
$HOME = $1 if /^\s*home="?([^\"]*)"?\s*$/o;
+ $LOCALES = $1 if /^\s*localedir="?([^\"]*)"?\s*$/o;
# $SEARCH_CGI = $1 if /^\s*search_cgi="?([^\"]*)"?\s*$/o;
$SEARCH_PAGE = $1 if /^\s*search_page="?([^\"]*)"?\s*$/o;
$SEARCH_URL = $1 if /^\s*search_url="?([^\"]*)"?\s*$/o;
@@ -49,8 +50,10 @@ sub init {
$SRC_BUG_URL = $1 if /^\s*src_bug_url="?([^\"]*)"?\s*$/o;
$QA_URL = $1 if /^\s*qa_url="?([^\"]*)"?\s*$/o;
$DDPO_URL = $1 if /^\s*ddpo_url="?([^\"]*)"?\s*$/o;
+ $CN_HELP_URL = $1 if /^\s*cn_help_url="?([^\"]*)"?\s*$/o;
$FTP_SITES{us} = $1 if /^\s*ftpsite="?([^\"]*)"?\s*$/o;
$FTP_SITES{$1} = $2 if /^\s*(\w+)_ftpsite="?([^\"]*)"?\s*$/o;
+ @LANGUAGES = split(/\s+/, $1) if /^\s*polangs="?([^\"]*)"?\s*$/o;
@SUITES = split(/\s+/, $1) if /^\s*suites="?([^\"]*)"?\s*$/o;
@SECTIONS = split(/\s+/, $1) if /^\s*sections="?([^\"]*)"?\s*$/o;
@ARCHIVES = split(/\s+/, $1) if /^\s*archives="?([^\"]*)"?\s*$/o;
@@ -61,6 +64,7 @@ sub init {
$config_read_time = $modtime;
}
$DBDIR = "$TOPDIR/files/db";
+ unshift @LANGUAGES, 'en';
}
1;
diff --git a/lib/Packages/DoDownload.pm b/lib/Packages/DoDownload.pm
index 87bc10c..8b1d6f6 100644
--- a/lib/Packages/DoDownload.pm
+++ b/lib/Packages/DoDownload.pm
@@ -9,9 +9,10 @@ use Benchmark ':hireswallclock';
use Exporter;
use Deb::Versions;
+use Packages::I18N::Locale;
use Packages::HTML ();
use Packages::Search qw( :all );
-use Packages::Config qw( $HOME $DBDIR @SUITES @ARCHIVES @SECTIONS @ARCHITECTURES );
+use Packages::Config qw( $HOME $DBDIR @SUITES @ARCHIVES @SECTIONS @ARCHITECTURES $SEARCH_URL );
use Packages::CGI;
use Packages::DB;
@@ -199,19 +200,19 @@ sub do_download {
my ($params, $opts, $html_header, $menu, $page_content) = @_;
if ($params->{errors}{package}) {
- fatal_error( "package not valid or not specified" );
+ fatal_error( _( "package not valid or not specified" ) );
}
if ($params->{errors}{suite}) {
- fatal_error( "suite not valid or not specified" );
+ fatal_error( _( "suite not valid or not specified" ) );
}
if ($params->{errors}{arch}) {
- fatal_error( "arch not valid or not specified" );
+ fatal_error( _( "architecture not valid or not specified" ) );
}
if (@{$opts->{suite}} > 1) {
- fatal_error( "more than one suite specified for download (@{$opts->{suite}})" );
+ fatal_error( sprintf( _( "more than one suite specified for download (%s)" ), "@{$opts->{suite}}" ) );
}
if (@{$opts->{arch}} > 1) {
- fatal_error( "more than one architecture specified for download (@{$opts->{arch}})" );
+ fatal_error( sprintf( _( "more than one architecture specified for download (%s)" ), "@{$opts->{arch}}" ) );
}
$opts->{h_sections} = { map { $_ => 1 } @SECTIONS };
@@ -223,8 +224,6 @@ sub do_download {
my (@results);
my ($final_result, $file, $filen, $md5sum, @file_components, $archive) = ("")x5;
- sub gettext { return $_[0]; };
-
my $st0 = new Benchmark;
unless (@Packages::CGI::fatal_errors) {
tie %packages_all, 'DB_File', "$DBDIR/packages_all_$suite.db",
@@ -234,8 +233,8 @@ sub do_download {
read_entry( \%packages, $pkg, \@results, $opts );
unless (@results) {
- fatal_error( "No such package".
- "{insert link to search page with substring search}" );
+ fatal_error( _( "No such package." )."';
foreach my $sec (keys %{$sections->{$s}{$a}}) {
mkpath ( "$wwwdir/$key/$sec" );
open $pages{$key}{$sec}{fh}, '>', "$wwwdir/$key/$sec/index.en.html.new"
or die "can't open index file for output: $!";
- $title = sprintf( gettext ( "Software Packages in \"%s\", section %s" ),
+ $title = sprintf( _g( "Software Packages in \"%s\", section %s" ),
$s, $sec );
print {$pages{$key}{$sec}{fh}} header( title => $title,
title_keywords => "debian, $s, $sec",
@@ -75,34 +124,25 @@ foreach my $s (@SUITES) {
lang => 'en' ),
title( $title ), '
';
}
- my $i = 0; my $num_sections = keys %{$subsections->{$s}{$a}};
foreach my $ssec ((keys %{$subsections->{$s}{$a}}, 'virtual')) {
next if $ssec eq '-';
mkpath ( "$wwwdir/$key/$ssec" );
open $pages{$key}{$ssec}{fh}, '>', "$wwwdir/$key/$ssec/index.en.html.new"
or die "can't open index file for output: $!";
- $title = sprintf( gettext ( "Software Packages in \"%s\", subsection %s" ),
+ $title = sprintf( _g( "Software Packages in \"%s\", subsection %s" ),
$s, $ssec );
print {$pages{$key}{$ssec}{fh}} header( title => $title,
title_keywords => "debian, $s, $ssec",
desc => encode_entities( $title, '"' ),
lang => 'en' ),
title( $title ), '
';
-
- if ($sections_descs{$ssec}) {
- print {$pages{$key}{index}{fh}} "
\n\n";
- }
- }
}
foreach my $prio (keys %{$priorities->{$s}{$a}}) {
next if $prio eq '-';
mkpath ( "$wwwdir/$key/$prio" );
open $pages{$key}{$prio}{fh}, '>', "$wwwdir/$key/$prio/index.en.html.new"
or die "can't open index file for output: $!";
- $title = sprintf( gettext ( "Software Packages in \"%s\", priority %s" ),
+ $title = sprintf( _g( "Software Packages in \"%s\", priority %s" ),
$s, $prio );
print {$pages{$key}{$prio}{fh}} header( title => $title,
title_keywords => "debian, $s, $prio",
@@ -189,15 +229,6 @@ foreach my $s (@SUITES) {
next if $a eq 'non-US';
my $key = ($a eq 'us') ? $s : "$s/$a";
my $root = ($a eq 'us') ? '' : '../';
- print {$pages{$key}{index}{fh}} '
(".
- gettext( "compact compressed textlist" ).")
".
+ sprintf( _( 'Search for the package' ), "$SEARCH_URL/$pkg" ) );
} else {
my $final_result = shift @results;
foreach (@results) {
@@ -254,139 +253,100 @@ sub do_download {
}
}
- my $arch_string = $arch ne 'all' ? "on $arches{$arch} machines" : "";
-
- %$html_header = ( title => "Package Download Selection",
- lang => "en",
+ %$html_header = ( title => _( "Package Download Selection" ),
+ lang => $opts->{lang},
print_title => 1 );
if ($file) {
- $$page_content .= "Download Page for $filen $arch_string
\n".
- "'.sprintf( _('Download Page for %s on %s machines'), $filen, $arches{$arch} ).'
';
+ } else {
+ $$page_content .= ''.sprintf( _('Download Page for %s'), $filen ).'
';
+ }
+ my $directory = join( '/', @file_components).'/';
+ if ($archive ne 'security' ) {
+ $$page_content .= "
'._( 'Note that AMD64 is not officialy included in the Debian archive yet, but the AMD64 porter group keeps their archive in sync with the official archive as close as possible. See the AMD64 ports page for current information.' ).'
'; } elsif ($arch eq 'kfreebsd-i386') { - $$page_content .= print_links( "North America", $file, @kfreebsd_north_american_sites ); - $$page_content .= print_links( "Europe", $file, @kfreebsd_european_sites ); + $$page_content .= print_links( _( "North America" ), $file, @kfreebsd_north_american_sites ); + $$page_content .= print_links( _( "Europe" ), $file, @kfreebsd_european_sites ); # $$page_content .= print_links( "Australia and New Zealand", $file, # @nonus_australian_sites ); # $$page_content .= print_links( "Asia", $file, @amd64_asian_sites ); # $$page_content .= print_links( "South America", $file, @nonus_south_american_sites ); - $$page_content .= <'._( 'Note that GNU/kFreeBSD is not officialy included in the Debian archive yet, but the GNU/kFreeBSD porter group keeps their archive in sync with the official archive as close as possible. See the GNU/kFreeBSD ports page for current information.' ).'
'; } elsif ($archive eq 'non-US') { - $$page_content .= print_links( "North America", $file, @nonus_north_american_sites ); - $$page_content .= print_links( "Europe", $file, @nonus_european_sites ); - $$page_content .= print_links( "Australia and New Zealand", $file, - @nonus_australian_sites ); - $$page_content .= print_links( "Asia", $file, @nonus_asian_sites ); - $$page_content .= print_links( "South America", $file, @nonus_south_american_sites ); + $$page_content .= print_links( _( "North America" ), $file, @nonus_north_american_sites ); + $$page_content .= print_links( _( "Europe" ), $file, @nonus_european_sites ); + $$page_content .= print_links( _( "Australia and New Zealand" ), $file, + @nonus_australian_sites ); + $$page_content .= print_links( _( "Asia" ), $file, @nonus_asian_sites ); + $$page_content .= print_links( _( "South America" ), $file, @nonus_south_american_sites ); - $$page_content .= <'.sprintf( _('If none of the above sites are fast enough for you, please see our complete mirror list.' ), 'http://www.debian.org/mirror/list-non-US' ).'
'; } elsif ($archive eq 'backports') { # $$page_content .= print_links( "North America", $file, @nonus_north_american_sites ); $$page_content .= ''.sprintf( _( 'If none of the above sites are fast enough for you, please see our complete mirror list.'), 'http://www.backports.org/debian/README.mirrors.html' ).'
'; } elsif ($archive eq 'volatile') { # $$page_content .= print_links( "North America", $file, @nonus_north_american_sites ); - $$page_content .=_links( "Europe", $file, @volatile_european_sites ); + $$page_content .= print_links( _( "Europe" ), $file, @volatile_european_sites ); # $$page_content .= print_links( "Australia and New Zealand", $file, # @nonus_australian_sites ); # $$page_content .= print_links( "Asia", $file, @nonus_asian_sites ); # $$page_content .= print_links( "South America", $file, @nonus_south_american_sites ); - $$page_content .= <'.sprintf( _( 'If none of the above sites are fast enough for you, please see our complete mirror list.' ), 'http://volatile.debian.net/mirrors.html' ).'
'; } elsif ($archive eq 'us') { $$page_content .= ''.sprintf( _( 'If none of the above sites are fast enough for you, please see our complete mirror list.' ), 'http://www.debian.org/mirror/list' ).'
'; } - $$page_content .= <The MD5sum for $filen is $md5sum
\n" - if $md5sum; + $$page_content .= ''._( 'Note that in some browsers you will need to tell your browser you want the file saved to a file. For example, in Firefox or Mozilla, you should hold the Shift key when you click on the URL.' ).'
'; + $$page_content .= "".sprintf( _( 'The MD5sum for %s is %s' ), $filen, $md5sum ).'
' + if $md5sum; } } diff --git a/lib/Packages/DoFilelist.pm b/lib/Packages/DoFilelist.pm index 714171b..7fb1a8f 100644 --- a/lib/Packages/DoFilelist.pm +++ b/lib/Packages/DoFilelist.pm @@ -13,6 +13,7 @@ use Exporter; use Deb::Versions; use Packages::Config qw( $DBDIR $ROOT @SUITES @ARCHIVES @SECTIONS @ARCHITECTURES %FTP_SITES ); +use Packages::I18N::Locale; use Packages::CGI; use Packages::DB; use Packages::Search qw( :all ); @@ -27,13 +28,13 @@ sub do_filelist { my ($params, $opts, $html_header, $menu, $page_content) = @_; if ($params->{errors}{package}) { - fatal_error( "package not valid or not specified" ); + fatal_error( _( "package not valid or not specified" ) ); } if ($params->{errors}{suite}) { - fatal_error( "suite not valid or not specified" ); + fatal_error( _( "suite not valid or not specified" ) ); } if ($params->{errors}{arch}) { - fatal_error( "arch not valid or not specified" ); + fatal_error( _( "architecture not valid or not specified" ) ); } $$menu = ''; @@ -41,9 +42,9 @@ sub do_filelist { my $suite = $opts->{suite}[0]; my $arch = $opts->{arch}[0] ||''; - %$html_header = ( title => "Filelist of package $pkg in $suite of arch $arch", - title_tag => "Filelist of of package $pkg/$suite/$arch", - lang => 'en', + %$html_header = ( title => sprintf( _( "Filelist of package %s in %s of architecture %s" ), $pkg, $suite, $arch ), + title_tag => sprintf( _( "Filelist of of package %s/%s/%s" ), $pkg, $suite, $arch ), + lang => $opts->{lang}, keywords => "debian, $suite, $arch, filelist", print_title => 1, ); @@ -53,7 +54,7 @@ sub do_filelist { O_RDONLY, 0666, $DB_BTREE) { unless (exists $contents{$pkg}) { - fatal_error( "No such package in this suite on this arch" ); + fatal_error( _( "No such package in this suite on this architecture." ) ); } else { my @files = unpack "L/(CC/a)", $contents{$pkg}; my $file = ""; @@ -65,7 +66,7 @@ sub do_filelist { $$page_content .= ''; } } else { - fatal_error( "Invalid suite/arch combination" ); + fatal_error( _( "Invalid suite/architecture combination" ) ); } } } diff --git a/lib/Packages/DoSearch.pm b/lib/Packages/DoSearch.pm index bc55b74..60052c5 100644 --- a/lib/Packages/DoSearch.pm +++ b/lib/Packages/DoSearch.pm @@ -12,12 +12,14 @@ our @ISA = qw( Exporter ); our @EXPORT = qw( do_search ); use Deb::Versions; +use Packages::I18N::Locale; use Packages::Search qw( :all ); use Packages::CGI; use Packages::DB; use Packages::HTML qw(marker); use Packages::Config qw( $DBDIR $SEARCH_URL $SEARCH_PAGE @SUITES @ARCHIVES $ROOT ); +use Packages::HTML; sub do_search { my ($params, $opts, $html_header, $menu, $page_content) = @_; @@ -25,9 +27,9 @@ sub do_search { $Params::Search::too_many_hits = 0; if ($params->{errors}{keywords}) { - fatal_error( "keyword not valid or missing" ); + fatal_error( _( "keyword not valid or missing" ) ); } elsif (length($opts->{keywords}) < 2) { - fatal_error( "keyword too short (keywords need to have at least two characters)" ); + fatal_error( _( "keyword too short (keywords need to have at least two characters)" ) ); } $$menu = ""; @@ -100,46 +102,43 @@ sub do_search { } if ($Packages::Search::too_many_hits) { - error( "Your search was too wide so we will only display exact matches. At least $Packages::Search::too_many_hits results have been omitted and will not be displayed. Please consider using a longer keyword or more keywords." ); + error( sprintf( _( "Your search was too wide so we will only display exact matches. At least %s results have been omitted and will not be displayed. Please consider using a longer keyword or more keywords." ), $Packages::Search::too_many_hits ) ); } if (!@Packages::CGI::fatal_errors && !@results) { - my $printed = 0; if ($searchon eq "names") { unless (@non_results) { - error( "Can't find that package." ); + error( _( "Can't find that package." ) ); } else { - hint( "Can't find that package. ". - "". - ($#non_results+1)."". + hint( _( "Can't find that package." )." ". + sprintf( _( '%s'. " results have not been displayed due to the". - " search parameters." ); + " search parameters." ), "$SEARCH_URL/$keyword_esc" , + $#non_results+1 ) ); } } else { if (($suites_enc eq 'all') && ($archs_enc eq 'any') && ($sections_enc eq 'all')) { - error( "Can't find that string." ); + error( _( "Can't find that string." ) ); } else { - error( "Can't find that string, at least not in that suite ($suites_enc, section $sections_enc) and on that architecture ($archs_enc)." ); + error( sprintf( _( "Can't find that string, at least not in that suite (%s, section %s) and on that architecture (%s)." ), + $suites_enc, $sections_enc, $archs_enc ) ); } if ($opts->{exact}) { - $printed++; - hint( "You have searched only for words exactly matching your - keywords. You can try to search {common_params}")."\">allowing - subword matching." ); + hint( sprintf( _( 'You have searched only for words exactly matching your keywords. You can try to search allowing subword matching.' ), + encode_entities("$SEARCH_URL?exact=0&$opts->{common_params}") ) ); } } - hint( ( $printed ? "Or you" : "You" )." can try a different search on the Packages search page." ); + hint( sprintf( _( 'You can try a different search on the Packages search page.' ), "$SEARCH_PAGE#search_packages" ) ); } - %$html_header = ( title => 'Package Search Results' , - lang => 'en', - title_tag => 'Debian Package Search Results', + %$html_header = ( title => _( 'Package Search Results' ) , + lang => $opts->{lang}, + title_tag => _( 'Debian Package Search Results' ), print_title => 1, print_search_field => 'packages', search_field_values => { @@ -227,20 +226,21 @@ sub print_packages { #my ($start, $end) = multipageheader( $input, scalar @pkgs, \%opts ); my $str = 'Found ".(scalar @$pkgs_list)." matching packages."; + $str .= "
".sprintf( _( "Found %s matching packages." ), + scalar @$pkgs_list )."
"; #my $count = 0; my $have_exact; if (grep { $_ eq $keyword } @$pkgs_list) { $have_exact = 1; - $str .= '{common_params}")."\">". - ($#{$pkgs_list}+1)." results have not been displayed because you requested only exact matches.
"; + $str .= "".sprintf( _( '%s results have not been displayed because you requested only exact matches.' ), + encode_entities("$SEARCH_URL?exact=0&$opts->{common_params}"), + scalar @$pkgs_list )."
"; } $str .= 'Found ".scalar(@results)." results
"; - $$page_content .= "