From: Frank Lichtenheld Date: Mon, 10 Dec 2007 18:44:13 +0000 (+0100) Subject: Packages::I18N::Locale: Load .po files on module load X-Git-Url: https://git.deb.at/w?a=commitdiff_plain;h=95a88f632e71b7cd3037856ac164c691d593414c;p=deb%2Fpackages.git Packages::I18N::Locale: Load .po files on module load Hardcode the po directory path with setup-site. The performance gain is worth the added uglyness. --- diff --git a/bin/create_index_pages b/bin/create_index_pages index 0cc0bf8..4e09430 100755 --- a/bin/create_index_pages +++ b/bin/create_index_pages @@ -20,7 +20,6 @@ use Packages::Page; use Packages::SrcPage; use Packages::Sections; &Packages::Config::init( './' ); -&Packages::I18N::Locale::load( "$TOPDIR/po" ); my $wwwdir = "$TOPDIR/www"; diff --git a/bin/parse-debtags-voc b/bin/parse-debtags-voc index be25178..4fd49f9 100755 --- a/bin/parse-debtags-voc +++ b/bin/parse-debtags-voc @@ -34,7 +34,6 @@ use Packages::Template; use Packages::Config qw( $TOPDIR @LANGUAGES ); use Packages::I18N::Locale; &Packages::Config::init( './' ); -&Packages::I18N::Locale::load( "$TOPDIR/po" ); my $debtagsdir = "$TOPDIR/files/debtags"; my $wwwdir = "$TOPDIR/www/about"; my $voc_file = "$debtagsdir/vocabulary"; diff --git a/lib/Packages/Dispatcher.pm b/lib/Packages/Dispatcher.pm index f65ec1a..3113683 100755 --- a/lib/Packages/Dispatcher.pm +++ b/lib/Packages/Dispatcher.pm @@ -91,7 +91,6 @@ sub do_dispatch { my $homedir = dirname($ENV{SCRIPT_FILENAME}).'/../'; &Packages::Config::init( $homedir ); &Packages::DB::init(); - &Packages::I18N::Locale::load( "$homedir/po" ); my $acc = I18N::AcceptLanguage->new(); my %all_langs = map { $_ => 1 } (@LANGUAGES, @DDTP_LANGUAGES); diff --git a/lib/Packages/I18N/.gitignore b/lib/Packages/I18N/.gitignore new file mode 100644 index 0000000..2319e27 --- /dev/null +++ b/lib/Packages/I18N/.gitignore @@ -0,0 +1 @@ +Locale.pm diff --git a/lib/Packages/I18N/Locale.pm b/lib/Packages/I18N/Locale.pm deleted file mode 100644 index c65c9b7..0000000 --- a/lib/Packages/I18N/Locale.pm +++ /dev/null @@ -1,41 +0,0 @@ -package Packages::I18N::Locale; - -use strict; -use warnings; - -use base 'Locale::Maketext'; -use Locale::Maketext::Lexicon; - -use base 'Exporter'; - -our @EXPORT = qw( N_ ); - -sub load { - my ($podir) = @_; - - Locale::Maketext::Lexicon->import( { - 'en' => [Gettext => "$podir/pdo.pot", - Gettext => "$podir/templates.pot", - Gettext => "$podir/langs.pot", - Gettext => "$podir/sections.pot", - Gettext => "$podir/debtags.pot"], - '*' => [Gettext => "$podir/pdo.*.po", - Gettext => "$podir/templates.*.po", - Gettext => "$podir/langs.*.po", - Gettext => "$podir/sections.*.po", - Gettext => "$podir/debtags.*.po"], - _auto => 1, - _style => 'gettext', - } ); -} - -sub N_ { return $_[0]; } - -sub g { - my ($self, $format, @args) = @_; - my $result = $self->maketext($format, @args); - return sprintf($result, @args) if $result =~ /%([su]|[.\d]*f)/; - return $result; -} - -1; diff --git a/lib/Packages/I18N/Locale.pm.sed.in b/lib/Packages/I18N/Locale.pm.sed.in new file mode 100644 index 0000000..11c75a3 --- /dev/null +++ b/lib/Packages/I18N/Locale.pm.sed.in @@ -0,0 +1,35 @@ +package Packages::I18N::Locale; + +use strict; +use warnings; + +use base 'Locale::Maketext'; +use Locale::Maketext::Lexicon { + 'en' => [Gettext => "%TOPDIR%/po/pdo.pot", + Gettext => "%TOPDIR%/po/templates.pot", + Gettext => "%TOPDIR%/po/langs.pot", + Gettext => "%TOPDIR%/po/sections.pot", + Gettext => "%TOPDIR%/po/debtags.pot"], + '*' => [Gettext => "%TOPDIR%/po/pdo.*.po", + Gettext => "%TOPDIR%/po/templates.*.po", + Gettext => "%TOPDIR%/po/langs.*.po", + Gettext => "%TOPDIR%/po/sections.*.po", + Gettext => "%TOPDIR%/po/debtags.*.po"], + _auto => 1, + _style => 'gettext', +}; + +use base 'Exporter'; + +our @EXPORT = qw( N_ ); + +sub N_ { return $_[0]; } + +sub g { + my ($self, $format, @args) = @_; + my $result = $self->maketext($format, @args); + return sprintf($result, @args) if $result =~ /%([su]|[.\d]*f)/; + return $result; +} + +1;