Reputation: 2007
I'm using Laravel 4 on TurnkeyLinux and trying to get money_format to display currency in a localized manner.
money_format('%.2n', 1222002.09)
returns 1222002.09.
In app/strart/global.php I have App::setLocale(Session::get('locale', 'en'));
, this alters the language using Laravel's language files but has no effect on currency.
I've discovered that localeconv();
outputs a nearly empty array (only decimal point is set) and using setLocale(LC_ALL, 'en_GB', 'en_GB');
has no effect.
I'm on PHP 5.4.4 and Debian 3.2.57.
Upvotes: 6
Views: 5674
Reputation: 2007
Got it! Thanks to Dmitry Bezik for pointing me in the right direction.
locale -a
returned:
The lack of GB (or US) locales prompted me to do another search that found me this page.
Basically I hadn't got any locales installed, so I followed the instructions and installed the GB locale by doing the following:
en_GB.UTF-8 UTF-8
and removed the leading "#", (if your file is empty, just adding an entry should work)./usr/sbin/locale-gen
as root, this made the system "Generate locales" (which only took a second).setLocale(LC_ALL, 'en_GB.utf8', 'en_GB');
to my blade template and refreshed.Voilà! I now get £1,222,002.09
.
I then moved my setLocale
code into my app/start/global.php just after I set the language so it run on every request.
Upvotes: 7