Hardcode the po directory path with setup-site.
The performance gain is worth the added uglyness.
use Packages::SrcPage;
use Packages::Sections;
&Packages::Config::init( './' );
-&Packages::I18N::Locale::load( "$TOPDIR/po" );
my $wwwdir = "$TOPDIR/www";
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";
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);
+++ /dev/null
-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;
--- /dev/null
+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;