From: Frank Lichtenheld Date: Sun, 28 Oct 2007 20:36:08 +0000 (+0100) Subject: Support translated short descriptions in index pages X-Git-Url: https://git.deb.at/w?a=commitdiff_plain;h=17913bc92f23cb3cd03978f24825f4f8823dfb8f;p=deb%2Fpackages.git Support translated short descriptions in index pages --- diff --git a/bin/create_index_pages b/bin/create_index_pages index d76beba..eb797d3 100755 --- a/bin/create_index_pages +++ b/bin/create_index_pages @@ -43,6 +43,9 @@ tie my %src_packages, 'DB_File', "$DBDIR/sources_small.db", tie my %src2bin, 'DB_File', "$DBDIR/sources_packages.db", O_RDONLY, 0666, $DB_BTREE or die "couldn't open $DBDIR/sources_packages.db: $!"; +tie my %desctrans, 'DB_File', "$DBDIR/descriptions_translated.db", + O_RDONLY, 0666, $DB_BTREE + or die "couldn't tie DB $DBDIR/descriptions_translated.db: $!"; my $sections = retrieve "$DBDIR/sections.info"; my $subsections = retrieve "$DBDIR/subsections.info"; @@ -106,7 +109,7 @@ while (my ($pkg, $data) = each %packages) { my ($virt, $p_data) = split /\000/o, $data, 2; %virt = split /\01/o, $virt; foreach (split /\000/o, $p_data||'') { - my @data = split ( /\s/o, $_, 8 ); + my @data = split ( /\s/o, $_, 9 ); $pkg{$data[1]} ||= new Packages::Page( $pkg ); $pkg{$data[1]}->merge_package( { package => $pkg, archive => $data[0], @@ -116,7 +119,8 @@ while (my ($pkg, $data) = each %packages) { subsection => $data[4], priority => $data[5], version => $data[6], - description => $data[7] } ); + 'description-md5' => $data[7], + description => $data[8] } ); } foreach (keys %virt) { next if $_ eq '-'; @@ -138,6 +142,18 @@ while (my ($pkg, $data) = each %packages) { $p{section} = $entry->get_newest( 'section' ); $p{archive} = $entry->get_newest( 'archive' ); $p{desc} = $entry->get_newest( 'description' ); + my $desc_md5 = $entry->get_newest( 'description-md5' ); + my $trans_desc = $desctrans{$desc_md5}; + if ($trans_desc) { + my %sdescs; + my %trans_desc = split /\000|\001/, $trans_desc; + while (my ($l, $d) = each %trans_desc) { + $d =~ s/\n.*//os; + + $sdescs{$l} = $d; + } + $p{trans_desc} = \%sdescs; + } $p{priority} = $entry->get_newest( 'priority' ); } push @{$allpkgs{$key}}, \%p; diff --git a/templates/html/index.tmpl b/templates/html/index.tmpl index a5139b5..63d5f49 100644 --- a/templates/html/index.tmpl +++ b/templates/html/index.tmpl @@ -33,6 +33,11 @@ [% PROCESS marker text=section IF section != main_section %] [% PROCESS marker text=archive IF archive != main_archive %] [% END %] + [%- IF trans_desc.$lang; + sdesc = trans_desc.$lang; + ELSE; + sdesc = desc; + END -%] [% IF providers.size %]
[% name %]
[% g('virtual package provided by') %] @@ -40,11 +45,11 @@ [%- ', ' UNLESS loop.last %][% END %]
[% IF versions.length %]
[% name %] ([% versions %])[% PROCESS markers %]
-
[% desc | html %]
+
[% sdesc | html %]
[% END %] [% ELSE %]
[% name %] ([% versions %])[% PROCESS markers %]
-
[% desc | html %]
+
[% sdesc | html %]
[% END %] [% '' IF loop.last %]