i18n-js 3.0.0.rc4 → 3.0.0.rc5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 065703ea709f170b5326ad0bbbe60039cfcdaa30
4
- data.tar.gz: 06edb6364fd9131dac979dd9052e5c94e2602d08
3
+ metadata.gz: a8e90f40cb73ad416912220f5a1636794964356d
4
+ data.tar.gz: e912fa9f82f3c76d26fffeedfc4850fe7553c838
5
5
  SHA512:
6
- metadata.gz: 882399d880781f54c2a41febc8cd069a8e5f360219be69310a70071e511fc317c9331784ebf1ec94a76ec0555a835061877dc68185e2b322132a4ebef0a7fa94
7
- data.tar.gz: db1adab1b748f5f06e0b2c58feee72a60348e56d99eb22421c6e46d02de5e041add56cd858ca1d616dbf06b504b8a62c83aadc3dd4f2858271a286694cb06211
6
+ metadata.gz: dbea11c2d0729c00da1c121d146c0f5325e133ab6c07989fae0e922650e8f7f5503bc5f4107d46a4d3d4012f0c03d88d39ce4a87d12e05295c59d29974b6b4a8
7
+ data.tar.gz: a56605c1ab472757cfd446a9c0e895a47c2c9ce6ffa00a01796efb6a8f3acae793370be272c253b906778b352d199876025e67f8cf2473021acdbd0f9f26125d
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- i18n-js (3.0.0.rc4)
4
+ i18n-js (3.0.0.rc5)
5
5
  i18n
6
6
 
7
7
  GEM
@@ -14,6 +14,52 @@
14
14
  ;(function(I18n){
15
15
  "use strict";
16
16
 
17
+ // Just cache the Array#slice function.
18
+ var slice = Array.prototype.slice;
19
+
20
+ // Apply number padding.
21
+ var padding = function(number) {
22
+ return ("0" + number.toString()).substr(-2);
23
+ };
24
+
25
+ // Set default days/months translations.
26
+ var DAYS_AND_MONTHS = {
27
+ day_names: ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]
28
+ , abbr_day_names: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"]
29
+ , month_names: [null, "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]
30
+ , abbr_month_names: [null, "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"]
31
+ };
32
+
33
+ // Set default number format.
34
+ var NUMBER_FORMAT = {
35
+ precision: 3
36
+ , separator: "."
37
+ , delimiter: ","
38
+ , strip_insignificant_zeros: false
39
+ };
40
+
41
+ // Set default currency format.
42
+ var CURRENCY_FORMAT = {
43
+ unit: "$"
44
+ , precision: 2
45
+ , format: "%u%n"
46
+ , delimiter: ","
47
+ , separator: "."
48
+ };
49
+
50
+ // Set default percentage format.
51
+ var PERCENTAGE_FORMAT = {
52
+ precision: 3
53
+ , separator: "."
54
+ , delimiter: ""
55
+ };
56
+
57
+ // Set default size units.
58
+ var SIZE_UNITS = [null, "kb", "mb", "gb", "tb"];
59
+
60
+ // Set meridian.
61
+ var MERIDIAN = ["AM", "PM"];
62
+
17
63
  I18n.reset = function() {
18
64
  // Set default locale. This locale will be used when fallback is enabled and
19
65
  // the translation doesn't exist in a particular locale.
@@ -197,19 +243,20 @@
197
243
  // #=> {name: "John Doe", role: "user"}
198
244
  //
199
245
  I18n.prepareOptions = function() {
200
- var args = Array.prototype.slice.call(arguments)
246
+ var args = slice.call(arguments)
201
247
  , options = {}
248
+ , subject
202
249
  ;
203
250
 
204
- for (var i = 0, count = args.length; i < count; i++) {
205
- var o = args.shift();
251
+ while (args.length) {
252
+ subject = args.shift();
206
253
 
207
- if (typeof(o) != "object") {
254
+ if (typeof(subject) != "object") {
208
255
  continue;
209
256
  }
210
257
 
211
- for (var attr in o) {
212
- if (!o.hasOwnProperty(attr)) {
258
+ for (var attr in subject) {
259
+ if (!subject.hasOwnProperty(attr)) {
213
260
  continue;
214
261
  }
215
262
 
@@ -217,7 +264,7 @@
217
264
  continue;
218
265
  }
219
266
 
220
- options[attr] = o[attr];
267
+ options[attr] = subject[attr];
221
268
  }
222
269
  }
223
270
 
@@ -307,12 +354,10 @@
307
354
 
308
355
  // Return a missing translation message for the given parameters.
309
356
  I18n.missingTranslation = function(scope) {
310
- var message = '[missing "' + this.currentLocale();
311
-
312
- for (var i = 0; i < arguments.length; i++) {
313
- message += "." + arguments[i];
314
- }
357
+ var message = '[missing "';
315
358
 
359
+ message += this.currentLocale() + ".";
360
+ message += slice.call(arguments).join(".");
316
361
  message += '" translation]';
317
362
 
318
363
  return message;
@@ -333,7 +378,7 @@
333
378
  options = this.prepareOptions(
334
379
  options
335
380
  , this.lookup("number.format")
336
- , {precision: 3, separator: ".", delimiter: ",", strip_insignificant_zeros: false}
381
+ , NUMBER_FORMAT
337
382
  );
338
383
 
339
384
  var negative = number < 0
@@ -389,7 +434,7 @@
389
434
  options
390
435
  , this.lookup("number.currency.format")
391
436
  , this.lookup("number.format")
392
- , {unit: "$", precision: 2, format: "%u%n", delimiter: ",", separator: "."}
437
+ , CURRENCY_FORMAT
393
438
  );
394
439
 
395
440
  number = this.toNumber(number, options);
@@ -511,16 +556,11 @@
511
556
  var options = this.lookup("date");
512
557
 
513
558
  if (!options) {
514
- options = {
515
- day_names: ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]
516
- , abbr_day_names: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"]
517
- , month_names: [null, "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]
518
- , abbr_month_names: [null, "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"]
519
- }
559
+ options = DAYS_AND_MONTHS;
520
560
  }
521
561
 
522
562
  if (!options.meridian) {
523
- options.meridian = ["AM", "PM"];
563
+ options.meridian = MERIDIAN;
524
564
  }
525
565
 
526
566
  var weekDay = date.getDay()
@@ -544,10 +584,6 @@
544
584
  hour12 = 12;
545
585
  }
546
586
 
547
- var padding = function(number) {
548
- return ("0" + number.toString()).substr(-2);
549
- };
550
-
551
587
  format = format.replace("%a", options.abbr_day_names[weekDay]);
552
588
  format = format.replace("%A", options.day_names[weekDay]);
553
589
  format = format.replace("%b", options.abbr_month_names[month]);
@@ -598,7 +634,7 @@
598
634
  options
599
635
  , this.lookup("number.percentage.format")
600
636
  , this.lookup("number.format")
601
- , {precision: 3, separator: ".", delimiter: ""}
637
+ , PERCENTAGE_FORMAT
602
638
  );
603
639
 
604
640
  number = this.toNumber(number, options);
@@ -623,7 +659,7 @@
623
659
  unit = this.t("number.human.storage_units.units.byte", {count: size});
624
660
  precision = 0;
625
661
  } else {
626
- unit = this.t("number.human.storage_units.units." + [null, "kb", "mb", "gb", "tb"][iterations]);
662
+ unit = this.t("number.human.storage_units.units." + SIZE_UNITS[iterations]);
627
663
  precision = (size - Math.floor(size) === 0) ? 0 : 1;
628
664
  }
629
665
 
@@ -645,4 +681,4 @@
645
681
  I18n.t = I18n.translate;
646
682
  I18n.l = I18n.localize;
647
683
  I18n.p = I18n.pluralize;
648
- })(typeof(exports) === "undefined" ? {} : exports);
684
+ })(typeof(exports) === "undefined" ? (this.I18n = {}) : exports);
@@ -4,7 +4,7 @@ module I18n
4
4
  MAJOR = 3
5
5
  MINOR = 0
6
6
  PATCH = 0
7
- STRING = "#{MAJOR}.#{MINOR}.#{PATCH}.rc4"
7
+ STRING = "#{MAJOR}.#{MINOR}.#{PATCH}.rc5"
8
8
  end
9
9
  end
10
10
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: i18n-js
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.0.rc4
4
+ version: 3.0.0.rc5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nando Vieira
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-03-07 00:00:00.000000000 Z
11
+ date: 2013-03-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: i18n