]> git.sesse.net Git - wloh/blobdiff - www/index.pl
Support translation of templates via po4a. Add an English translation as an example.
[wloh] / www / index.pl
index 2b7dcaf31c03080d745526cd1cbc843cfb5a8f4b..4fef4a7e4e319abe764e9edf78b844412cbb753d 100755 (executable)
@@ -138,9 +138,9 @@ sub get_covariance_matrix {
 }
 
 sub write_parms_to_file {
-       my ($aux_parms, $match_stddev, $used_ratings, $used_cov) = @_;
+       my ($locale, $aux_parms, $match_stddev, $used_ratings, $used_cov) = @_;
 
-       POSIX::setlocale(&POSIX::LC_ALL, 'nb_NO.UTF-8');
+       wloh_common::set_locale($locale);
 
        my @sorted_players = sort { $players{$a} cmp $players{$b} } keys %players;
 
@@ -175,7 +175,7 @@ sub write_parms_to_file {
        }
        close MCCALC;
 
-       POSIX::setlocale(&POSIX::LC_ALL, 'nb_NO.UTF-8');
+       wloh_common::set_locale($locale);
 
        return $tmpnam;
 }
@@ -183,7 +183,7 @@ sub write_parms_to_file {
 sub make_table {
        my ($locale, $aux_parms, $match_stddev, $lowest_division, $used_ratings, $used_cov, $division, $subdivision, $table_id) = @_;
 
-       my $tmpnam = write_parms_to_file($aux_parms, $match_stddev, $used_ratings, $used_cov);
+       my $tmpnam = write_parms_to_file($locale, $aux_parms, $match_stddev, $used_ratings, $used_cov);
        my %prob = ();
 
        open MCCALC, "$config::base_dir/mcwordfeud $trials < $tmpnam |"
@@ -352,7 +352,7 @@ get_players_and_ratings($dbh, $locale, $season, $division, $subdivision);
 my $cov = get_covariance_matrix($dbh, keys %players);
 
 if (defined($match_player) && defined($match_position)) {
-       my $tmpnam = write_parms_to_file($aux_parms, $match_stddev, \%ratings, $cov);
+       my $tmpnam = write_parms_to_file($locale, $aux_parms, $match_stddev, \%ratings, $cov);
 
        --$match_player;
        --$match_position;
@@ -377,20 +377,20 @@ if (defined($match_player) && defined($match_position)) {
 
        if (scalar @scenario == 0) {
                print CGI->header(-type=>'text/html; charset=utf-8', -expires=>'+5m');
-               wloh_common::process_template('scenario-not-found.xml', {
+               wloh_common::process_template('scenario-not-found', $locale, {
                        '#nick' => $player_name,
                        '#rank' => sprintf("%d.", $match_position + 1)
                });
        } else {
                print CGI->header(-type=>'text/html; charset=utf-8', -expires=>'+5m');
-               wloh_common::process_template('scenario.xml', {
+               wloh_common::process_template('scenario', $locale, {
                        '#nick' => $player_name,
                        '#rank' => sprintf("%d.", $match_position + 1),
                        '#results' => \@scenario
                });
        }
 } else {
-       POSIX::setlocale(&POSIX::LC_ALL, 'nb_NO.UTF-8');
+       wloh_common::set_locale($locale);
 
        my $max_division = $divisions[$#divisions];
        my $lowest_division = ($division == $max_division);
@@ -401,7 +401,7 @@ if (defined($match_player) && defined($match_position)) {
        my $avg_rating = find_avg_rating(\%ratings);
 
        print CGI->header(-type=>'text/html; charset=utf-8', -expires=>'+5m');
-       wloh_common::process_template('index.xml', {
+       wloh_common::process_template('index', $locale, {
                '#navbar' => wloh_common::get_navbar($cgi, $dbh, $locale),
                '#division-selector/action' => "/$locale/",
                '#division' => get_division_selector(\@divisions, $division),