Skip to content
Grav 2.0 is officially stable. Read the announcement →
General

Making number_format respecting locale?

Started by P. Fighter 8 years ago · 1 replies · 898 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 Hanns Mattes, 3 weeks ago
1 266 3 weeks ago
General · by Andy Miller, 3 weeks ago
0 195 3 weeks ago
General · by Jerry Hunt, 3 weeks ago
2 331 3 weeks ago
General · by pamtbaau, 3 weeks ago
1 253 3 weeks ago
General · by Andy Miller, 3 weeks ago
0 221 3 weeks ago