Correctly fallback to en when requesting an unsupported lang

This commit is contained in:
Daniel Berteaud 2015-07-22 15:00:55 +02:00
parent 980b834da6
commit 9c89488558
1 changed files with 3 additions and 1 deletions

View File

@ -1573,10 +1573,12 @@ any [qw(GET POST)] => '/invitation/:token' => { token => '' } => sub {
};
# Create a json script which contains localization
get '/locales/(:lang).js' => { lang => 'en' } => sub {
get '/locales/(:lang).js' => sub {
my $self = shift;
my $usr_lang = $self->languages;
my $req_lang = $self->stash('lang');
$req_lang = (grep { $_ eq $req_lang } $self->get_supported_lang) ?
$req_lang : 'en';
# Temporarily switch to the requested locale
# eg, we can be in en and ask for /locales/fr.js
$self->languages($req_lang);