@@ -65,6 +65,21 @@ goog.i18n.currency.SPACE_FLAG_ = 0x20;
65
65
goog . i18n . currency . tier2Enabled_ = false ;
66
66
67
67
68
+ /**
69
+ * Tests if currency is available.
70
+ *
71
+ * Note: If the currency is not available it might be in the tier2 currency set:
72
+ * {@link goog.i18n.currency.CurrencyInfoTier2}. If that is the case call
73
+ * {@link goog.i18n.currency.addTier2Support} before calling any other function
74
+ * in this namespace.
75
+ *
76
+ * @param {string } currencyCode Currency code to tested.
77
+ * @return {boolean } If the currency is available.
78
+ */
79
+ goog . i18n . currency . isAvailable = function ( currencyCode ) {
80
+ return currencyCode in goog . i18n . currency . CurrencyInfo ;
81
+ } ;
82
+
68
83
/**
69
84
* This function will add tier2 currency support. Be default, only tier1
70
85
* (most popular currencies) are supported. If an application really needs
@@ -84,6 +99,7 @@ goog.i18n.currency.addTier2Support = function() {
84
99
85
100
86
101
/**
102
+ * Deprecated.
87
103
* Global currency pattern always uses ISO-4217 currency code as prefix. Local
88
104
* currency sign is added if it is different from currency code. Each currency
89
105
* is unique in this form. The negative side is that ISO code looks weird in
@@ -92,6 +108,9 @@ goog.i18n.currency.addTier2Support = function() {
92
108
*
93
109
* @param {string } currencyCode ISO-4217 3-letter currency code.
94
110
* @return {string } Global currency pattern string for given currency.
111
+ * @deprecated Format numbers using {@link goog.i18n.NumberFormat} with
112
+ * {@link goog.i18n.NumberFormat.Format.CURRENCY} and
113
+ * {@link goog.i18n.NumberFormat.CurrencyStyle.GLOBAL}
95
114
*/
96
115
goog . i18n . currency . getGlobalCurrencyPattern = function ( currencyCode ) {
97
116
var info = goog . i18n . currency . CurrencyInfo [ currencyCode ] ;
@@ -119,12 +138,16 @@ goog.i18n.currency.getGlobalCurrencySign = function(currencyCode) {
119
138
120
139
121
140
/**
141
+ * Deprecated.
122
142
* Local currency pattern is the most frequently used pattern in currency's
123
143
* native region. It does not care about how it is distinguished from other
124
144
* currencies.
125
145
*
126
146
* @param {string } currencyCode ISO-4217 3-letter currency code.
127
147
* @return {string } Local currency pattern string for given currency.
148
+ * @deprecated Format numbers using {@link goog.i18n.NumberFormat} with
149
+ * {@link goog.i18n.NumberFormat.Format.CURRENCY} and
150
+ * {@link goog.i18n.NumberFormat.CurrencyStyle.LOCAL}
128
151
*/
129
152
goog . i18n . currency . getLocalCurrencyPattern = function ( currencyCode ) {
130
153
var info = goog . i18n . currency . CurrencyInfo [ currencyCode ] ;
@@ -145,6 +168,7 @@ goog.i18n.currency.getLocalCurrencySign = function(currencyCode) {
145
168
146
169
147
170
/**
171
+ * Deprecated.
148
172
* Portable currency pattern is a compromise between local and global. It is
149
173
* not a mere blend or mid-way between the two. Currency sign is chosen so that
150
174
* it looks familiar to native users. It also has enough information to
@@ -154,6 +178,9 @@ goog.i18n.currency.getLocalCurrencySign = function(currencyCode) {
154
178
*
155
179
* @param {string } currencyCode ISO-4217 3-letter currency code.
156
180
* @return {string } Portable currency pattern string for given currency.
181
+ * @deprecated Format numbers using {@link goog.i18n.NumberFormat} with
182
+ * {@link goog.i18n.NumberFormat.Format.CURRENCY} and
183
+ * {@link goog.i18n.NumberFormat.CurrencyStyle.PORTABLE}
157
184
*/
158
185
goog . i18n . currency . getPortableCurrencyPattern = function ( currencyCode ) {
159
186
var info = goog . i18n . currency . CurrencyInfo [ currencyCode ] ;
@@ -174,12 +201,17 @@ goog.i18n.currency.getPortableCurrencySign = function(currencyCode) {
174
201
175
202
176
203
/**
177
- * This function returns the default currency sign position. Some applications
204
+ * This function returns the default currency sign's position. Some applications
178
205
* may want to handle currency sign and currency amount separately. This
179
206
* function can be used in such situations to correctly position the currency
180
207
* sign relative to the amount.
181
208
*
182
- * To match the behavior of ICU, position is not determined by display locale.
209
+ * Use {@link goog.i18n.NumberFormat#isCurrencyCodeBeforeValue} for a locale
210
+ * aware version of this API (recommended). isPrefixSignPosition() returns the
211
+ * default currency sign's position in the currency's default locale (e.g. 'en'
212
+ * for 'USD'), but most commonly the position is needed for the locale in which
213
+ * the number is going to be displayed. For example, in 'fr' 10.10 USD would be
214
+ * displayed as '10,10 $'.
183
215
*
184
216
* @param {string } currencyCode ISO-4217 3-letter currency code.
185
217
* @return {boolean } true if currency should be positioned before amount field.
@@ -267,6 +299,10 @@ goog.i18n.currency.adjustPrecision = function(pattern, currencyCode) {
267
299
* 18: two decimals precision (2), currency sign last (16), no space (0)
268
300
* 50: two decimals precision (2), currency sign last (16), space (32)
269
301
*
302
+ * It's not recommended to read this data directly. Format numbers using
303
+ * {@link goog.i18n.NumberFormat} with
304
+ * {@link goog.i18n.NumberFormat.Format.CURRENCY} instead.
305
+ *
270
306
* @const {!Object<!Array<?>>}
271
307
*/
272
308
goog . i18n . currency . CurrencyInfo = {
@@ -310,7 +346,7 @@ goog.i18n.currency.CurrencyInfo = {
310
346
'NOK' : [ 50 , 'kr' , 'NOkr' ] ,
311
347
'PAB' : [ 2 , 'B/.' , 'B/.' ] ,
312
348
'PEN' : [ 2 , 'S/.' , 'S/.' ] ,
313
- 'PHP' : [ 2 , '\u20B1' , 'Php ' ] ,
349
+ 'PHP' : [ 2 , '\u20B1' , 'PHP ' ] ,
314
350
'PKR' : [ 0 , 'Rs' , 'PKRs.' ] ,
315
351
'PLN' : [ 50 , 'z\u0142' , 'z\u0142' ] ,
316
352
'RON' : [ 2 , 'RON' , 'RON' ] ,
@@ -334,6 +370,11 @@ goog.i18n.currency.CurrencyInfo = {
334
370
335
371
/**
336
372
* Tier 2 currency information.
373
+ *
374
+ * It's not recommended to read this data directly. Format numbers using
375
+ * {@link goog.i18n.NumberFormat} with
376
+ * {@link goog.i18n.NumberFormat.Format.CURRENCY} instead.
377
+ *
337
378
* @const {!Object<!Array<?>>}
338
379
*/
339
380
goog . i18n . currency . CurrencyInfoTier2 = {
@@ -431,7 +472,7 @@ goog.i18n.currency.CurrencyInfoTier2 = {
431
472
'XAF' : [ 0 , 'FCFA' , 'FCFA' ] ,
432
473
'XCD' : [ 2 , '$' , 'EC$' ] ,
433
474
'XOF' : [ 0 , 'CFA' , 'CFA' ] ,
434
- 'XPF' : [ 0 , 'FCFP' , 'FCFP' ] ,
475
+ 'XPF' : [ 48 , 'FCFP' , 'FCFP' ] ,
435
476
'ZMW' : [ 0 , 'ZMW' , 'ZMW' ] ,
436
477
'ZWD' : [ 0 , '$' , 'Z$' ]
437
478
} ;
0 commit comments