Skip to content
Grav 2.1 is out: every page speaks Markdown. Read the announcement →

Making number_format respecting locale?

Started by P. Fighter 8 years ago · 1 replies · 1046 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 jeremycherfas, 4 days ago
2 86 15 hours ago
General · by Old Man Umby, 2 days ago
1 60 2 days ago
General · by Sebastian, 4 days ago
1 81 4 days ago
General · by Andy Miller, 2 weeks ago
0 215 2 weeks ago
General · by ready-4-IT, 6 months ago
1 716 3 weeks ago