Discussion:
Twig: show the name of the months based on the current locale
tirengarfio
2012-07-30 19:14:42 UTC
Permalink
Hi,

I'm just trying to show the name of the months based on the current locale.

{{ event.date|date('F') }}

but the months are always shown in english...

I have tried this code below I found here<https://github.com/fabpot/Twig/issues/378>,
but the result is the same...

class Helper_Twig extends Twig_Extension
{
public function getFilters()
{
return array(
'datetime' => new Twig_Filter_Method($this, 'datetime')
);
}

public function datetime($d, $format = "%B %e")
{
if ($d instanceof \DateTime) {
$d = $d->getTimestamp();
}

return strftime($format, $d);
}

public function getName()
{
return 'Helper';
}
}

*NOTE:* In the controller I'm checking the current locale using
$request->getLocale and it corresponds to the locale parameter I'm
switching in parameters.yml.

What is the problem?

sf 2.1

Javi
--
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
smurfy
2012-07-30 19:31:25 UTC
Permalink
Hey,

maybe this is something for you:

https://github.com/fabpot/Twig-extensions/blob/master/lib/Twig/Extensions/Extension/Intl.php

greetings,
smurfy

Loading...