# Update pot
#
# Common options for all calls
-xgettext_opts="--language=Perl --keyword=N_ --keyword=_g --foreign-user --add-comments"
+xgettext_opts="--language=Perl --keyword=N_ --keyword=_g --keyword=g --foreign-user --add-comments"
echo gettextfiles=$gettextfiles
echo templatefiles=$templatefiles
shift @components;
$what_to_do = 'search';
# Done
- fatal_error( _g( "search doesn't take any more path elements" ) )
+ fatal_error( "search doesn't take any more path elements" )
if @components;
} elsif (@components == 0) {
- fatal_error( _g( "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 {
my ($cgi, $params_set, $key, $val) = @_;
debug("set_param_once key=$key val=$val",4) if DEBUG;
if ($params_set->{$key}++) {
- fatal_error( sprintf( _g( "%s set more than once in path" ), $key ) );
+ fatal_error( "$key set more than once in path" );
} else {
$cgi->param( $key, $val );
}
@components = @pkg;
if (@components > 1) {
- fatal_error( sprintf( _g( "two or more packages specified (%s)" ), "@components" ) );
+ fatal_error( "two or more packages specified (@components)" );
}
} # else if (@components == 1)
my $charset = "UTF-8";
my $cat = Packages::I18N::Locale->get_handle( $opts{lang} )
or die "get_handle failed";
+ $opts{cat} = $cat;
$opts{h_suites} = { map { $_ => 1 } @suites };
$opts{h_sections} = { map { $_ => 1 } @sections };
#FIXME: ugly hack
unless (($what_to_do eq 'allpackages' and $opts{format} =~ /^(html|txt\.gz)/)
|| -e "$TEMPLATEDIR/$opts{format}/${what_to_do}.tmpl") {
- fatal_error( _g("requested format not available for this document"),
+ fatal_error( $cat->g("requested format not available for this document"),
"406 requested format not available");
}
sub do_download {
my ($params, $opts, $page_content) = @_;
+ my $cat = $opts->{cat};
if ($params->{errors}{package}) {
- fatal_error( _g( "package not valid or not specified" ) );
+ fatal_error( $cat->g( "package not valid or not specified" ) );
}
if ($params->{errors}{suite}) {
- fatal_error( _g( "suite not valid or not specified" ) );
+ fatal_error( $cat->g( "suite not valid or not specified" ) );
}
if ($params->{errors}{arch}) {
- fatal_error( _g( "architecture not valid or not specified" ) );
+ fatal_error( $cat->g( "architecture not valid or not specified" ) );
}
if (@{$opts->{suite}} > 1) {
- fatal_error( sprintf( _g( "more than one suite specified for download (%s)" ), "@{$opts->{suite}}" ) );
+ fatal_error( $cat->g( "more than one suite specified for download (%s)",
+ "@{$opts->{suite}}" ) );
}
if (@{$opts->{arch}} > 1) {
- fatal_error( sprintf( _g( "more than one architecture specified for download (%s)" ), "@{$opts->{arch}}" ) );
+ fatal_error( $cat->g( "more than one architecture specified for download (%s)",
+ "@{$opts->{arch}}" ) );
}
$opts->{h_sections} = { map { $_ => 1 } @SECTIONS };
my $pkgsize = floor(($data{size}/102.4)+0.5)/10;
if ($pkgsize < 1024) {
$page_content->{pkgsize} = sprintf( '%.1f', $pkgsize );
- $page_content->{pkgsize_unit} = _g( 'kByte' );
+ $page_content->{pkgsize_unit} = $cat->g( 'kByte' );
} else {
$page_content->{pkgsize} = sprintf( '%.1f', floor(($data{size}/(102.4*102.4))+0.5)/100 );
- $page_content->{pkgsize_unit} = _g( 'MByte' );
+ $page_content->{pkgsize_unit} = $cat->g( 'MByte' );
}
$page_content->{architecture} = $arch;
foreach (keys %data) {
sub do_filelist {
my ($params, $opts, $page_content) = @_;
+ my $cat = $opts->{cat};
if ($params->{errors}{package}) {
- fatal_error( _g( "package not valid or not specified" ) );
+ fatal_error( $cat->g( "package not valid or not specified" ) );
}
if ($params->{errors}{suite}) {
- fatal_error( _g( "suite not valid or not specified" ) );
+ fatal_error( $cat->g( "suite not valid or not specified" ) );
}
if ($params->{errors}{arch}) {
- fatal_error( _g( "architecture not valid or not specified" ) );
+ fatal_error( $cat->g( "architecture not valid or not specified" ) );
}
my $pkg = $opts->{package};
O_RDONLY, 0666, $DB_BTREE) {
unless (exists $contents{$pkg}) {
- fatal_error( _g( "No such package in this suite on this architecture." ) );
+ fatal_error( $cat->g( "No such package in this suite on this architecture." ) );
} else {
my @files = unpack "L/(CC/a)", $contents{$pkg};
my $file = '';
}
}
} else {
- fatal_error( _g( "Invalid suite/architecture combination" ) );
+ fatal_error( $cat->g( "Invalid suite/architecture combination" ) );
}
}
}
);
sub send_file {
my ($file, $params, $opts) = @_;
+ my $cat = $opts->{cat};
if ($params->{errors}{suite}) {
- fatal_error( _g( "suite not valid or not specified" ) );
+ fatal_error( $cat->g( "suite not valid or not specified" ) );
}
if (@{$opts->{suite}} > 1) {
- fatal_error( sprintf( _g( "more than one suite specified for show_static (%s)" ), "@{$opts->{suite}}" ) );
+ fatal_error( $cat->g( "more than one suite specified for show_static (%s)",
+ "@{$opts->{suite}}" ) );
}
if (@{$opts->{subsection}} > 1) {
- fatal_error( sprintf( _g( "more than one subsection specified for show_static (%s)" ), "@{$opts->{suite}}" ) );
+ fatal_error( $cat->g( "more than one subsection specified for show_static (%s)",
+ "@{$opts->{suite}}" ) );
}
my $wwwdir = "$TOPDIR/www";
close INDEX;
exit;
} else {
- fatal_error( sprintf( _g( "couldn't read index file %s: %s" ),
+ fatal_error( $cat->g( "couldn't read index file %s: %s",
$path, $! ) );
}
}
sub do_newpkg {
my ($params, $opts, $page_content) = @_;
+ my $cat = $opts->{cat};
if ($params->{errors}{suite}) {
- fatal_error( _g( "suite not valid or not specified" ) );
+ fatal_error( $cat->g( "suite not valid or not specified" ) );
}
if (@{$opts->{suite}} > 1) {
- fatal_error( sprintf( _g( "more than one suite specified for newpkg (%s)" ), "@{$opts->{suite}}" ) );
+ fatal_error( $cat->g( "more than one suite specified for newpkg (%s)",
+ "@{$opts->{suite}}" ) );
}
my $sort_func = sub { $_[0][0] cmp $_[1][0] };
open NEWPKG, '<', "$TOPDIR/files/packages/newpkg_info_$suite"
or do {
warn "can't read newpkg_info_$suite: $!";
- fatal_error( sprintf( _g("no newpkg information found for suite %s"),
- $suite) );
+ fatal_error( $cat->g("no newpkg information found for suite %s",
+ $suite) );
return;
};
while (<NEWPKG>) {
sub do_search {
my ($params, $opts, $page_content) = @_;
+ my $cat = $opts->{cat};
$Params::Search::too_many_hits = 0;
if ($params->{errors}{keywords}) {
- fatal_error( _g( "keyword not valid or missing" ) );
+ fatal_error( $cat->g( "keyword not valid or missing" ) );
$opts->{keywords} = [];
} elsif (grep { length($_) < 2 } @{$opts->{keywords}}) {
- fatal_error( _g( "keyword too short (keywords need to have at least two characters)" ) );
+ fatal_error( $cat->g( "keyword too short (keywords need to have at least two characters)" ) );
}
my @keywords = @{$opts->{keywords}};
} else {
@pkgs = sort { $sort_by_relevance{$a} <=> $sort_by_relevance{$b} } keys %uniq_pkgs;
}
- process_packages( $page_content, 'packages', \%pkgs, \@pkgs, $opts, \@keywords,
+ process_packages( $page_content, 'packages', \%pkgs, \@pkgs,
+ $opts, \@keywords,
\&process_package, \%provided_by,
\%archives, \%sect, \%subsect,
\%desc );
}
my @pkgs = sort keys %pkgs;
- process_packages( $page_content, 'src_packages', \%pkgs, \@pkgs, $opts, \@keywords,
+ process_packages( $page_content, 'src_packages', \%pkgs, \@pkgs,
+ $opts, \@keywords,
\&process_src_package, \%archives,
\%sect, \%subsect, \%binaries );
} # else unless $opts->{source}
my $have_exact;
if ($keyword && grep { $_ eq $keyword } @$pkgs_list) {
$have_exact = 1;
- $categories[0]{name} = _g( "Exact hits" );
+ $categories[0]{name} = $opts->{cat}->g( "Exact hits" );
- $categories[0]{$target} = [ &$print_func( $keyword, $pkgs->{$keyword}||{},
- map { $_->{$keyword}||{} } @func_args ) ];
+ $categories[0]{$target} = [ &$print_func( $opts, $keyword,
+ $pkgs->{$keyword}||{},
+ map { $_->{$keyword}||{} } @func_args ) ];
@$pkgs_list = grep { $_ ne $keyword } @$pkgs_list;
}
if (@$pkgs_list && (($opts->{searchon} ne 'names') || !$opts->{exact})) {
my %cat;
- $cat{name} = _g( 'Other hits' ) if $have_exact;
+ $cat{name} = $opts->{cat}->g( 'Other hits' ) if $have_exact;
$cat{packages} = [];
foreach my $pkg (@$pkgs_list) {
- push @{$cat{$target}}, &$print_func( $pkg, $pkgs->{$pkg}||{},
+ push @{$cat{$target}}, &$print_func( $opts, $pkg, $pkgs->{$pkg}||{},
map { $_->{$pkg}||{} } @func_args );
}
push @categories, \%cat;
}
sub process_package {
- my ($pkg, $pkgs, $provided_by, $archives, $sect, $subsect, $desc) = @_;
+ my ($opts, $pkg, $pkgs, $provided_by,
+ $archives, $sect, $subsect, $desc) = @_;
my %pkg = ( pkg => $pkg,
suites => [] );
$suite{providers} = $p;
}
} elsif (my $p = $provided_by->{$suite}) {
- $suite{desc} = _g('Virtual package');
+ $suite{desc} = $opts->{cat}->g('Virtual package');
$suite{providers} = $p;
}
push @{$pkg{suites}}, \%suite if $suite{versions} || $suite{providers};
}
sub process_src_package {
- my ($pkg, $pkgs, $archives, $sect, $subsect, $binaries) = @_;
+ my ($opts, $pkg, $pkgs, $archives, $sect, $subsect, $binaries) = @_;
my %pkg = ( pkg => $pkg,
origins => [] );
sub do_search_contents {
my ($params, $opts, $page_content) = @_;
+ my $cat = $opts->{cat};
if ($params->{errors}{keywords}) {
- fatal_error( _g( "keyword not valid or missing" ) );
+ fatal_error( $cat->g( "keyword not valid or missing" ) );
$opts->{keywords} = [];
} elsif (grep { length($_) < 2 } @{$opts->{keywords}}) {
- fatal_error( _g( "keyword too short (keywords need to have at least two characters)" ) );
+ fatal_error( $cat->g( "keyword too short (keywords need to have at least two characters)" ) );
}
if ($params->{errors}{suite}) {
- fatal_error( _g( "suite not valid or not specified" ) );
+ fatal_error( $cat->g( "suite not valid or not specified" ) );
}
#FIXME: that's extremely hacky atm
}
if (@{$opts->{suite}} > 1) {
- fatal_error( sprintf( _g( "more than one suite specified for contents search (%s)" ), "@{$opts->{suite}}" ) );
+ fatal_error( $cat->g( "more than one suite specified for contents search (%s)",
+ "@{$opts->{suite}}" ) );
}
my @keywords = @{$opts->{keywords}};
close FILENAMES or warn "fgrep error: $!\n";
} else {
- error(_g("The search mode you selected doesn't support more than one keyword."))
+ error($cat->g("The search mode you selected doesn't support more than one keyword."))
if @keywords;
my $kw = reverse $first_kw;
my $file = shift @$result;
my %pkgs;
foreach (@$result) {
- my ($pkg, $arch) = split /:/, $_;
+ my ($pkg, $arch) = split m/:/, $_;
next unless $opts->{h_archs}{$arch};
$pkgs{$pkg}{$arch}++;
$archs{$arch}++ unless $arch eq 'all';
sub do_show {
my ($params, $opts, $page_contents) = @_;
+ my $cat = $opts->{cat};
if ($params->{errors}{package}) {
- fatal_error( _g( "package not valid or not specified" ) );
+ fatal_error( $cat->g( "package not valid or not specified" ) );
}
if ($params->{errors}{suite}) {
- fatal_error( _g( "suite not valid or not specified" ) );
+ fatal_error( $cat->g( "suite not valid or not specified" ) );
}
if (@{$opts->{suite}} > 1) {
- fatal_error( sprintf( _g( "more than one suite specified for show (%s)" ), "@{$opts->{suite}}" ) );
+ fatal_error( $cat->g( "more than one suite specified for show (%s)",
+ "@{$opts->{suite}}" ) );
}
my %contents;
}
unless (@results || @non_results ) {
- fatal_error( _g( "No such package.") );
+ fatal_error( $cat->g( "No such package.") );
#sprintf( _g( '<a href="%s">Search for the package</a>' ), make_search_url('','keywords='.uri_escape($pkg)) ) );
} else {
my %all_suites;
$contents{suites} = [ suites_sort(keys %all_suites) ];
unless (@results) {
- fatal_error( _g( "Package not available in this suite." ) );
+ fatal_error( $cat->g( "Package not available in this suite." ) );
} else {
$contents{page} = $page;
unless ($opts->{source}) {
my $v_str = $version;
my $multiple_versions = grep { $_ ne $version } values %$versions;
- $v_str .= _g(" and others") if $multiple_versions;
+ $v_str .= $cat->g(" and others") if $multiple_versions;
$contents{versions} = { short => $v_str,
multiple => $multiple_versions };
search => 1 );
} else { # unless $page->is_virtual
$contents{is_virtual} = 1;
- $contents{desc}{short} = _g( "virtual package" );
+ $contents{desc}{short} = $cat->g( "virtual package" );
$contents{subsection} = 'virtual';
my $provided_by = $page->{provided_by};
'suggests' => 'sug', 'build-depends' => 'adep',
'build-depends-indep' => 'idep' );
my $suite = $opts->{suite}[0];
+ my $cat = $opts->{cat};
my %out = ( id => $dep_type{$type}, terms => [] );
if ($arch_str ||= '') {
if ($arch_neg) {
- $arch_str = sprintf( _g("not %s"), "$arch_str" );
+ $arch_str = $cat->g("not %s", "$arch_str" );
} else {
$arch_str = $arch_str;
}
}
} elsif ( $rel_out{is_old_pkgs} ) {
} else {
- $rel_alt_out{desc} = _g( "Package not available" );
+ $rel_alt_out{desc} = $cat->g( "Package not available" );
$rel_alt_out{suite} = '';
}
push @{$rel_out{alternatives}}, \%rel_alt_out;
push @$list, { name => $p, desc => $short_desc,
trans_desc => \%sdescs, available => 1 };
} else {
- push @$list, { name => $p, desc => _g("Not available") };
+ push @$list, { name => $p,
+ desc => $opts->{cat}->g("Not available") };
}
}
}
use base 'Exporter';
-our @EXPORT = qw( _g N_ );
+our @EXPORT = qw( N_ );
-sub _g { return $_[0]; }
sub N_ { return $_[0]; }
sub g {