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

Community guidelines

Please keep discussions civil and on-topic. Repeated violations may lead to a temporary ban.

General

Making number_format respecting locale?

Started by P. Fighter 8 years ago · 1 replies · 838 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 Jerry Hunt, 4 days ago
2 85 13 hours ago
General · by pamtbaau, 18 hours ago
1 60 18 hours ago
General · by Andy Miller, 1 day ago
0 47 1 day ago
General · by Marcel, 12 months ago
6 350 5 days ago
General · by Duc , 6 days ago
3 44 5 days ago