From: Frank Lichtenheld Date: Sun, 21 Oct 2007 22:24:48 +0000 (+0200) Subject: Make short descriptions translatable X-Git-Url: https://git.deb.at/w?a=commitdiff_plain;h=994eceb69bd5a8865a51e00b3cfb1c7a1f03f78e;p=deb%2Fpackages.git Make short descriptions translatable Add description md5sum to packages_small entries. Use this to translate the short descriptions in search results and dependency listings. --- diff --git a/bin/parse-packages b/bin/parse-packages index 3c78323..61d6b84 100755 --- a/bin/parse-packages +++ b/bin/parse-packages @@ -157,7 +157,7 @@ for my $suite (@SUITES) { $subsections{$suite}{$subsection}++; $priorities{$suite}{$data{priority}}++; my $pkgitem = "$archive $suite $data{'architecture'} ". - "$section $subsection $data{'priority'} $data{'version'} $sdescr\0"; + "$section $subsection $data{'priority'} $data{'version'} $data{'description-md5'} $sdescr\0"; my $previtem = ($packages_small{$data{'package'}}{$suite}{$data{'architecture'}} ||= $pkgitem); $packages_small{$data{'package'}}{$suite}{$data{'architecture'}} = $pkgitem diff --git a/lib/Packages/DoSearch.pm b/lib/Packages/DoSearch.pm index 77bedfb..31e110d 100644 --- a/lib/Packages/DoSearch.pm +++ b/lib/Packages/DoSearch.pm @@ -88,7 +88,7 @@ sub do_search { unless ($opts->{source}) { foreach (@results) { my ($pkg_t, $archive, $suite, $arch, $section, $subsection, - $priority, $version, $desc) = @$_; + $priority, $version, $desc_md5, $desc) = @$_; my ($pkg) = $pkg_t =~ m/^(.+)/; # untaint if ($arch ne 'virtual') { @@ -97,7 +97,7 @@ sub do_search { $sect{$pkg}{$suite}{$version} = $section; $archives{$pkg}{$suite}{$version} ||= $archive; - $desc{$pkg}{$suite}{$version} = $desc; + $desc{$pkg}{$suite}{$version} = [ $desc_md5, $desc ]; } else { $provided_by{$pkg}{$suite} = [ split /\s+/, $desc ]; } @@ -197,9 +197,22 @@ sub process_package { my @versions = version_sort keys %{$pkgs->{$suite}}; $suite{section} = $sect->{$suite}{$versions[0]}; $suite{subsection} = $subsect->{$suite}{$versions[0]}; - $suite{desc} = $desc->{$suite}{$versions[0]}; + my $desc_md5 = $desc->{$suite}{$versions[0]}[0]; + $suite{desc} = $desc->{$suite}{$versions[0]}[1]; $suite{versions} = []; - + + my $trans_desc = $desctrans{$desc_md5}; + my %sdescs; + if ($trans_desc) { + my %trans_desc = split /\000|\001/, $trans_desc; + while (my ($l, $d) = each %trans_desc) { + $d =~ s/\n.*//os; + + $sdescs{$l} = $d; + } + $suite{trans_desc} = \%sdescs; + } + foreach my $v (@versions) { my %version; $version{version} = $v; diff --git a/lib/Packages/DoShow.pm b/lib/Packages/DoShow.pm index 38b34fb..0c65ec1 100644 --- a/lib/Packages/DoShow.pm +++ b/lib/Packages/DoShow.pm @@ -89,7 +89,7 @@ sub do_show { for my $entry (@results) { debug( join(":", @$entry), 1 ) if DEBUG; my (undef, $archive, undef, $arch, $section, $subsection, - $priority, $version, $provided_by) = @$entry; + $priority, $version, undef, $provided_by) = @$entry; if ($arch ne 'virtual') { my %data = split /\000/, $packages_all{"$pkg $arch $version"}; @@ -440,11 +440,23 @@ sub build_deps { my $entry = $entries{$p_name} || read_entry_simple( $packages, $p_name, $opts->{h_archives}, $suite); my $short_desc = $entry->[-1]; + my $desc_md5 = $entry->[-2]; my $arch = $entry->[3]; my $archive = $entry->[1]; my $p_suite = $entry->[2]; if ( $short_desc ) { $rel_alt_out{desc} = $short_desc; + my $trans_desc = $desctrans{$desc_md5}; + if ($trans_desc) { + my %trans_desc = split /\000|\001/, $trans_desc; + my %sdescs; + while (my ($l, $d) = each %trans_desc) { + $d =~ s/\n.*//os; + + $sdescs{$l} = $d; + } + $rel_alt_out{trans_desc} = \%sdescs; + } $rel_alt_out{suite} = $p_suite; if ( $rel_out{is_old_pkgs} ) { } elsif (defined $entry->[1]) { @@ -483,10 +495,22 @@ sub pkg_list { # we don't deal with virtual packages here because for the # current uses of this function this isn't needed - my $short_desc = (read_entry_simple( $packages, $p, $opts->{h_archives}, $suite))->[-1]; + my $data = read_entry_simple( $packages, $p, $opts->{h_archives}, $suite); + my ($desc_md5, $short_desc) = ($data->[-2],$data->[-1]); if ( $short_desc ) { - push @$list, { name => $p, desc => $short_desc, available => 1 }; + my $trans_desc = $desctrans{$desc_md5}; + my %sdescs; + if ($trans_desc) { + my %trans_desc = split /\000|\001/, $trans_desc; + while (my ($l, $d) = each %trans_desc) { + $d =~ s/\n.*//os; + + $sdescs{$l} = $d; + } + } + push @$list, { name => $p, desc => $short_desc, + trans_desc => \%sdescs, available => 1 }; } else { push @$list, { name => $p, desc => _g("Not available") }; } diff --git a/lib/Packages/Search.pm b/lib/Packages/Search.pm index be7bebd..52f451e 100644 --- a/lib/Packages/Search.pm +++ b/lib/Packages/Search.pm @@ -74,16 +74,16 @@ sub read_entry_all { while (my ($suite, $provides) = each %virt) { next if $suite eq '-'; if ($opts->{h_suites}{$suite}) { - push @$results, [ $key, "-", $suite, 'virtual', 'v', 'v', 'v', 'v', + push @$results, [ $key, "-", $suite, 'virtual', 'v', 'v', 'v', 'v', 'v', $provides]; } else { - push @$non_results, [ $key, "-", $suite, 'virtual', 'v', 'v', 'v', 'v', + push @$non_results, [ $key, "-", $suite, 'virtual', 'v', 'v', 'v', 'v', 'v', $provides]; } } foreach (split(/\000/o, $result||'')) { - my @data = split ( /\s/o, $_, 8 ); + my @data = split ( /\s/o, $_, 9 ); debug( "Considering entry ".join( ':', @data), 2) if DEBUG; if ($opts->{h_suites}{$data[1]} && ($opts->{h_archs}{$data[2]} || $data[2] eq 'all') @@ -123,7 +123,7 @@ sub read_entry_simple { # with correctly, but it's adequate enough for now return [ $virt{$suite} ] unless defined $result; foreach (split /\000/o, $result) { - my @data = split ( /\s/o, $_, 8 ); + my @data = split ( /\s/o, $_, 9 ); debug( "use entry: @data", 2 ) if DEBUG && $data[1] eq $suite; return [ $virt{$suite}, @data ] if $data[1] eq $suite; } diff --git a/templates/html/search.tmpl b/templates/html/search.tmpl index 31dd928..8e6bed4 100644 --- a/templates/html/search.tmpl +++ b/templates/html/search.tmpl @@ -88,7 +88,7 @@ [% FOREACH s IN suites; suite = s.suite %]
  • [% suite %] - [%- ' (' _ suite_aliases.$suite _ ')' IF suite_aliases.$suite %][% ' (' _ s.subsection _ ')' IF s.subsection %]: [% s.desc %] [%- IF s.section != main_section %] [[% s.section %]][% END %] + [%- ' (' _ suite_aliases.$suite _ ')' IF suite_aliases.$suite %][% ' (' _ s.subsection _ ')' IF s.subsection %]: [% IF s.trans_desc.$lang; s.trans_desc.$lang | html; ELSE; s.desc | html; END %] [%- IF s.section != main_section %] [[% s.section %]][% END %] [% FOREACH s.versions %]
    [% version %] [%- IF archive != main_archive %] [[% archive %]][% END %]: [% architectures.join(' ') %] [% END %] diff --git a/templates/html/show.tmpl b/templates/html/show.tmpl index eee041b..0c27c00 100644 --- a/templates/html/show.tmpl +++ b/templates/html/show.tmpl @@ -196,19 +196,19 @@ [%- END %] [% END %] -[% FOREACH providers %] +[% FOREACH p IN providers %] [% IF loop.first %]

    [% g('Packages providing %s', pkg) %]

    [% END %] -
    [% IF available %][% name %][% ELSE %][% name %][% END %]
    -
    [% desc %]
    +
    [% IF p.available %][% p.name %][% ELSE; p.name; END %]
    +
    [% IF p.trans_desc.$lang; p.trans_desc.$lang | html; ELSE; p.desc | html; END %]
    [% '
    ' IF loop.last %] [% END %] [% END %] -[% FOREACH binaries %] +[% FOREACH b IN binaries %] [% IF loop.first %]
    [% g('The following binary packages are built from this source package:') %]
    [% END %] -
    [% IF available %][% name %][% ELSE %][% name %][% END %]
    -
    [% desc %]
    +
    [% IF b.available %][% b.name %][% ELSE; b.name; END %]
    +
    [% IF b.trans_desc.$lang; b.trans_desc.$lang | html; ELSE; b.desc | html; END %]
    [% '
    ' IF loop.last %] [% END %] @@ -239,7 +239,7 @@ [% ' (' _ version _ ')' IF version %] [% ' [' _ arch_str _ ']' IF arch_str %] [%- IF !is_old_pkgs -%] -
    [% desc -%] +
    [% IF trans_desc.$lang; trans_desc.$lang | html; ELSE; desc | html; END -%] [%- IF providers.pkgs.size > 0 -%] [% IF providers.also; '
    ' _ g('also a virtual package provided by');