|
|
@ -1583,24 +1583,20 @@ get '/locales/(:lang).js' => sub { |
|
|
|
my $fallback_strings = {}; |
|
|
|
my $fallback_strings = {}; |
|
|
|
foreach my $string (keys %Vroom::I18N::fr::Lexicon){ |
|
|
|
foreach my $string (keys %Vroom::I18N::fr::Lexicon){ |
|
|
|
next if $string eq ''; |
|
|
|
next if $string eq ''; |
|
|
|
$strings->{$string} = $self->l($string); |
|
|
|
if ($self->l($string) ne ''){ |
|
|
|
} |
|
|
|
$strings->{$string} = $self->l($string); |
|
|
|
# If lang is not en, send also en as a fallback locale |
|
|
|
} |
|
|
|
# useful if a locale is not complete |
|
|
|
else{ |
|
|
|
if ($req_lang ne 'en'){ |
|
|
|
$self->languages('en'); |
|
|
|
$self->languages('en'); |
|
|
|
$strings->{$string} = $self->l($string); |
|
|
|
foreach my $string (keys %Vroom::I18N::fr::Lexicon){ |
|
|
|
$self->languages($req_lang); |
|
|
|
next if $string eq ''; |
|
|
|
|
|
|
|
$fallback_strings->{$string} = $self->l($string); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
# Set the user locale back |
|
|
|
# Set the user locale back |
|
|
|
$self->languages($usr_lang); |
|
|
|
$self->languages($usr_lang); |
|
|
|
my $res = 'locale = ' . Mojo::JSON::to_json($strings) . ';'; |
|
|
|
|
|
|
|
$res .= 'fallback_locale = ' . Mojo::JSON::to_json($fallback_strings) . ';'; |
|
|
|
|
|
|
|
# And send the response |
|
|
|
# And send the response |
|
|
|
return $self->render( |
|
|
|
return $self->render( |
|
|
|
text => $res, |
|
|
|
text => 'locale = ' . Mojo::JSON::to_json($strings) . ';', |
|
|
|
format => 'application/javascript;charset=UTF-8' |
|
|
|
format => 'application/javascript;charset=UTF-8' |
|
|
|
); |
|
|
|
); |
|
|
|
}; |
|
|
|
}; |
|
|
|