twitter_cldr_js 1.0.0 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (129) hide show
  1. data/Gemfile +5 -0
  2. data/History.txt +11 -1
  3. data/README.md +103 -13
  4. data/Rakefile +1 -1
  5. data/lib/assets/javascripts/twitter_cldr/af.js +1815 -0
  6. data/lib/assets/javascripts/twitter_cldr/ar.js +1815 -0
  7. data/lib/assets/javascripts/twitter_cldr/be.js +1815 -0
  8. data/lib/assets/javascripts/twitter_cldr/bg.js +1815 -0
  9. data/lib/assets/javascripts/twitter_cldr/bn.js +1815 -0
  10. data/lib/assets/javascripts/twitter_cldr/ca.js +1815 -0
  11. data/lib/assets/javascripts/twitter_cldr/cs.js +1815 -0
  12. data/lib/assets/javascripts/twitter_cldr/cy.js +1815 -0
  13. data/lib/assets/javascripts/twitter_cldr/da.js +1815 -0
  14. data/lib/assets/javascripts/twitter_cldr/de.js +1815 -0
  15. data/lib/assets/javascripts/twitter_cldr/el.js +1815 -0
  16. data/lib/assets/javascripts/twitter_cldr/en.js +1815 -0
  17. data/lib/assets/javascripts/twitter_cldr/es.js +1815 -0
  18. data/lib/assets/javascripts/twitter_cldr/eu.js +1815 -0
  19. data/lib/assets/javascripts/twitter_cldr/fa.js +1815 -0
  20. data/lib/assets/javascripts/twitter_cldr/fi.js +1815 -0
  21. data/lib/assets/javascripts/twitter_cldr/fil.js +1815 -0
  22. data/lib/assets/javascripts/twitter_cldr/fr.js +1815 -0
  23. data/lib/assets/javascripts/twitter_cldr/ga.js +1815 -0
  24. data/lib/assets/javascripts/twitter_cldr/gl.js +1815 -0
  25. data/lib/assets/javascripts/twitter_cldr/he.js +1815 -0
  26. data/lib/assets/javascripts/twitter_cldr/hi.js +1815 -0
  27. data/lib/assets/javascripts/twitter_cldr/hu.js +1815 -0
  28. data/lib/assets/javascripts/twitter_cldr/id.js +1815 -0
  29. data/lib/assets/javascripts/twitter_cldr/it.js +1815 -0
  30. data/lib/assets/javascripts/twitter_cldr/ja.js +1815 -0
  31. data/lib/assets/javascripts/twitter_cldr/ko.js +1815 -0
  32. data/lib/assets/javascripts/twitter_cldr/lv.js +1815 -0
  33. data/lib/assets/javascripts/twitter_cldr/msa.js +1815 -0
  34. data/lib/assets/javascripts/twitter_cldr/nl.js +1815 -0
  35. data/lib/assets/javascripts/twitter_cldr/no.js +1815 -0
  36. data/lib/assets/javascripts/twitter_cldr/pl.js +1815 -0
  37. data/lib/assets/javascripts/twitter_cldr/pt.js +1815 -0
  38. data/lib/assets/javascripts/twitter_cldr/ro.js +1815 -0
  39. data/lib/assets/javascripts/twitter_cldr/ru.js +1815 -0
  40. data/lib/assets/javascripts/twitter_cldr/sk.js +1815 -0
  41. data/lib/assets/javascripts/twitter_cldr/sq.js +1815 -0
  42. data/lib/assets/javascripts/twitter_cldr/sr.js +1815 -0
  43. data/lib/assets/javascripts/twitter_cldr/sv.js +1815 -0
  44. data/lib/assets/javascripts/twitter_cldr/ta.js +1815 -0
  45. data/lib/assets/javascripts/twitter_cldr/th.js +1815 -0
  46. data/lib/assets/javascripts/twitter_cldr/tr.js +1815 -0
  47. data/lib/assets/javascripts/twitter_cldr/uk.js +1815 -0
  48. data/lib/assets/javascripts/twitter_cldr/ur.js +1815 -0
  49. data/lib/assets/javascripts/twitter_cldr/zh-cn.js +1815 -0
  50. data/lib/assets/javascripts/twitter_cldr/zh-tw.js +1815 -0
  51. data/lib/twitter_cldr/js/compiler.rb +12 -3
  52. data/lib/twitter_cldr/js/mustache/bundle.coffee +19 -1
  53. data/lib/twitter_cldr/js/mustache/calendars/additional_date_format_selector.coffee +85 -0
  54. data/lib/twitter_cldr/js/mustache/calendars/datetime.coffee +248 -226
  55. data/lib/twitter_cldr/js/mustache/calendars/timespan.coffee +19 -18
  56. data/lib/twitter_cldr/js/mustache/numbers/numbers.coffee +62 -19
  57. data/lib/twitter_cldr/js/mustache/plurals/rules.coffee +1 -1
  58. data/lib/twitter_cldr/js/mustache/shared/bidi.coffee +433 -0
  59. data/lib/twitter_cldr/js/mustache/shared/calendar.coffee +25 -0
  60. data/lib/twitter_cldr/js/mustache/shared/currencies.coffee +5 -11
  61. data/lib/twitter_cldr/js/mustache/shared/lists.coffee +40 -0
  62. data/lib/twitter_cldr/js/mustache/shared/prerender/bidi_classes.json +1 -0
  63. data/lib/twitter_cldr/js/mustache/utilities.coffee +87 -0
  64. data/lib/twitter_cldr/js/renderers.rb +23 -19
  65. data/lib/twitter_cldr/js/renderers/bundle.rb +8 -2
  66. data/lib/twitter_cldr/js/renderers/calendars/additional_date_format_selector_renderer.rb +18 -0
  67. data/lib/twitter_cldr/js/renderers/calendars/datetime_renderer.rb +13 -9
  68. data/lib/twitter_cldr/js/renderers/numbers/numbers_renderer.rb +17 -3
  69. data/lib/twitter_cldr/js/renderers/shared/bidi_renderer.rb +77 -0
  70. data/lib/twitter_cldr/js/renderers/shared/calendar_renderer.rb +20 -0
  71. data/lib/twitter_cldr/js/renderers/shared/currencies_renderer.rb +2 -2
  72. data/lib/twitter_cldr/js/renderers/shared/list_renderer.rb +22 -0
  73. data/lib/twitter_cldr/js/tasks/tasks.rake +9 -5
  74. data/lib/twitter_cldr/js/tasks/tasks.rb +6 -5
  75. data/lib/twitter_cldr/js/version.rb +1 -1
  76. data/spec/js/calendars/additional_date_format_selector.spec.js +126 -0
  77. data/spec/js/calendars/datetime.spec.js +29 -2
  78. data/spec/js/calendars/timespan.spec.js +45 -1
  79. data/spec/js/numbers/abbreviated/abbreviated_number.spec.js +47 -0
  80. data/spec/js/numbers/abbreviated/long_decimal.spec.js +57 -0
  81. data/spec/js/numbers/abbreviated/short_decimal.spec.js +57 -0
  82. data/spec/js/numbers/currency.spec.js +2 -2
  83. data/spec/js/numbers/decimal.spec.js +1 -1
  84. data/spec/js/numbers/helpers/fraction.spec.js +1 -1
  85. data/spec/js/numbers/helpers/integer.spec.js +1 -1
  86. data/spec/js/numbers/number.spec.js +1 -1
  87. data/spec/js/numbers/percent.spec.js +1 -1
  88. data/spec/js/plurals/plural_rules.spec.js +1 -1
  89. data/spec/js/shared/bidi.spec.js +105 -0
  90. data/spec/js/shared/calendar.spec.js +51 -0
  91. data/spec/js/shared/classpath_bidi_test.txt +217202 -0
  92. data/spec/js/shared/lists.spec.js +100 -0
  93. data/spec/js/utilities.spec.js +120 -0
  94. data/twitter_cldr_js.gemspec +1 -1
  95. metadata +68 -37
  96. data/lib/assets/javascripts/twitter_cldr/twitter_cldr_af.js +0 -887
  97. data/lib/assets/javascripts/twitter_cldr/twitter_cldr_ar.js +0 -887
  98. data/lib/assets/javascripts/twitter_cldr/twitter_cldr_ca.js +0 -887
  99. data/lib/assets/javascripts/twitter_cldr/twitter_cldr_cs.js +0 -887
  100. data/lib/assets/javascripts/twitter_cldr/twitter_cldr_da.js +0 -887
  101. data/lib/assets/javascripts/twitter_cldr/twitter_cldr_de.js +0 -887
  102. data/lib/assets/javascripts/twitter_cldr/twitter_cldr_el.js +0 -887
  103. data/lib/assets/javascripts/twitter_cldr/twitter_cldr_en.js +0 -887
  104. data/lib/assets/javascripts/twitter_cldr/twitter_cldr_es.js +0 -887
  105. data/lib/assets/javascripts/twitter_cldr/twitter_cldr_eu.js +0 -887
  106. data/lib/assets/javascripts/twitter_cldr/twitter_cldr_fa.js +0 -887
  107. data/lib/assets/javascripts/twitter_cldr/twitter_cldr_fi.js +0 -887
  108. data/lib/assets/javascripts/twitter_cldr/twitter_cldr_fil.js +0 -887
  109. data/lib/assets/javascripts/twitter_cldr/twitter_cldr_fr.js +0 -887
  110. data/lib/assets/javascripts/twitter_cldr/twitter_cldr_he.js +0 -887
  111. data/lib/assets/javascripts/twitter_cldr/twitter_cldr_hi.js +0 -887
  112. data/lib/assets/javascripts/twitter_cldr/twitter_cldr_hu.js +0 -887
  113. data/lib/assets/javascripts/twitter_cldr/twitter_cldr_id.js +0 -887
  114. data/lib/assets/javascripts/twitter_cldr/twitter_cldr_it.js +0 -887
  115. data/lib/assets/javascripts/twitter_cldr/twitter_cldr_ja.js +0 -887
  116. data/lib/assets/javascripts/twitter_cldr/twitter_cldr_ko.js +0 -887
  117. data/lib/assets/javascripts/twitter_cldr/twitter_cldr_msa.js +0 -887
  118. data/lib/assets/javascripts/twitter_cldr/twitter_cldr_nl.js +0 -887
  119. data/lib/assets/javascripts/twitter_cldr/twitter_cldr_no.js +0 -887
  120. data/lib/assets/javascripts/twitter_cldr/twitter_cldr_pl.js +0 -887
  121. data/lib/assets/javascripts/twitter_cldr/twitter_cldr_pt.js +0 -887
  122. data/lib/assets/javascripts/twitter_cldr/twitter_cldr_ru.js +0 -887
  123. data/lib/assets/javascripts/twitter_cldr/twitter_cldr_sv.js +0 -887
  124. data/lib/assets/javascripts/twitter_cldr/twitter_cldr_th.js +0 -887
  125. data/lib/assets/javascripts/twitter_cldr/twitter_cldr_tr.js +0 -887
  126. data/lib/assets/javascripts/twitter_cldr/twitter_cldr_uk.js +0 -887
  127. data/lib/assets/javascripts/twitter_cldr/twitter_cldr_ur.js +0 -887
  128. data/lib/assets/javascripts/twitter_cldr/twitter_cldr_zh-cn.js +0 -887
  129. data/lib/assets/javascripts/twitter_cldr/twitter_cldr_zh-tw.js +0 -887
@@ -0,0 +1,25 @@
1
+ # Copyright 2012 Twitter, Inc
2
+ # http://www.apache.org/licenses/LICENSE-2.0
3
+
4
+ class TwitterCldr.Calendar
5
+ @calendar: `{{{calendar}}}`
6
+
7
+ @months: (options = {}) ->
8
+ root = @get_root("months", options)
9
+ result = []
10
+ result[parseInt(key) - 1] = val for key, val of root
11
+ result
12
+
13
+ @weekdays: (options = {}) ->
14
+ @get_root("days", options)
15
+
16
+ @get_root: (key, options = {}) ->
17
+ root = @calendar[key]
18
+ names_form = options["names_form"] || "wide"
19
+
20
+ format = options.format || if root?["stand-alone"]?[names_form]?
21
+ "stand-alone"
22
+ else
23
+ "format"
24
+
25
+ root[format][names_form]
@@ -1,27 +1,21 @@
1
1
  # Copyright 2012 Twitter, Inc
2
2
  # http://www.apache.org/licenses/LICENSE-2.0
3
3
 
4
- TwitterCldr.Currencies = class Currencies
4
+ class TwitterCldr.Currencies
5
5
  @currencies = `{{{currencies}}}`
6
6
 
7
- @countries: ->
8
- @names ||= (country_name for country_name, data of @currencies)
9
-
10
7
  @currency_codes: ->
11
- @codes ||= (data.code for country_name, data of @currencies)
12
-
13
- @for_country: (country_name) ->
14
- @currencies[country_name]
8
+ @codes ||= (data.code for _, data of @currencies)
15
9
 
16
10
  @for_code: (currency_code) ->
17
- final = null
11
+ result = null
18
12
  for country_name, data of @currencies
19
13
  if data.code == currency_code
20
- final =
14
+ result =
21
15
  country: country_name
22
16
  code: data.code
23
17
  symbol: data.symbol
24
18
  currency: data.currency
25
19
  break
26
20
 
27
- final
21
+ result
@@ -0,0 +1,40 @@
1
+ # Copyright 2012 Twitter, Inc
2
+ # http://www.apache.org/licenses/LICENSE-2.0
3
+
4
+ class TwitterCldr.ListFormatter
5
+ constructor: (options = {}) ->
6
+ @formats = `{{{formats}}}`
7
+
8
+ format: (list) ->
9
+ if @formats[list.length.toString()]?
10
+ this.compose(@formats[list.length.toString()], list)
11
+ else
12
+ this.compose_list(list)
13
+
14
+ compose_list: (list) ->
15
+ result = this.compose(@formats.end || @formats.middle || "", [list[list.length - 2], list[list.length - 1]])
16
+
17
+ if list.length > 2
18
+ for i in [3..list.length]
19
+ format_key = if i == list.length then "start" else "middle"
20
+ format_key = "middle" unless @formats[format_key]?
21
+ result = this.compose(@formats[format_key] || "", [list[list.length - i], result])
22
+
23
+ result
24
+
25
+ compose: (format, elements) ->
26
+ elements = (element for element in elements when element isnt null)
27
+
28
+ if elements.length > 1
29
+ result = format.replace(/\{(\d+)\}/g, ->
30
+ RegExp.$1
31
+ )
32
+
33
+ if TwitterCldr.is_rtl
34
+ result = TwitterCldr.Bidi.from_string(result, {"direction": "RTL"}).reorder_visually().toString()
35
+
36
+ result.replace(/(\d+)/g, ->
37
+ elements[parseInt(RegExp.$1)]
38
+ )
39
+ else
40
+ elements[0] || ""
@@ -0,0 +1 @@
1
+ {"BN":{"8":[0],"13":[14],"5":[127,8298],"25":[134],"0":[173,65279,917505],"2":[8203],"4":[8288],"7":[119155],"95":[917536]},"S":{"0":[9,11,31]},"B":{"0":[10,13,133,8233],"2":[28]},"WS":{"0":[12,32,5760,6158,8232,8287,12288],"10":[8192]},"ON":{"1":[33,171,174,697,884,900,1542,1550,5787,6468,8189,8448,8456,8506,12342,12443,12829,13278,42622,64830,65120,65281,126704,127338],"4":[38,187,8512,65286,65529,127942],"5":[59,91,3059,8478,11493,65307,65339,127792],"3":[123,166,2038,3898,8451,8522,12289,13004,13175,43048,43124,128249,128320],"0":[161,180,215,247,894,903,1014,1418,1758,1769,3066,5120,6464,8125,8468,8485,8487,8489,8585,12336,12448,12539,13311,42611,42888,65021,65105,65108,65128,65131,65793,67871,119365,120539,120597,120655,120713,120771,128064],"2":[182,8127,8141,8157,8173,8316,8332,8470,12349,12924,42509,65124,65506],"13":[706,722,127153],"8":[741,65110],"16":[751,127968],"6":[3192,11513,65512,68409],"9":[5008,6128,11088,65040],"10":[6144,9280,65371,128581],"33":[6622,42752],"23":[8208,128336],"14":[8245,12977,127136,127169,127185],"25":[8261,9083,11904],"15":[8528,12880],"129":[8592],"289":[8724],"93":[9110],"38":[9216],"39":[9312],"449":[9450],"82":[9901],"254":[9985],"588":[10496],"59":[11776],"88":[11931],"213":[12032],"11":[12272,65936],"24":[12296],"35":[12736],"63":[19904],"54":[42128],"31":[65072],"74":[65856],"19":[69714,127872],"65":[119296],"86":[119552],"43":[126976],"99":[127024],"32":[127744],"69":[127799,128507,128640],"36":[127904],"62":[128000],"181":[128066],"61":[128256],"115":[128768]},"ET":{"2":[35,65283],"3":[162],"1":[176,1545,2546,43064,65129,65504,65509],"0":[1423,1642,2555,2801,3065,3647,6107,8494,8723,65119],"4":[8240],"25":[8352]},"ES":{"0":[43,45,8722,64297,65291,65293],"1":[8314,8330,65122]},"CS":{"0":[44,58,160,1548,8239,8260,65104,65106,65109,65292,65306],"1":[46,65294]},"EN":{"9":[48,1776,8320,65296],"1":[178],"0":[185,8304],"5":[8308],"19":[9352],"49":[120782],"10":[127232]},"L":{"25":[65,97,5761,6576,65313,65345,65549],"0":[170,181,186,750,902,908,1417,2363,2482,2510,2519,2563,2654,2691,2761,2768,2880,2903,2947,2972,3024,3031,3133,3199,3294,3406,3415,3517,3716,3722,3725,3749,3751,3773,3782,3894,3896,3967,3973,4145,4152,4295,4301,4696,4800,6070,6108,6314,6743,6753,6965,6971,7082,7143,7150,7379,7393,8025,8027,8029,8126,8206,8305,8319,8450,8455,8469,8484,8486,8488,9109,9900,11559,11565,43047,43597,43697,43712,43714,65792,65794,69632,69932,71340,71350,119970,119995,120134],"22":[192,3090,3218,6656,11648],"30":[216,8031,13280,66304,127248],"448":[248],"6":[699,1369,2425,2474,2548,2602,2730,2858,3449,3520,3648,3737,4688,4792,6100,8118,8134,8182,11680,11688,11696,11704,11712,11720,11728,11736,43808,43816,64256,69703,69819,119997,120086,120138],"1":[720,886,2434,2447,2503,2507,2524,2575,2610,2613,2616,2738,2763,2784,2818,2831,2866,2877,2887,2891,2908,2969,2974,2979,3006,3009,3160,3168,3202,3274,3285,3296,3313,3330,3424,3458,3634,3713,3719,3754,3762,4155,4227,5941,6087,6448,6755,7078,7154,7220,7413,8526,11506,11631,12334,43346,43444,43450,43486,43567,43571,43701,44006,65596,69815,71342,110592,119171,119966,119973,127568],"4":[736,2741,2869,3125,3253,3776,3976,6512,6973,8473,8517,12337,12344,43705,64275,120128],"3":[880,890,2365,2377,2486,2493,2649,2749,2962,3137,3389,3732,3757,3804,4186,4682,4698,4746,4786,4802,4882,5902,6435,7401,8144,8490,8508,11499,12540,42896,43015,44009,66336,74864,119977,120071,120123],"2":[904,2382,2527,2622,2674,2703,2911,2958,2984,3014,3018,3073,3086,3214,3270,3342,3398,3402,3535,3570,3745,5998,6441,6681,7146,8130,8178,12293,12445,43011,43584,65498],"19":[910,2404],"82":[931],"139":[1015],"157":[1162,66560],"37":[1329,7968,11520,43264],"38":[1377,119040],"54":[2307],"9":[2392,2662,3114,3174,3242,3302,3792,3902,6112,6160,6784,6800,8458,43000,43250,43600,44016,66720,69734,69872,70079,70096,71360],"7":[2437,2821,3077,3205,3261,3333,3544,4030,6078,7360,8016,43056,43588,43758,120077,120772],"21":[2451,2579,2707,2835],"11":[2534,2990,12992,43214,65536,119982],"5":[2565,2949,4039,4231,6451,6765,7406,7960,8008,8150,42738,42889,43777,43785,43793,65474,65482,65490],"8":[2693,3507,6979,7028,12321,65847,119146,127552],"10":[2790,6608,8495,42912,43471],"17":[2918,3461,5920,5952,119648],"12":[3046,3663,4046,4213,5888,5984,8160,8336,94099],"40":[3346,4704,6272,8544,12549,43520],"15":[3430,4193,4992],"23":[3482,3840,42624],"47":[3585,6916,7164,12832,43395,43648,119214],"26":[3866,6992,66352],"35":[3913,69891],"44":[4096,12784,65799,66000],"24":[4159,43020,43310,69840],"14":[4238,4808,7227,65599],"39":[4254,6470],"376":[4304],"32":[4752],"56":[4824,120540,120598,120656,120714],"66":[4888],"28":[4960,6400,66176,127462],"84":[5024,119808],"638":[5121],"80":[5792],"51":[6016,43072,70018],"87":[6176],"69":[6320],"43":[6528],"55":[6686,11568],"13":[6816,65616,66504,69942],"31":[7042,43612],"57":[7084,127280],"50":[7245,120488],"191":[7424],"277":[7680],"52":[8064],"68":[9014,93952],"77":[9372],"255":[10240],"46":[11264,11312,13008,42560,94032],"132":[11360],"85":[12353],"89":[12449],"93":[12593],"42":[12688,71296,127344,127504],"27":[12896,42512,120094],"49":[12927],"118":[13056],"98":[13179,74752],"6591":[13312],"22156":[19968],"316":[42192],"79":[42656],"101":[42786],"67":[43136],"29":[43359,66432,119180],"16":[43453,43739],"36":[43968,66463],"11206":[44032],"48":[55243,66208,69762],"8813":[55296],"105":[64112],"88":[65382],"18":[65576],"122":[65664],"53":[69634],"878":[73728],"1070":[77824],"568":[92160],"245":[118784],"61":[119081],"70":[119894],"64":[120005],"339":[120146],"42719":[131072],"4383":[173824],"541":[194560],"131071":[983040]},"NSM":{"111":[768],"6":[1155,1750,2385,3636,6071,6744,7394,65056,119173],"44":[1425],"0":[1471,1479,1648,1809,2362,2364,2381,2433,2492,2509,2620,2641,2677,2748,2765,2817,2876,2879,2893,2902,2946,3008,3021,3260,3405,3530,3542,3633,3761,3893,3895,3897,4038,4226,4237,4253,6086,6109,6313,6450,6742,6752,6754,6783,6964,6972,6978,7083,7142,7149,7405,7412,11647,42655,43010,43014,43019,43204,43443,43452,43587,43596,43696,43713,43766,44005,44008,44013,64286,66045,68159,69633,71339,71341,71351],"1":[1473,1476,1767,2402,2530,2561,2625,2631,2672,2689,2759,2786,2914,3157,3170,3276,3298,3426,3771,3864,3974,4153,4157,4184,4229,5970,6002,6068,6439,6679,7040,7080,7144,7222,12441,42736,43045,43569,43573,43703,43710,43756,68101,69760,69817,70016],"10":[1552,1958,3981,6089,43335],"20":[1611],"5":[1759,3764,3784,4146,43561,71344],"3":[1770,2070,2497,2881,3146,3393,4141,4209,6912,7074,7676,12330,42607,43446,68108,69811,94095,119210],"26":[1840,2276],"8":[2027,2075,7019,70070],"2":[2085,2137,2304,2635,3134,3142,3538,4190,4957,5906,5938,6155,6432,6457,7151,7376,11503,43392,43698,68097,68152,69888,119143,119362],"4":[2089,2753,3968,6966,69927],"7":[2369,3655,6757,7212,43302,69933,119163],"13":[3953],"35":[3993],"9":[6771,42612],"12":[7380],"38":[7616],"32":[8400],"31":[11744],"17":[43232],"15":[65024],"14":[69688],"239":[917760]},"R":{"0":[1470,1472,1475,1478,2042,2074,2084,2088,2142,8207,64285,64318,67592,67644,67903,68096],"26":[1488,68121,68440],"4":[1520,64312],"42":[1984],"1":[2036,64320,64323,67639,68030],"21":[2048,68416],"14":[2096],"24":[2112],"9":[64287,64326],"12":[64298],"5":[67584],"43":[67594],"22":[67647],"8":[67671,68176],"27":[67840],"25":[67872],"55":[67968],"3":[68112],"2":[68117],"7":[68160,68472],"31":[68192],"53":[68352],"72":[68608]},"AN":{"4":[1536],"9":[1632],"1":[1643],"0":[1757],"30":[69216]},"AL":{"0":[1544,1547,1549,1563,1969,2208,126500,126503,126521,126523,126530,126535,126537,126539,126548,126551,126553,126555,126557,126559,126564,126590],"44":[1566],"2":[1645,126541,126625],"100":[1649],"1":[1765,1774,1807,126497,126545,126561],"19":[1786],"29":[1810],"88":[1869],"10":[2210],"113":[64336],"362":[64467],"63":[64848],"53":[64914],"12":[65008],"4":[65136,126629],"134":[65142],"3":[126464,126516,126567,126580,126585],"26":[126469],"9":[126505,126592],"6":[126572],"16":[126603,126635]},"LRE":{"0":[8234]},"RLE":{"0":[8235]},"PDF":{"0":[8236]},"LRO":{"0":[8237]},"RLO":{"0":[8238]}}
@@ -0,0 +1,87 @@
1
+ # Copyright 2012 Twitter, Inc
2
+ # http://www.apache.org/licenses/LICENSE-2.0
3
+
4
+ class TwitterCldr.Utilities
5
+ # This function was adapted from the Mozilla JS reference:
6
+ # https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/String/fromCharCode
7
+ @from_char_code: (code_point) ->
8
+ if code_point > 0xFFFF
9
+ code_point -= 0x10000
10
+ String.fromCharCode(0xD800 + (code_point >> 10), 0xDC00 + (code_point & 0x3FF))
11
+ else
12
+ String.fromCharCode(code_point)
13
+
14
+ # This function was adapted from the Mozilla JS reference:
15
+ # https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/String/charCodeAt
16
+ @char_code_at: (str, idx) ->
17
+ str += ''
18
+ end = str.length
19
+ surrogatePairs = /[\uD800-\uDBFF][\uDC00-\uDFFF]/g
20
+
21
+ while surrogatePairs.exec(str) != null
22
+ li = surrogatePairs.lastIndex
23
+ if (li - 2 < idx) then idx += 1 else break
24
+
25
+ if (idx >= end) || (idx < 0)
26
+ return NaN
27
+
28
+ code = str.charCodeAt(idx)
29
+
30
+ if (0xD800 <= code) && (code <= 0xDBFF)
31
+ hi = code
32
+ low = str.charCodeAt(idx + 1) # Go one further, since one of the "characters" is part of a surrogate pair
33
+ return ((hi - 0xD800) * 0x400) + (low - 0xDC00) + 0x10000
34
+
35
+ code
36
+
37
+ @unpack_string: (str) ->
38
+ result = []
39
+
40
+ for idx in [0...str.length]
41
+ code_point = @char_code_at(str, idx)
42
+ break unless code_point
43
+ result.push(code_point)
44
+
45
+ result
46
+
47
+ @pack_array: (char_arr) ->
48
+ (@from_char_code(cur_char) for cur_char in char_arr).join("")
49
+
50
+ @arraycopy: (orig, orig_index, dest, dest_index, length) ->
51
+ for elem, count in orig[orig_index...(orig_index + length)]
52
+ dest[dest_index + count] = elem
53
+
54
+ return
55
+
56
+ @max: (arr) ->
57
+ max = null
58
+
59
+ # make sure the first item chosen is not undefined, which can't be compared using >
60
+ for elem, start_index in arr
61
+ if elem?
62
+ max = elem
63
+ break
64
+
65
+ for i in [start_index..arr.length]
66
+ max = arr[i] if arr[i] > max
67
+
68
+ max
69
+
70
+ @min: (arr) ->
71
+ min = null
72
+
73
+ for elem, start_index in arr
74
+ if elem?
75
+ min = elem
76
+ break
77
+
78
+ for i in [start_index..arr.length]
79
+ min = arr[i] if arr[i] < min
80
+
81
+ min
82
+
83
+ @is_even: (num) ->
84
+ num % 2 == 0
85
+
86
+ @is_odd: (num) ->
87
+ num % 2 == 1
@@ -6,25 +6,29 @@
6
6
  module TwitterCldr
7
7
  module Js
8
8
  module Renderers
9
- autoload :Base, 'twitter_cldr/js/renderers/base'
10
- autoload :Bundle, 'twitter_cldr/js/renderers/bundle'
11
-
12
- module Calendars
13
- autoload :DateTimeRenderer, 'twitter_cldr/js/renderers/calendars/datetime_renderer'
14
- autoload :TimespanRenderer, 'twitter_cldr/js/renderers/calendars/timespan_renderer'
15
- end
16
-
17
- module Numbers
18
- autoload :NumbersRenderer, 'twitter_cldr/js/renderers/numbers/numbers_renderer'
19
- end
20
-
21
- module PluralRules
22
- autoload :PluralRulesCompiler, 'twitter_cldr/js/renderers/plurals/rules/plural_rules_compiler'
23
- autoload :PluralRulesRenderer, 'twitter_cldr/js/renderers/plurals/rules/plural_rules_renderer'
24
- end
25
-
26
- module Shared
27
- autoload :CurrenciesRenderer, 'twitter_cldr/js/renderers/shared/currencies_renderer'
9
+ autoload :Base, 'twitter_cldr/js/renderers/base'
10
+ autoload :Bundle, 'twitter_cldr/js/renderers/bundle'
11
+
12
+ module Calendars
13
+ autoload :DateTimeRenderer, 'twitter_cldr/js/renderers/calendars/datetime_renderer'
14
+ autoload :AdditionalDateFormatSelectorRenderer, 'twitter_cldr/js/renderers/calendars/additional_date_format_selector_renderer'
15
+ autoload :TimespanRenderer, 'twitter_cldr/js/renderers/calendars/timespan_renderer'
16
+ end
17
+
18
+ module Numbers
19
+ autoload :NumbersRenderer, 'twitter_cldr/js/renderers/numbers/numbers_renderer'
20
+ end
21
+
22
+ module PluralRules
23
+ autoload :PluralRulesCompiler, 'twitter_cldr/js/renderers/plurals/rules/plural_rules_compiler'
24
+ autoload :PluralRulesRenderer, 'twitter_cldr/js/renderers/plurals/rules/plural_rules_renderer'
25
+ end
26
+
27
+ module Shared
28
+ autoload :CurrenciesRenderer, 'twitter_cldr/js/renderers/shared/currencies_renderer'
29
+ autoload :ListRenderer, 'twitter_cldr/js/renderers/shared/list_renderer'
30
+ autoload :BidiRenderer, 'twitter_cldr/js/renderers/shared/bidi_renderer'
31
+ autoload :CalendarRenderer, 'twitter_cldr/js/renderers/shared/calendar_renderer'
28
32
  end
29
33
  end
30
34
  end
@@ -7,10 +7,16 @@ module TwitterCldr
7
7
  module Js
8
8
  module Renderers
9
9
  class Bundle < Mustache
10
- self.template_file = File.expand_path(File.join(File.dirname(__FILE__), "..", "mustache/bundle.coffee"))
10
+ self.template_path = File.expand_path(File.join(File.dirname(__FILE__), "..", "mustache"))
11
+ self.template_file = File.join(self.template_path, "bundle.coffee")
12
+ self.template_extension = "coffee"
11
13
 
12
14
  def version
13
- TwitterCldr::VERSION
15
+ TwitterCldr::Js::VERSION
16
+ end
17
+
18
+ def is_rtl?
19
+ TwitterCldr::Shared::Languages.is_rtl?(self[:locale])
14
20
  end
15
21
  end
16
22
  end
@@ -0,0 +1,18 @@
1
+ # encoding: UTF-8
2
+
3
+ # Copyright 2012 Twitter, Inc
4
+ # http://www.apache.org/licenses/LICENSE-2.0
5
+
6
+ module TwitterCldr
7
+ module Js
8
+ module Renderers
9
+ module Calendars
10
+
11
+ class AdditionalDateFormatSelectorRenderer < TwitterCldr::Js::Renderers::Base
12
+ self.template_file = File.expand_path(File.join(File.dirname(__FILE__), "../..", "mustache/calendars/additional_date_format_selector.coffee"))
13
+ end
14
+
15
+ end
16
+ end
17
+ end
18
+ end
@@ -11,21 +11,25 @@ module TwitterCldr
11
11
  self.template_file = File.expand_path(File.join(File.dirname(__FILE__), "../..", "mustache/calendars/datetime.coffee"))
12
12
 
13
13
  def tokens
14
- tokens = {}
15
14
  { :date_time => TwitterCldr::Tokenizers::DateTimeTokenizer,
16
15
  :time => TwitterCldr::Tokenizers::TimeTokenizer,
17
- :date => TwitterCldr::Tokenizers::DateTokenizer }.each_pair do |name, const|
16
+ :date => TwitterCldr::Tokenizers::DateTokenizer }.inject({}) do |tokens, (name, const)|
18
17
  tokenizer = const.new(:locale => @locale)
19
18
  tokens[name] = const::VALID_TYPES.inject({}) do |ret, type|
20
- ret[type] = tokenizer.tokens(:type => type).map(&:to_hash)
19
+ ret[type] = if type == :additional
20
+ pattern_list = TwitterCldr.get_locale_resource(@locale, :calendars)[@locale][:calendars]
21
+ pattern_list = pattern_list[tokenizer.calendar_type][:additional_formats].keys
22
+ pattern_list.inject({}) do |additionals, pattern|
23
+ additionals[pattern] = tokenizer.tokens(:type => type, :format => pattern.to_s).map(&:to_hash)
24
+ additionals
25
+ end
26
+ else
27
+ tokenizer.tokens(:type => type).map(&:to_hash)
28
+ end
21
29
  ret
22
30
  end
23
- end
24
- tokens.to_json
25
- end
26
-
27
- def calendar
28
- TwitterCldr::Tokenizers::DateTimeTokenizer.new(:locale => @locale).calendar.to_json
31
+ tokens
32
+ end.to_json
29
33
  end
30
34
  end
31
35
  end
@@ -3,6 +3,8 @@
3
3
  # Copyright 2012 Twitter, Inc
4
4
  # http://www.apache.org/licenses/LICENSE-2.0
5
5
 
6
+ include TwitterCldr::Tokenizers
7
+
6
8
  module TwitterCldr
7
9
  module Js
8
10
  module Renderers
@@ -11,11 +13,23 @@ module TwitterCldr
11
13
  self.template_file = File.expand_path(File.join(File.dirname(__FILE__), "../..", "mustache/numbers/numbers.coffee"))
12
14
 
13
15
  def tokens
14
- TwitterCldr::Tokenizers::NumberTokenizer::VALID_TYPES.inject({}) do |ret, type|
15
- tokenizer = TwitterCldr::Tokenizers::NumberTokenizer.new(:type => type, :locale => @locale)
16
+ tokenizer = TwitterCldr::Tokenizers::NumberTokenizer.new(:locale => @locale)
17
+ tokenizer.valid_types.inject({}) do |ret, type|
16
18
  ret[type] = {}
17
19
  [:positive, :negative].each do |sign|
18
- ret[type][sign] = tokenizer.tokens(:sign => sign)
20
+ ret[type][sign] = case type
21
+ when :short_decimal, :long_decimal
22
+ (NumberTokenizer::ABBREVIATED_MIN_POWER..NumberTokenizer::ABBREVIATED_MAX_POWER).inject({}) do |formats, i|
23
+ formats[10 ** i] = tokenizer.tokens(
24
+ :sign => sign,
25
+ :type => type,
26
+ :format => 10 ** i
27
+ )
28
+ formats
29
+ end
30
+ else
31
+ tokenizer.tokens(:sign => sign, :type => type)
32
+ end
19
33
  end
20
34
  ret
21
35
  end.to_json
@@ -0,0 +1,77 @@
1
+ # encoding: UTF-8
2
+
3
+ # Copyright 2012 Twitter, Inc
4
+ # http://www.apache.org/licenses/LICENSE-2.0
5
+
6
+ module TwitterCldr
7
+ module Js
8
+ module Renderers
9
+ module Shared
10
+
11
+ class BidiRenderer < TwitterCldr::Js::Renderers::Base
12
+ self.template_file = File.expand_path(File.join(File.dirname(__FILE__), "../..", "mustache/shared/bidi.coffee"))
13
+
14
+ def initialize(options = {})
15
+ super
16
+ @prerender = options[:prerender]
17
+ end
18
+
19
+ def bidi_classes
20
+ @@bidi_classes ||= if @prerender
21
+ File.read(File.expand_path(File.join(File.dirname(__FILE__), "../..", "mustache/shared/prerender/bidi_classes.json")))
22
+ else
23
+ categories = rangify_code_points(code_points_by_category)
24
+
25
+ categories.inject({}) do |ret, (bidi_class, ranges)|
26
+ ret[bidi_class] ||= {}
27
+ ranges.each do |range|
28
+ diff = range.first == range.last ? 0 : range.last - range.first
29
+ ret[bidi_class][diff] ||= []
30
+ ret[bidi_class][diff] << range.first
31
+ end
32
+ ret
33
+ end.to_json
34
+ end
35
+ end
36
+
37
+ protected
38
+
39
+ def code_points_by_category
40
+ (0..0x10FFFF).inject({}) do |ret, i|
41
+ cp = TwitterCldr::Shared::CodePoint.find(i)
42
+ if cp
43
+ ret[cp.bidi_class] ||= []
44
+ ret[cp.bidi_class] << i
45
+ end
46
+ ret
47
+ end
48
+ end
49
+
50
+ def rangify_code_points(categories)
51
+ categories.inject({}) do |ret, (bidi_class, cp_list)|
52
+ ret[bidi_class] = find_ranges(cp_list)
53
+ ret
54
+ end
55
+ end
56
+
57
+ def find_ranges(list)
58
+ ranges = []
59
+ start_idx = 0
60
+ list.each_with_index do |item, idx|
61
+ if idx > 0
62
+ if list[idx - 1] < (item - 1)
63
+ ranges << (list[start_idx]..list[idx - 1])
64
+ start_idx = idx
65
+ end
66
+ end
67
+ end
68
+ ranges << (list[start_idx]..list[list.size - 1]) unless list.empty?
69
+ ranges
70
+ end
71
+
72
+ end
73
+
74
+ end
75
+ end
76
+ end
77
+ end
@@ -0,0 +1,20 @@
1
+ # encoding: UTF-8
2
+
3
+ # Copyright 2012 Twitter, Inc
4
+ # http://www.apache.org/licenses/LICENSE-2.0
5
+
6
+ module TwitterCldr
7
+ module Js
8
+ module Renderers
9
+ module Shared
10
+ class CalendarRenderer < TwitterCldr::Js::Renderers::Base
11
+ self.template_file = File.expand_path(File.join(File.dirname(__FILE__), "../..", "mustache/shared/calendar.coffee"))
12
+
13
+ def calendar
14
+ TwitterCldr::Tokenizers::DateTimeTokenizer.new(:locale => @locale).calendar.to_json
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
20
+ end