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 +4 -4
- data/Gemfile.lock +1 -1
- data/app/assets/javascripts/i18n.js +64 -28
- data/lib/i18n/js/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a8e90f40cb73ad416912220f5a1636794964356d
|
4
|
+
data.tar.gz: e912fa9f82f3c76d26fffeedfc4850fe7553c838
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dbea11c2d0729c00da1c121d146c0f5325e133ab6c07989fae0e922650e8f7f5503bc5f4107d46a4d3d4012f0c03d88d39ce4a87d12e05295c59d29974b6b4a8
|
7
|
+
data.tar.gz: a56605c1ab472757cfd446a9c0e895a47c2c9ce6ffa00a01796efb6a8f3acae793370be272c253b906778b352d199876025e67f8cf2473021acdbd0f9f26125d
|
data/Gemfile.lock
CHANGED
@@ -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 =
|
246
|
+
var args = slice.call(arguments)
|
201
247
|
, options = {}
|
248
|
+
, subject
|
202
249
|
;
|
203
250
|
|
204
|
-
|
205
|
-
|
251
|
+
while (args.length) {
|
252
|
+
subject = args.shift();
|
206
253
|
|
207
|
-
if (typeof(
|
254
|
+
if (typeof(subject) != "object") {
|
208
255
|
continue;
|
209
256
|
}
|
210
257
|
|
211
|
-
for (var attr in
|
212
|
-
if (!
|
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] =
|
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 "'
|
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
|
-
,
|
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
|
-
,
|
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 =
|
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
|
-
,
|
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." + [
|
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);
|
data/lib/i18n/js/version.rb
CHANGED
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.
|
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-
|
11
|
+
date: 2013-03-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: i18n
|