3333
3434
3535goog . provide ( 'goog.i18n.currency' ) ;
36+ goog . provide ( 'goog.i18n.currency.CurrencyInfo' ) ;
37+ goog . provide ( 'goog.i18n.currency.CurrencyInfoTier2' ) ;
3638
3739
3840/**
@@ -46,7 +48,7 @@ goog.i18n.currency.PRECISION_MASK_ = 0x07;
4648 * Whether the currency sign should be positioned after the number.
4749 * @private
4850 */
49- goog . i18n . currency . POSITION_FLAG_ = 0x08 ;
51+ goog . i18n . currency . POSITION_FLAG_ = 0x10 ;
5052
5153
5254/**
@@ -56,16 +58,27 @@ goog.i18n.currency.POSITION_FLAG_ = 0x08;
5658goog . i18n . currency . SPACE_FLAG_ = 0x20 ;
5759
5860
61+ /**
62+ * Whether tier2 was enabled already by calling addTier2Support().
63+ * @private
64+ */
65+ goog . i18n . currency . tier2Enabled_ = false ;
66+
67+
5968/**
6069 * This function will add tier2 currency support. Be default, only tier1
6170 * (most popular currencies) are supported. If an application really needs
6271 * to support some of the rarely used currencies, it should call this function
6372 * before any other functions in this namespace.
6473 */
6574goog . i18n . currency . addTier2Support = function ( ) {
66- for ( var key in goog . i18n . currency . CurrencyInfoTier2 ) {
67- goog . i18n . currency . CurrencyInfo [ key ] =
68- goog . i18n . currency . CurrencyInfoTier2 [ key ] ;
75+ // Protection from executing this these again and again.
76+ if ( ! goog . i18n . currency . tier2Enabled_ ) {
77+ for ( var key in goog . i18n . currency . CurrencyInfoTier2 ) {
78+ goog . i18n . currency . CurrencyInfo [ key ] =
79+ goog . i18n . currency . CurrencyInfoTier2 [ key ] ;
80+ }
81+ goog . i18n . currency . tier2Enabled_ = true ;
6982 }
7083} ;
7184
@@ -244,60 +257,75 @@ goog.i18n.currency.adjustPrecision = function(pattern, currencyCode) {
244257 * the currency sign should be positioned after the number. Valid values are 0
245258 * (before the number) or 16 (after the number). The space flag indicates
246259 * whether a space should be inserted between the currency sign and number.
247- * Valid values are 0 (no space) and 24 (space).
260+ * Valid values are 0 (no space) and 32 (space).
248261 *
249262 * The number in the array is calculated by adding together the mask and flag
250263 * values. For example:
251264 *
252265 * 0: no precision (0), currency sign first (0), no space (0)
253266 * 2: two decimals precision (2), currency sign first (0), no space (0)
254267 * 18: two decimals precision (2), currency sign last (16), no space (0)
255- * 42 : two decimals precision (2), currency sign last (16), space (24 )
268+ * 50 : two decimals precision (2), currency sign last (16), space (32 )
256269 *
257270 * @type {!Object.<!Array> }
258271 */
259272goog . i18n . currency . CurrencyInfo = {
260273 'AED' : [ 2 , 'dh' , '\u062f.\u0625.' , 'DH' ] ,
274+ 'ALL' : [ 0 , 'Lek' , 'Lek' ] ,
261275 'AUD' : [ 2 , '$' , 'AU$' ] ,
262276 'BDT' : [ 2 , '\u09F3' , 'Tk' ] ,
277+ 'BGN' : [ 2 , 'lev' , 'lev' ] ,
263278 'BRL' : [ 2 , 'R$' , 'R$' ] ,
264279 'CAD' : [ 2 , '$' , 'C$' ] ,
280+ 'CDF' : [ 2 , 'FrCD' , 'CDF' ] ,
265281 'CHF' : [ 2 , 'CHF' , 'CHF' ] ,
266282 'CLP' : [ 0 , '$' , 'CL$' ] ,
267283 'CNY' : [ 2 , '¥' , 'RMB¥' ] ,
268284 'COP' : [ 0 , '$' , 'COL$' ] ,
269285 'CRC' : [ 0 , '\u20a1' , 'CR\u20a1' ] ,
270- 'CZK' : [ 2 , 'K\u010d' , 'K\u010d' ] ,
286+ 'CZK' : [ 50 , 'K\u010d' , 'K\u010d' ] ,
271287 'DKK' : [ 18 , 'kr' , 'kr' ] ,
272288 'DOP' : [ 2 , '$' , 'RD$' ] ,
273289 'EGP' : [ 2 , '£' , 'LE' ] ,
274- 'EUR' : [ 18 , '€' , '€' ] ,
290+ 'ETB' : [ 2 , 'Birr' , 'Birr' ] ,
291+ 'EUR' : [ 2 , '€' , '€' ] ,
275292 'GBP' : [ 2 , '£' , 'GB£' ] ,
276293 'HKD' : [ 2 , '$' , 'HK$' ] ,
294+ 'HRK' : [ 2 , 'kn' , 'kn' ] ,
295+ 'HUF' : [ 0 , 'Ft' , 'Ft' ] ,
296+ 'IDR' : [ 0 , 'Rp' , 'Rp' ] ,
277297 'ILS' : [ 2 , '\u20AA' , 'IL\u20AA' ] ,
278298 'INR' : [ 2 , '\u20B9' , 'Rs' ] ,
299+ 'IRR' : [ 0 , 'Rial' , 'IRR' ] ,
279300 'ISK' : [ 0 , 'kr' , 'kr' ] ,
280301 'JMD' : [ 2 , '$' , 'JA$' ] ,
281302 'JPY' : [ 0 , '¥' , 'JP¥' ] ,
282303 'KRW' : [ 0 , '\u20A9' , 'KR₩' ] ,
283304 'LKR' : [ 2 , 'Rs' , 'SLRs' ] ,
305+ 'LTL' : [ 2 , 'Lt' , 'Lt' ] ,
306+ 'LVL' : [ 2 , 'Ls' , 'Ls' ] ,
284307 'MNT' : [ 0 , '\u20AE' , 'MN₮' ] ,
285308 'MXN' : [ 2 , '$' , 'Mex$' ] ,
286309 'MYR' : [ 2 , 'RM' , 'RM' ] ,
287- 'NOK' : [ 18 , 'kr' , 'NOkr' ] ,
310+ 'NOK' : [ 50 , 'kr' , 'NOkr' ] ,
288311 'PAB' : [ 2 , 'B/.' , 'B/.' ] ,
289312 'PEN' : [ 2 , 'S/.' , 'S/.' ] ,
290313 'PHP' : [ 2 , '\u20B1' , 'Php' ] ,
291314 'PKR' : [ 0 , 'Rs' , 'PKRs.' ] ,
292- 'RUB' : [ 42 , 'руб.' , 'руб.' ] ,
315+ 'PLN' : [ 50 , 'z\u0142' , 'z\u0142' ] ,
316+ 'RON' : [ 2 , 'RON' , 'RON' ] ,
317+ 'RSD' : [ 0 , 'din' , 'RSD' ] ,
318+ 'RUB' : [ 50 , 'руб.' , 'руб.' ] ,
293319 'SAR' : [ 2 , 'Rial' , 'Rial' ] ,
294320 'SEK' : [ 2 , 'kr' , 'kr' ] ,
295321 'SGD' : [ 2 , '$' , 'S$' ] ,
296322 'THB' : [ 2 , '\u0e3f' , 'THB' ] ,
297323 'TRY' : [ 2 , 'TL' , 'YTL' ] ,
298324 'TWD' : [ 2 , 'NT$' , 'NT$' ] ,
325+ 'TZS' : [ 0 , 'TSh' , 'TSh' ] ,
326+ 'UAH' : [ 2 , '\u20B4' , 'UAH' ] ,
299327 'USD' : [ 2 , '$' , 'US$' ] ,
300- 'UYU' : [ 2 , '$' , 'UY$ ' ] ,
328+ 'UYU' : [ 2 , '$' , '$U ' ] ,
301329 'VND' : [ 0 , '\u20AB' , 'VN\u20AB' ] ,
302330 'YER' : [ 0 , 'Rial' , 'Rial' ] ,
303331 'ZAR' : [ 2 , 'R' , 'ZAR' ]
@@ -309,16 +337,14 @@ goog.i18n.currency.CurrencyInfo = {
309337 * @type {!Object.<!Array> }
310338 */
311339goog . i18n . currency . CurrencyInfoTier2 = {
312- 'AFN' : [ 16 , 'Af.' , 'AFN' ] ,
313- 'ALL' : [ 0 , 'Lek' , 'Lek' ] ,
340+ 'AFN' : [ 48 , 'Af.' , 'AFN' ] ,
314341 'AMD' : [ 0 , 'Dram' , 'dram' ] ,
315342 'AOA' : [ 2 , 'Kz' , 'Kz' ] ,
316343 'ARS' : [ 2 , '$' , 'AR$' ] ,
317344 'AWG' : [ 2 , 'Afl.' , 'Afl.' ] ,
318345 'AZN' : [ 2 , 'man.' , 'man.' ] ,
319- 'BAM' : [ 18 , 'KM' , 'KM' ] ,
346+ 'BAM' : [ 2 , 'KM' , 'KM' ] ,
320347 'BBD' : [ 2 , '$' , 'Bds$' ] ,
321- 'BGN' : [ 2 , 'lev' , 'lev' ] ,
322348 'BHD' : [ 3 , 'din' , 'din' ] ,
323349 'BIF' : [ 0 , 'FBu' , 'FBu' ] ,
324350 'BMD' : [ 2 , '$' , 'BD$' ] ,
@@ -329,14 +355,12 @@ goog.i18n.currency.CurrencyInfoTier2 = {
329355 'BWP' : [ 2 , 'P' , 'pula' ] ,
330356 'BYR' : [ 0 , 'BYR' , 'BYR' ] ,
331357 'BZD' : [ 2 , '$' , 'BZ$' ] ,
332- 'CDF' : [ 2 , 'FrCD' , 'CDF' ] ,
333358 'CUC' : [ 1 , '$' , 'CUC$' ] ,
334359 'CUP' : [ 2 , '$' , 'CU$' ] ,
335360 'CVE' : [ 2 , 'CVE' , 'Esc' ] ,
336361 'DJF' : [ 0 , 'Fdj' , 'Fdj' ] ,
337362 'DZD' : [ 2 , 'din' , 'din' ] ,
338363 'ERN' : [ 2 , 'Nfk' , 'Nfk' ] ,
339- 'ETB' : [ 2 , 'Birr' , 'Birr' ] ,
340364 'FJD' : [ 2 , '$' , 'FJ$' ] ,
341365 'FKP' : [ 2 , '£' , 'FK£' ] ,
342366 'GEL' : [ 2 , 'GEL' , 'GEL' ] ,
@@ -347,12 +371,8 @@ goog.i18n.currency.CurrencyInfoTier2 = {
347371 'GTQ' : [ 2 , 'Q' , 'GTQ' ] ,
348372 'GYD' : [ 0 , '$' , 'GY$' ] ,
349373 'HNL' : [ 2 , 'L' , 'HNL' ] ,
350- 'HRK' : [ 2 , 'kn' , 'kn' ] ,
351374 'HTG' : [ 2 , 'HTG' , 'HTG' ] ,
352- 'HUF' : [ 0 , 'Ft' , 'Ft' ] ,
353- 'IDR' : [ 0 , 'Rp' , 'Rp' ] ,
354375 'IQD' : [ 0 , 'din' , 'IQD' ] ,
355- 'IRR' : [ 0 , 'Rial' , 'IRR' ] ,
356376 'JOD' : [ 3 , 'din' , 'JOD' ] ,
357377 'KES' : [ 2 , 'Ksh' , 'Ksh' ] ,
358378 'KGS' : [ 2 , 'KGS' , 'KGS' ] ,
@@ -366,8 +386,6 @@ goog.i18n.currency.CurrencyInfoTier2 = {
366386 'LBP' : [ 0 , 'L£' , 'LBP' ] ,
367387 'LRD' : [ 2 , '$' , 'L$' ] ,
368388 'LSL' : [ 2 , 'LSL' , 'LSL' ] ,
369- 'LTL' : [ 2 , 'Lt' , 'Lt' ] ,
370- 'LVL' : [ 2 , 'Ls' , 'Ls' ] ,
371389 'LYD' : [ 3 , 'din' , 'LD' ] ,
372390 'MAD' : [ 2 , 'dh' , 'MAD' ] ,
373391 'MDL' : [ 2 , 'MDL' , 'MDL' ] ,
@@ -386,11 +404,8 @@ goog.i18n.currency.CurrencyInfoTier2 = {
386404 'NZD' : [ 2 , '$' , 'NZ$' ] ,
387405 'OMR' : [ 3 , 'Rial' , 'OMR' ] ,
388406 'PGK' : [ 2 , 'PGK' , 'PGK' ] ,
389- 'PLN' : [ 2 , 'z\u0142' , 'z\u0142' ] ,
390407 'PYG' : [ 0 , 'Gs' , 'PYG' ] ,
391408 'QAR' : [ 2 , 'Rial' , 'QR' ] ,
392- 'RON' : [ 2 , 'RON' , 'RON' ] ,
393- 'RSD' : [ 0 , 'din' , 'RSD' ] ,
394409 'RWF' : [ 0 , 'RF' , 'RF' ] ,
395410 'SBD' : [ 2 , '$' , 'SI$' ] ,
396411 'SCR' : [ 2 , 'SCR' , 'SCR' ] ,
@@ -400,16 +415,13 @@ goog.i18n.currency.CurrencyInfoTier2 = {
400415 'SOS' : [ 0 , 'SOS' , 'SOS' ] ,
401416 'SRD' : [ 2 , '$' , 'SR$' ] ,
402417 'STD' : [ 0 , 'Db' , 'Db' ] ,
403- 'SYP' : [ 16 , '£' , 'SY£' ] ,
418+ 'SYP' : [ 0 , '£' , 'SY£' ] ,
404419 'SZL' : [ 2 , 'SZL' , 'SZL' ] ,
405420 'TJS' : [ 2 , 'Som' , 'TJS' ] ,
406421 'TND' : [ 3 , 'din' , 'DT' ] ,
407422 'TOP' : [ 2 , 'T$' , 'T$' ] ,
408423 'TTD' : [ 2 , '$' , 'TT$' ] ,
409- 'TZS' : [ 0 , 'TSh' , 'TSh' ] ,
410- 'UAH' : [ 2 , '\u20B4' , 'UAH' ] ,
411424 'UGX' : [ 0 , 'UGX' , 'UGX' ] ,
412- 'UYU' : [ 1 , '$' , '$U' ] ,
413425 'UZS' : [ 0 , 'so\u02bcm' , 'UZS' ] ,
414426 'VEF' : [ 2 , 'Bs' , 'Bs' ] ,
415427 'VUV' : [ 0 , 'VUV' , 'VUV' ] ,
0 commit comments