Version 4.1.2
This commit is contained in:
1 parent
3ba79295ee
commit
28bd025b35
1131 files changed
+63658
-20579
No files matched your search
@@ -123,10 +123,42 @@ class _Money
|
||||
{
|
||||
/* If the server has intl installed, use that */
|
||||
if ( function_exists( 'numfmt_format_currency' ) )
|
||||
{
|
||||
{
|
||||
/* Unfortunately a bug in intl means that locales which use commas for decimal separation are broken.
|
||||
@link https://community.invisionpower.com/4bugtrack/active-reports/nexus-money-formatting-r6911/ .
|
||||
What we'll do is store the current locale, reset to English, then reset back to current locale afterwards. */
|
||||
$currentLocale = setlocale( LC_ALL, '0' );
|
||||
|
||||
if( mb_strtoupper( mb_substr( PHP_OS, 0, 3 ) ) === 'WIN' )
|
||||
{
|
||||
setlocale( LC_ALL, 'english' );
|
||||
}
|
||||
else
|
||||
{
|
||||
setlocale( LC_ALL, 'en_US' );
|
||||
}
|
||||
|
||||
$format = numfmt_create( $language->short, \NumberFormatter::CURRENCY );
|
||||
|
||||
if ( $return = numfmt_format_currency( $format, $this->amount, $this->currency ) and $return !== 'NaN' )
|
||||
{
|
||||
/* Now we have to reset locale back to what it was */
|
||||
foreach( explode( ";", $currentLocale ) as $locale )
|
||||
{
|
||||
if( mb_strpos( $locale, '=' ) !== FALSE )
|
||||
{
|
||||
$parts = explode( "=", $locale );
|
||||
if( in_array( $parts[0], array( 'LC_ALL', 'LC_COLLATE', 'LC_CTYPE', 'LC_MONETARY', 'LC_NUMERIC', 'LC_TIME' ) ) )
|
||||
{
|
||||
setlocale( constant( $parts[0] ), $parts[1] );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
setLocale( LC_ALL, $locale );
|
||||
}
|
||||
}
|
||||
|
||||
return $return;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user