use Storable;
use HTML::Entities;
use URI::Escape;
-use Locale::gettext;
use Compress::Zlib;
use lib './lib';
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",
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;
- };
+ my $charset = 'UTF-8';
+ my $cat = Packages::I18N::Locale->get_handle($lang)
+ or die "get_handle failed for $lang";
print "writing $key/index (lang=$lang)...\n";
my %content = ( subsections => [], suite => $s,
- lang => $lang, charset => $charset,
+ lang => $lang, charset => $charset, cat => $cat,
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] ),
+ name => $cat->g($sections_descs{$ssec}[0]),
+ desc => $cat->g($sections_descs{$ssec}[1]),
};
}
}
}
}
-setlocale( LC_ALL, 'C' ) or die "couldn't reset locale";
print "collecting package info ...\n";
my %allpkgs;
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 );
+ 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 },
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" );
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" );
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" );
use Data::Dumper;
use HTML::Entities;
use URI::Escape;
-use Locale::gettext;
use Deb::Versions;
use Packages::Template;
$/ = "";
-delete $ENV{'LANGUAGE'};
-delete $ENV{'LANG'};
-delete $ENV{'LC_ALL'};
-delete $ENV{'LC_MESSAGES'};
-bindtextdomain ( 'debtags', $LOCALES );
-textdomain( 'debtags' );
-
sub process_desc {
my ($desc) = @_;
$voc_db{$voc_key} = $sdesc || "";
foreach my $lang (@LANGUAGES) {
- my $locale = get_locale( $lang );
- setlocale ( LC_ALL, $locale ) or do {
- warn "couldn't set locale ($lang/$locale)\n";
- next;
- };
+ next if $lang eq 'en';
+
+ my $cat = Packages::I18N::Locale->get_handle($lang)
+ or die "get_handle failed for $lang";
- my $sdesc_trans = dgettext( 'debtags', $sdesc );
+ my $sdesc_trans = $cat->maketext($sdesc);
$voc_db{"$voc_key-$lang"} = $sdesc_trans
if $sdesc_trans and $sdesc_trans ne $sdesc;
}
my @tags = sort( grep { exists $voc{$_}{tag} } keys %voc );
my %tags_by_facet;
foreach (@tags) {
- my ($facet, $tag) = split /::/, $_, 2;
+ my ($facet, $tag) = split m/::/, $_, 2;
warn "No facet data available for $facet\n"
unless exists $voc{$facet};
$tags_by_facet{$facet} ||= [];
use warnings;
use Template;
-use Locale::gettext;
use URI ();
use HTML::Entities ();
use URI::Escape ();
#use Data::Dumper;
#die Dumper($self, $action, $page_content);
+ if ($page_content->{cat}) {
+ $page_content->{g} =
+ sub { return Packages::I18N::Locale::g($page_content->{cat}, @_) };
+ }
$page_content->{used_langs} ||= \@LANGUAGES;
$page_content->{langs} = languages( $page_content->{lang}
|| $self->{vars}{lang} || 'en',
sub languages {
my ( $lang, @used_langs ) = @_;
-
+ my $cat = Packages::I18N::Locale->get_handle($lang)
+ || Packages::I18N::Locale->get_handle('en');
+
my @langs;
if (@used_langs) {
-
+
my @printed_langs = ();
foreach (@used_langs) {
next if $_ eq $lang; # Never print the current language
foreach my $cur_lang (sort langcmp @printed_langs) {
my %lang;
$lang{lang} = $cur_lang;
- $lang{tooltip} = dgettext( "langs", get_language_name($cur_lang) );
- $lang{selfname} = get_selfname($cur_lang);
- $lang{transliteration} = get_transliteration($cur_lang) if defined get_transliteration($cur_lang);
+ $lang{tooltip} = $cat->g(get_language_name($cur_lang));
+ $lang{selfname} = get_selfname($cur_lang);
+ $lang{transliteration} = get_transliteration($cur_lang)
+ if defined get_transliteration($cur_lang);
push @langs, \%lang;
}
}
-
+
return \@langs;
}