Hi,
I've made currency Euro config, but there is an'error on currency format.
Error format: 2,000.00 EUR
Good format: 2.000,00 EUR <--- how setup this?
This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.
Please use forum.silverstripe.org for any new questions
(announcement).
The forum archive will stick around, but will be read only.
You can also use our Slack channel
or StackOverflow to ask for help.
Check out our community overview for more options to contribute.
Discuss about the various e-commerce modules available:
Ecommerce, SS Shop, SilverCart and SwipeStripe
Alternatively, have a look the shared mailinglist.
Moderators: martimiz, Nicolaas, Sean, Ed, frankmullenger, biapar, Willr, Ingo, Jedateach, swaiba
Hi,
I've made currency Euro config, but there is an'error on currency format.
Error format: 2,000.00 EUR
Good format: 2.000,00 EUR <--- how setup this?
Don't think it supports this yet.. you would have to make some adjustments to sapphire/core/model/fieldtypes/Currency.php
Maybe using a decorator / extension to keep upgrade capability
How? Or is a localization problem?
in mysite/_config.php, I put:
i18n::enable();
i18n::set_default_lang('it_IT'); // for Ita
i18n::set_locale('it_IT');
Now ok...
in currency.php , I've changed to
number_format(abs($this->value), 2,',','.');
from
number_format(abs($this->value), 2);
Bye
In my opinion It's advisable not to modify core classes but simply to extend them eventually overriding original methods. As an example in MyPage.php:
MyPage_CurrencyEuro extends Currency
{
protected static $currencySymbol = '€';
function Nice()//or NiceEuro() if You don't want to override
{
$val = self::$currencySymbol.' '.number_format(abs($this->value), 2, ',', '.') ;
if($this->value < 0) return "($val)";
else return $val;
}
}
or in a separate class-file CurrencyEuro.php
CurrencyEuro extends Currency
{
protected static $currencySymbol = '€';
function Nice()
{
$val = self::$currencySymbol.' '.number_format(abs($this->value), 2, ',', '.') ;
if($this->value < 0) return "($val)";
else return $val;
}
}