Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Y
yii2
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
PSDI Army
yii2
Commits
4ecbd201
Commit
4ecbd201
authored
May 29, 2014
by
Leandro Gehlen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added `yii\i18n\Formatter::intlCurrencySymbol`
parent
2b5819d0
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
2 deletions
+14
-2
Formatter.php
framework/i18n/Formatter.php
+14
-2
No files found.
framework/i18n/Formatter.php
View file @
4ecbd201
...
@@ -73,6 +73,11 @@ class Formatter extends \yii\base\Formatter
...
@@ -73,6 +73,11 @@ class Formatter extends \yii\base\Formatter
* If not set, the thousand separator corresponding to [[locale]] will be used.
* If not set, the thousand separator corresponding to [[locale]] will be used.
*/
*/
public
$thousandSeparator
;
public
$thousandSeparator
;
/**
* @var string the international curency symbol displayed when formatting a number.
* If not set, the thousand separator corresponding to [[locale]] will be used.
*/
public
$intlCurrencySymbol
;
/**
/**
* Initializes the component.
* Initializes the component.
...
@@ -88,7 +93,7 @@ class Formatter extends \yii\base\Formatter
...
@@ -88,7 +93,7 @@ class Formatter extends \yii\base\Formatter
if
(
$this
->
locale
===
null
)
{
if
(
$this
->
locale
===
null
)
{
$this
->
locale
=
Yii
::
$app
->
language
;
$this
->
locale
=
Yii
::
$app
->
language
;
}
}
if
(
$this
->
decimalSeparator
===
null
||
$this
->
thousandSeparator
===
null
)
{
if
(
$this
->
decimalSeparator
===
null
||
$this
->
thousandSeparator
===
null
||
$this
->
intlCurrencySymbol
===
null
)
{
$formatter
=
new
NumberFormatter
(
$this
->
locale
,
NumberFormatter
::
DECIMAL
);
$formatter
=
new
NumberFormatter
(
$this
->
locale
,
NumberFormatter
::
DECIMAL
);
if
(
$this
->
decimalSeparator
===
null
)
{
if
(
$this
->
decimalSeparator
===
null
)
{
$this
->
decimalSeparator
=
$formatter
->
getSymbol
(
NumberFormatter
::
DECIMAL_SEPARATOR_SYMBOL
);
$this
->
decimalSeparator
=
$formatter
->
getSymbol
(
NumberFormatter
::
DECIMAL_SEPARATOR_SYMBOL
);
...
@@ -96,6 +101,9 @@ class Formatter extends \yii\base\Formatter
...
@@ -96,6 +101,9 @@ class Formatter extends \yii\base\Formatter
if
(
$this
->
thousandSeparator
===
null
)
{
if
(
$this
->
thousandSeparator
===
null
)
{
$this
->
thousandSeparator
=
$formatter
->
getSymbol
(
NumberFormatter
::
GROUPING_SEPARATOR_SYMBOL
);
$this
->
thousandSeparator
=
$formatter
->
getSymbol
(
NumberFormatter
::
GROUPING_SEPARATOR_SYMBOL
);
}
}
if
(
$this
->
intlCurrencySymbol
===
null
)
{
$this
->
intlCurrencySymbol
=
$formatter
->
getSymbol
(
NumberFormatter
::
INTL_CURRENCY_SYMBOL
);
}
}
}
parent
::
init
();
parent
::
init
();
...
@@ -261,11 +269,15 @@ class Formatter extends \yii\base\Formatter
...
@@ -261,11 +269,15 @@ class Formatter extends \yii\base\Formatter
* for details on how to specify a format.
* for details on how to specify a format.
* @return string the formatted result.
* @return string the formatted result.
*/
*/
public
function
asCurrency
(
$value
,
$currency
=
'USD'
,
$format
=
null
)
public
function
asCurrency
(
$value
,
$currency
=
null
,
$format
=
null
)
{
{
if
(
$value
===
null
)
{
if
(
$value
===
null
)
{
return
$this
->
nullDisplay
;
return
$this
->
nullDisplay
;
}
}
if
(
$currency
===
null
){
$currency
=
$this
->
intlCurrencySymbol
;
}
return
$this
->
createNumberFormatter
(
NumberFormatter
::
CURRENCY
,
$format
)
->
formatCurrency
(
$value
,
$currency
);
return
$this
->
createNumberFormatter
(
NumberFormatter
::
CURRENCY
,
$format
)
->
formatCurrency
(
$value
,
$currency
);
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment