]> git.deb.at Git - deb/packages.git/commitdiff
Packages::I18N::Locale: Load .po files on module load
authorFrank Lichtenheld <frank@lichtenheld.de>
Mon, 10 Dec 2007 18:44:13 +0000 (19:44 +0100)
committerFrank Lichtenheld <frank@lichtenheld.de>
Mon, 10 Dec 2007 20:28:40 +0000 (21:28 +0100)
Hardcode the po directory path with setup-site.
The performance gain is worth the added uglyness.

bin/create_index_pages
bin/parse-debtags-voc
lib/Packages/Dispatcher.pm
lib/Packages/I18N/.gitignore [new file with mode: 0644]
lib/Packages/I18N/Locale.pm [deleted file]
lib/Packages/I18N/Locale.pm.sed.in [new file with mode: 0644]

index 0cc0bf8fe3cd0ce2e43d03e3f9a1a3531d0c2b2a..4e094302746b131708f6af53223cafdaa4bbe4f2 100755 (executable)
@@ -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";
 
index be251781a89616dafd66b880f84473a15675ca88..4fd49f9e6b2bedb93eb5cec77e57c02e6a871209 100755 (executable)
@@ -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";
index f65ec1ab4c6fe4fec8e2de38130a1e812b23f1b7..3113683c010cf210de0f24c88162a7189df4b2e8 100755 (executable)
@@ -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 (file)
index 0000000..2319e27
--- /dev/null
@@ -0,0 +1 @@
+Locale.pm
diff --git a/lib/Packages/I18N/Locale.pm b/lib/Packages/I18N/Locale.pm
deleted file mode 100644 (file)
index c65c9b7..0000000
+++ /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 (file)
index 0000000..11c75a3
--- /dev/null
@@ -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;