Skip to content
Snippets Groups Projects
Commit 6a0ef149 authored by Guillaume ROUSSE's avatar Guillaume ROUSSE
Browse files

fix automatic lang detection

parent 33feaab2
No related branches found
No related tags found
No related merge requests found
......@@ -68,25 +68,25 @@ sub new {
my $lang;
my $cookies = CGI::Simple::Cookie->fetch();
if ($lang = $self->{cgi}->param('lang')) {
if ($self->{cgi}->param('lang')) {
$lang = $self->{cgi}->param('lang');
$self->{lh} = AccountManager::L10N->get_handle($lang);
$self->{logger}->debugf("setting language from parameter: %s", $lang);
} elsif ($lang = $cookies->{lang} ? $cookies->{lang}->value() : undef) {
} elsif ($cookies->{lang}) {
$lang = $cookies->{lang}->value();
$self->{lh} = AccountManager::L10N->get_handle($lang);
$self->{logger}->debugf("setting language from cookie: %s", $lang);
} elsif ($lang = $ENV{HTTP_ACCEPT_LANGUAGE}) {
$lang = I18N::LangTags::Detect::detect();
if ($lang =~ /^(\w\w)-(\w\w)$/) {
$lang = $1;
}
$self->{lh} = AccountManager::L10N->get_handle($lang);
$self->{logger}->debugf("setting language from HTTP_ACCEPT_LANGUAGE header: %s", $lang);
} else {
$self->{lh} = AccountManager::L10N->get_handle('en');
$self->{logger}->debugf("using default language");
}
$self->{lh} = AccountManager::L10N->get_handle($lang ? $lang: ());
if (!$self->{lh}) {
$self->{logger}->fatal("Unable to get suitable language handle");
$self->respond(
template => 'errors.tt2.html',
data => {
errors => [ 'internal' ]
}
);
}
$self->{lh}->load_custom_lexicon($args{custom_l10n});
if (!$self->{configuration}->{mailer}) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment