diff options
author | Frank Lichtenheld <frank@lichtenheld.de> | 2009-07-04 22:30:21 +0200 |
---|---|---|
committer | Frank Lichtenheld <frank@lichtenheld.de> | 2009-07-04 22:30:21 +0200 |
commit | 597347c0fe994954d5e5168368fb21e743a39def (patch) | |
tree | 0fa91c7f94519e2dbcec00ca39389fb3aa72c262 /bin | |
parent | 15a0877194f3d709bf080d35a51a649ea1ef7b51 (diff) |
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.
Diffstat (limited to 'bin')
-rwxr-xr-x | bin/translate_static_page | 42 |
1 files changed, 42 insertions, 0 deletions
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" ); + } +} |