Skip to content

Commit

Permalink
Added section on currency formatting. Closes globalizejs#66
Browse files Browse the repository at this point in the history
  • Loading branch information
rdworth committed Feb 24, 2012
1 parent 32b6db0 commit 95714e1
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ as an extensible system for localization.
<li><a href="#extend">Utilizing and Extending Cultures</a></li>
<li><a href="#defining">Defining Culture Information</a></li>
<li><a href="#numbers">Number Formatting</a></li>
<li><a href="#currency">Currency Formatting</a></li>
<li><a href="#dates">Date Formatting</a></li>
<li><a href="#generating">Generating Culture Files</a></li>
</ul>
Expand Down Expand Up @@ -556,6 +557,27 @@ Globalize.format( 0.12345, "p4" ); // 12.3450 %
Parsing with parseInt and parseFloat also accepts any of these formats.
</p>

<a name="currency"></a>
<h2 id="currency">Currency Formatting</h2>
<p>
Globalize has a default currency symbol for each locale. This is used when
formatting a currency value such as
<pre>
Globalize.format( 1234.56, "c" ); // $1,234.56
</pre>
You can change the currency symbol for a locale by modifying the culture's
<code>numberFormat.currency.symbol</code> property:
<pre>
Globalize.culture( "en-US" ).numberFormat.currency.symbol = '\u20ac'; // euro sign U+20AC
</pre>
If you need to switch between currency symbols, you could write a function
to do that, such as
<pre>
function setCurrency( currSym ) {
Globalize.culture().numberFormat.currency.symbol = currSym;
}
</pre>

<a name="dates"></a>
<h2 id="dates">Date Formatting</h2>
<p>
Expand Down

0 comments on commit 95714e1

Please sign in to comment.