]> git.deb.at Git - deb/packages.git/blobdiff - bin/create_index_pages
Split the creation of the suite index pages out of create_index_pages
[deb/packages.git] / bin / create_index_pages
index eb797d34bb0c906bed604857e3dc92a7482143bf..53443bc08bb1d1f666064629590089cc2d9c3ebe 100755 (executable)
@@ -9,12 +9,11 @@ use DB_File;
 use Storable;
 use HTML::Entities;
 use URI::Escape;
-use Locale::gettext;
 use Compress::Zlib;
 
 use lib './lib';
 
-use Packages::Config qw( $TOPDIR $DBDIR @ARCHIVES @SUITES @LANGUAGES $LOCALES);
+use Packages::Config qw( $TOPDIR $DBDIR @ARCHIVES @SUITES @LANGUAGES );
 use Packages::Template;
 use Packages::I18N::Locale;
 use Packages::Page;
@@ -22,16 +21,6 @@ use Packages::SrcPage;
 use Packages::Sections;
 &Packages::Config::init( './' );
 
-delete $ENV{'LANGUAGE'};
-delete $ENV{'LANG'};
-delete $ENV{'LC_ALL'};
-delete $ENV{'LC_MESSAGES'};
-bindtextdomain ( 'pdo', $LOCALES );
-bindtextdomain ( 'templates', $LOCALES );
-bindtextdomain ( 'sections', $LOCALES );
-bindtextdomain ( 'langs', $LOCALES );
-textdomain( 'pdo' );
-
 my $wwwdir = "$TOPDIR/www";
 
 tie my %packages, 'DB_File', "$DBDIR/packages_small.db",
@@ -59,49 +48,6 @@ my (%pages);
 my $template = new Packages::Template( "$TOPDIR/templates", 'html');
 my $txt_template = new Packages::Template( "$TOPDIR/templates", 'txt');
 
-print "write suite index files ...\n";
-foreach my $s (@SUITES) {
-    my $key = $s;
-    mkpath ( "$wwwdir/$key" );
-    mkpath ( "$wwwdir/source/$key" );
-    foreach my $lang (@LANGUAGES) {
-       my $locale = get_locale( $lang );
-       my $charset = get_charset( $lang );
-       setlocale ( LC_ALL, $locale ) or do {
-           warn "couldn't set locale ($lang/$locale)\n";
-           next;
-       };
-       print "writing $key/index (lang=$lang)...\n";
-
-       my %content = ( subsections => [], suite => $s,
-                       lang => $lang, charset => $charset,
-                       used_langs => \@LANGUAGES, suites => \@SUITES );
-       foreach my $ssec ((keys %{$subsections->{$s}}, 'virtual')) {
-           next if $ssec eq '-';
-           if ($sections_descs{$ssec}) {
-               push @{$content{subsections}}, {
-                   id => $ssec,
-                   name => dgettext( 'sections', $sections_descs{$ssec}[0] ),
-                   desc => dgettext( 'sections', $sections_descs{$ssec}[1] ),
-               };
-           }
-       }
-
-       $template->page( 'suite_index', \%content,
-                        "$wwwdir/$key/index.$lang.html.new");
-       rename( "$wwwdir/$key/index.$lang.html.new",
-               "$wwwdir/$key/index.$lang.html" );
-
-       $content{source} = 'source';
-       $template->page( 'suite_index', \%content,
-                        "$wwwdir/source/$key/index.$lang.html.new");
-       rename( "$wwwdir/source/$key/index.$lang.html.new",
-               "$wwwdir/source/$key/index.$lang.html" );
-
-    }
-}
-setlocale( LC_ALL, 'C' ) or die "couldn't reset locale";
-
 print "collecting package info ...\n";
 my %allpkgs;
 while (my ($pkg, $data) = each %packages) {
@@ -211,15 +157,13 @@ sub write_files {
        my $key = $s;
        mkpath ( "$wwwdir/$source$key" );
        foreach my $lang (@LANGUAGES) {
-           my $locale = get_locale( $lang );
-           my $charset = get_charset( $lang );
-           setlocale ( LC_ALL, $locale ) or do {
-               warn "couldn't set locale ($lang/$locale)\n";
-               next;
-           };
+           my $charset = 'UTF-8';
+           my $cat = Packages::I18N::Locale->get_handle($lang)
+               or die "get_handle failed for $lang";
 
-           my %lang_vars = ( lang => $lang, charset => $charset,
-                             used_langs => \@LANGUAGES );
+           my %lang_vars = ( po_lang => $lang, ddtp_lang => $lang,
+                             charset => $charset,
+                             cat => $cat, used_langs => \@LANGUAGES );
            print "writing $source$s/allpackages (lang=$lang)...\n";
            $template->page( 'index', { %lang_vars, packages => $pkgs->{$key},
                                        suite => $s, is_source => $source  },
@@ -247,7 +191,7 @@ sub write_files {
                print "writing $source$s/$sec/index (lang=$lang)...\n";
                $template->page( 'index', { packages => [ grep { $_->{section} eq $sec } @{$pkgs->{$key}} ],
                                            %lang_vars, suite => $s, is_source => $source,
-                                           category => { id => _g('Section'), name => $sec } },
+                                           category => { id => $cat->g('Section'), name => $sec } },
                                 "$wwwdir/$source$key/$sec/index.$lang.html.new" );
                rename( "$wwwdir/$source$key/$sec/index.$lang.html.new",
                        "$wwwdir/$source$key/$sec/index.$lang.html" );
@@ -259,7 +203,7 @@ sub write_files {
                print "writing $source$s/$ssec/index (lang=$lang)...\n";
                $template->page( 'index', { packages => [ grep { $_->{subsection} eq $ssec } @{$pkgs->{$key}} ],
                                            %lang_vars, suite => $s, is_source => $source,
-                                           category => { id => _g('Subsection'), name => $ssec } },
+                                           category => { id => $cat->g('Subsection'), name => $ssec } },
                                 "$wwwdir/$source$key/$ssec/index.$lang.html.new" );
                rename( "$wwwdir/$source$key/$ssec/index.$lang.html.new",
                        "$wwwdir/$source$key/$ssec/index.$lang.html" );
@@ -271,7 +215,7 @@ sub write_files {
                print "writing $source$s/$prio/index (lang=$lang)...\n";
                $template->page( 'index', { packages => [ grep { $_->{priority} eq $prio } @{$pkgs->{$key}} ],
                                            %lang_vars, suite => $s, is_source => $source,
-                                           category => { id => _g('Priority'), name => $prio } },
+                                           category => { id => $cat->g('Priority'), name => $prio } },
                                 "$wwwdir/$source$key/$prio/index.$lang.html.new" );
                rename( "$wwwdir/$source$key/$prio/index.$lang.html.new",
                        "$wwwdir/$source$key/$prio/index.$lang.html" );