I'm customizing my error pages and I was wandering if it is possible to get the language of the country user directly in my template, without the controller.
Asked
Active
Viewed 699 times
1 Answers
0
You can use :
{{ app.request.locale }}
Edit
Ah i didn't understood the question but this is what you are looking for :
$request->getPreferredLanguage($anArrayOfYourSupportedLanguages);
Then pass it to your twig. fabpot answer :
https://groups.google.com/forum/#!topic/symfony-devs/-2AwAQhlLLQ

Nawfal Serrar
- 2,213
- 1
- 14
- 22
-
Won't this just return my default langugae? Because I would really like if there was a way to get the used language according to the country the personne is in. – Kévin Duguay Apr 03 '15 at 01:51
-
updated my answer. getPreferredLanguage and pass it to your twig – Nawfal Serrar Apr 03 '15 at 02:28