Good Evening!
As a matter of fact there are many Place Value Systems in place. CouchCMS happens to implement the International Place Value System by default.
Now as a use case, I need to display an amount. For ex:
Up until PHP 7.3,x there exists a function money_format. But from > PHP 7.4.0 the function got deprecated and in PHP 8, it was totally removed.
So since PHP 7.4.0 and after, NumberFormatter Class is suggested to be used. An example of implementation can be found here.
My request would be, can there be a native implementation in CouchCMS as there is for time-zones in the "couch/config.php", which is:
If this could be implemented through the couch/config.php, it would be great, as it would solve a lot of hassles (though I cannot think much about multi-lingual sites).
A straightforward implementation as:
would output:
while for en_DE locale (a list of locale can be found here), it would output:
Making it very easy to handle currency symbols, decimal characters, thousands_separator etc.
Nevertheless, I suppose a small implementation could also come in with the <cms:number_format> tag. Something like the no round-off feature.
If the same tag can have an attribute as pvs_format, where pvs_format could takeon the locale values like en_IN, en_DE, de_DE, etc. and implement the NumberFormatter Class it would be really helpful.
Does it sound useful to others too?
@KK Sir: Could you please have a look at this!
Regards,
GenXCoders
As a matter of fact there are many Place Value Systems in place. CouchCMS happens to implement the International Place Value System by default.
Now as a use case, I need to display an amount. For ex:
Amount = 123456789.00
In International Place Value System it would be: 123,456,789.00
In Indian Place Value System it would be: 12,34,56,789.00
Up until PHP 7.3,x there exists a function money_format. But from > PHP 7.4.0 the function got deprecated and in PHP 8, it was totally removed.
So since PHP 7.4.0 and after, NumberFormatter Class is suggested to be used. An example of implementation can be found here.
My request would be, can there be a native implementation in CouchCMS as there is for time-zones in the "couch/config.php", which is:
- Code: Select all
// 2.
// Your Time Zone
// Example values (note how :15, :30, :45 will be entered as .25, .5 and .75 respectively):
// +12.75 New Zealand (UTC+12:45)
// +8.75 Australia (UTC+08:45)
// +5.5 India (UTC+05:30)
// +1 Germany (UTC+01:00)
// 0 United Kingdom (UTC±0)
// -2 Brazil (UTC-02:00)
// -4.5 Venezuela (UTC-04:30)
// -6 United States (Central Time) (UTC-06:00)
// -8 United States (Pacific Time) (UTC-08:00)
define( 'K_GMT_OFFSET', +5.5 );
If this could be implemented through the couch/config.php, it would be great, as it would solve a lot of hassles (though I cannot think much about multi-lingual sites).
A straightforward implementation as:
- Code: Select all
$amount = new \NumberFormatter( 'en_IN', \NumberFormatter::CURRENCY );
return $amount->format( 123456789 );
would output:
₹ 12,34,56,789.00
while for en_DE locale (a list of locale can be found here), it would output:
€123.456.789,00
Making it very easy to handle currency symbols, decimal characters, thousands_separator etc.
Nevertheless, I suppose a small implementation could also come in with the <cms:number_format> tag. Something like the no round-off feature.
Example usage of no round-off
<cms:number_format '21.188' /> // outputs 21.19
<cms:number_format '21.188' round='0' /> // outputs 21.18
If the same tag can have an attribute as pvs_format, where pvs_format could takeon the locale values like en_IN, en_DE, de_DE, etc. and implement the NumberFormatter Class it would be really helpful.
- Code: Select all
<cms:number_format '21.188' round='0' pvs_format='en_IN' />
Does it sound useful to others too?
@KK Sir: Could you please have a look at this!
Regards,
GenXCoders