Skip to content
● Grav 2.2 is out: 2x faster cold starts and 96% less memory on big sites. Read the announcement →

Making number_format respecting locale?

Started by P. Fighter 8 years ago · 1 replies · 1105 views
8 years ago

I've installed the necessary locale onto my webserver, restarted Apache and override_locale is set to true but none of this seems to do anything.

Is there a way to have Twig format numbers based on locale?

last edited 06/25/18 by P. Fighter
8 years ago

Are the digits in your locale different to 0..9? I'll assume not and it's simply the formatting.

Have you seen the Twig filter number_format? You can also set the default format using that snippet of PHP, which is probably easiest to place in your theme's PHP file. If this filter works and you want help setting a default format with PHP, let me know.

Also note that I don't know exactly what override_locale does, so you may have used that incorrectly for all I know. I am pretty sure it won't make Twig automatically format numbers though. Twig probably treats all numbers dumbly as strings unless you are doing some arithmetic on them, regardless of locale settings.

Suggested topics

Topic Participants Replies Views Activity
General · by lynbor, 3 weeks ago
3 352 3 days ago
General · by lynbor, 1 week ago
7 386 3 days ago
General · by Harry, 3 days ago
0 83 3 days ago
General · by Old Man Umby, 3 weeks ago
2 256 2 weeks ago
General · by jeremycherfas, 3 weeks ago
5 374 2 weeks ago