From: Frank Lichtenheld Date: Sat, 4 Jul 2009 20:30:21 +0000 (+0200) Subject: Make static pages translatable via templates.pot and convert homepage to use it X-Git-Url: https://git.deb.at/w?a=commitdiff_plain;h=597347c0fe994954d5e5168368fb21e743a39def;p=deb%2Fpackages.git Make static pages translatable via templates.pot and convert homepage to use it This is currently only for the benefit of every site except packages.d.o since that uses a page on www.d.o instead which is translated there. --- diff --git a/bin/translate_static_page b/bin/translate_static_page new file mode 100755 index 0000000..e62bbb9 --- /dev/null +++ b/bin/translate_static_page @@ -0,0 +1,42 @@ +#!/usr/bin/perl + +use strict; +use warnings; + +use POSIX; +use File::Basename; + +use lib './lib'; + +use Packages::CommonCode qw(:all); +use Packages::Config qw( $TOPDIR $DBDIR @ARCHIVES @SUITES @LANGUAGES ); +use Packages::Template; +use Packages::I18N::Locale; +&Packages::Config::init( './' ); + +my $template = new Packages::Template( "$TOPDIR/templates", 'html'); + +if( @ARGV % 2 ){ + die "usage: translate_static_page [[template outputfile]...]\n"; +} +my %pages = @ARGV; +print "translate static pages ...\n"; +while( my ($tmpl, $output) = each %pages ) { + my $outdir = dirname($output); + my $outfile = basename($output); + mkdirp ( $outdir ); + foreach my $lang (@LANGUAGES) { + my $charset = 'UTF-8'; + my $cat = Packages::I18N::Locale->get_handle($lang) + or die "get_handle failed for $lang"; + print "writing $outfile (lang=$lang)...\n"; + + my %content = ( po_lang => $lang, ddtp_lang => $lang, + charset => $charset, cat => $cat, + used_langs => \@LANGUAGES ); + + $template->page( $tmpl, \%content, + "$TOPDIR/$output.$lang.html.new"); + activate( "$TOPDIR/$output.$lang.html" ); + } +} diff --git a/cron.d/500update_po b/cron.d/500update_po index 9950b8a..5a84ea9 100755 --- a/cron.d/500update_po +++ b/cron.d/500update_po @@ -31,6 +31,7 @@ templates/html/error.tmpl templates/html/filelist.tmpl templates/html/foot.tmpl templates/html/head.tmpl +templates/html/homepage.tmpl templates/html/index_head.tmpl templates/html/index_foot.tmpl templates/html/messages.tmpl diff --git a/cron.d/700install_static b/cron.d/700install_static index 933fb21..05723a4 100755 --- a/cron.d/700install_static +++ b/cron.d/700install_static @@ -6,5 +6,8 @@ set -e test -d "$htmldir" || mkdir -p "$htmldir" -cd "$topdir" && ttree --perl5lib=${libdir} --load_perl --eval_perl \ - -f ./conf/ttreerc +cd "$topdir" +ttree --perl5lib=${libdir} --load_perl --eval_perl \ + -f ./conf/ttreerc + +./bin/translate_static_page homepage www/index diff --git a/static/index.tmpl b/static/index.tmpl deleted file mode 100644 index 524dff3..0000000 --- a/static/index.tmpl +++ /dev/null @@ -1,129 +0,0 @@ -[%- PROCESS 'html/head.tmpl' - title_tag = "$organisation Packages Search" - page_title = "$organisation Packages Search" - keywords = "$organisation, Packages" --%] -[%- - all_suites = [ 'etch', 'etch-m68k', 'etch-volatile', 'etch-backports', - 'lenny', 'lenny-volatile', 'lenny-backports', 'squeeze', 'sid' ] - version_numbers = { sarge => '3.1', - etch => '4.0', - lenny => '5.0' } - current_release = 'lenny' - all_sections = [ 'main', 'contrib', 'non-free' ] - all_architectures = [ 'alpha', 'arm', 'armel', 'amd64', 'avr32', 'hppa', 'i386', - 'ia64', 'kfreebsd-amd64', 'kfreebsd-i386', 'mips', - 'mipsel', 'm68k', 'powerpc', 's390', 'sparc' ] --%] - -

This site provides you with information about all the packages -available in the [% organisation %] -Package archive. - -

Please contact [% admin.name %] -if you encounter any problems!

- -

Browse through the lists of packages:

- - - -

There is also a list of packages -recently added to [% all_suites.-1 %].

- -

Search

- -

Search package directories

- -
- - - -
-Search on: - -   - - - - - -
-Only show exact matches: - -
-Distribution: - -Section: - -
-

There are shortcuts for some searches available:

- -
- -

Search the contents of packages

- -

This search engine allows you to search the contents of [% organisation %] -distributions for any files (or just parts of file names) that are -part of packages. -You can also get a full list of files in a given package. -
-

- - - -   - - -
-Display: -
- - -
- - -
- - -
- - - - - -
- -[% PROCESS 'html/foot.tmpl' - langs.size = 0 - copyright.years = '1997 - 2008' %] diff --git a/templates/html/foot.tmpl b/templates/html/foot.tmpl index 5a98997..7944c67 100644 --- a/templates/html/foot.tmpl +++ b/templates/html/foot.tmpl @@ -5,7 +5,7 @@ Total page evaluation took [% benchmark %]