Discussion:
How to get user culture / actual locale in twig template
Daniel Ancuta
2011-08-01 20:14:44 UTC
Permalink
Hi everyone,
I am "working" with Symfony2 from yesterday, and I have a simple
problem. How to get access to user culture (actual locale) in twig
template?

I found that is something like "app.user" but it return NULL if user
is not authenticated. Also is there a list (if possible) of variables
that I can execute from twig template that are similar to variables in
Symfony 1.4 template system e.g. $sf_user, $sf_request ?
--
If you want to report a vulnerability issue on symfony, please send it to security at symfony-project.com

You received this message because you are subscribed to the Google
Groups "Symfony2" group.
To post to this group, send email to symfony2-/***@public.gmane.org
To unsubscribe from this group, send email to
symfony2+unsubscribe-/***@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/symfony2?hl=en
FKowal
2012-01-21 22:54:28 UTC
Permalink
Hi,
Sorry for this late answer, I was looking for the same thing and finally I
get it, perhaps it could help :
You can get the current culture in twig by using the following syntax : {{
app.request.get('_locale') }}
--
If you want to report a vulnerability issue on symfony, please send it to security at symfony-project.com

You received this message because you are subscribed to the Google
Groups "Symfony2" group.
To post to this group, send email to symfony2-/***@public.gmane.org
To unsubscribe from this group, send email to
symfony2+unsubscribe-/***@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/symfony2?hl=en
Pierre Goudjo
2012-05-12 17:38:13 UTC
Permalink
Hi,
Doesn't work for me. But {{ app.request.locale }} work
Post by FKowal
Hi,
Sorry for this late answer, I was looking for the same thing and finally I
You can get the current culture in twig by using the following syntax : {{
app.request.get('_locale') }}
--
If you want to report a vulnerability issue on symfony, please send it to security at symfony-project.com

You received this message because you are subscribed to the Google
Groups "Symfony2" group.
To post to this group, send email to symfony2-/***@public.gmane.org
To unsubscribe from this group, send email to
symfony2+unsubscribe-/***@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/symfony2?hl=en
Lhassan Baazzi
2012-05-15 16:22:22 UTC
Permalink
Hi,

Both work very well
{{ app.request.get('_locale') }}
{{ app.session.locale }}
thanks
Hi everyone,
I am "working" with Symfony2 from yesterday, and I have a simple
problem. How to get access to user culture (actual locale) in twig
template?
I found that is something like "app.user" but it return NULL if user
is not authenticated. Also is there a list (if possible) of variables
that I can execute from twig template that are similar to variables in
Symfony 1.4 template system e.g. $sf_user, $sf_request ?
--
If you want to report a vulnerability issue on symfony, please send it to security at symfony-project.com

You received this message because you are subscribed to the Google
Groups "Symfony2" group.
To post to this group, send email to symfony2-/***@public.gmane.org
To unsubscribe from this group, send email to
symfony2+unsubscribe-/***@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/symfony2?hl=en
Mario Alberto Alvarez Garcia
2012-05-15 19:46:37 UTC
Permalink
In Symfony2 was {{ app.session.locale }} but in Symfony2.1(master) is {{
app.request.locale }}
Post by Lhassan Baazzi
Hi,
Both work very well
{{ app.request.get('_locale') }}
{{ app.session.locale }}
thanks
Hi everyone,
I am "working" with Symfony2 from yesterday, and I have a simple
problem. How to get access to user culture (actual locale) in twig
template?
I found that is something like "app.user" but it return NULL if user
is not authenticated. Also is there a list (if possible) of variables
that I can execute from twig template that are similar to variables in
Symfony 1.4 template system e.g. $sf_user, $sf_request ?
--
If you want to report a vulnerability issue on symfony, please send it to security at symfony-project.com

You received this message because you are subscribed to the Google
Groups "Symfony2" group.
To post to this group, send email to symfony2-/***@public.gmane.org
To unsubscribe from this group, send email to
symfony2+unsubscribe-/***@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/symfony2?hl=en
Loading...