i18n-js 0.1.3 → 0.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -3,7 +3,7 @@ module SimplesIdeias
3
3
  module Version
4
4
  MAJOR = 0
5
5
  MINOR = 1
6
- PATCH = 3
6
+ PATCH = 4
7
7
  STRING = "#{MAJOR}.#{MINOR}.#{PATCH}"
8
8
  end
9
9
  end
data/source/i18n.js CHANGED
@@ -138,8 +138,9 @@ I18n.localize = function(scope, value) {
138
138
 
139
139
  I18n.parseDate = function(d) {
140
140
  var matches, date;
141
-
142
- if (matches = d.toString().match(/(\d{4})-(\d{2})-(\d{2})(?:[ |T](\d{2}):(\d{2}):(\d{2}))?(Z)?/)) {
141
+ matches = d.toString().match(/(\d{4})-(\d{2})-(\d{2})(?:[ |T](\d{2}):(\d{2}):(\d{2}))?(Z)?/);
142
+
143
+ if (matches) {
143
144
  // date/time strings: yyyy-mm-dd hh:mm:ss or yyyy-mm-dd or yyyy-mm-ddThh:mm:ssZ
144
145
  for (var i = 1; i <= 6; i++) {
145
146
  matches[i] = parseInt(matches[i], 10) || 0;
@@ -209,7 +210,7 @@ I18n.strftime = function(date, format) {
209
210
  var padding = function(n) {
210
211
  var s = "0" + n.toString();
211
212
  return s.substr(s.length - 2);
212
- }
213
+ };
213
214
 
214
215
  var f = format;
215
216
  f = f.replace("%a", options["abbr_day_names"][weekDay]);
@@ -244,8 +245,9 @@ I18n.toNumber = function(number, options) {
244
245
  this.lookup("number.format"),
245
246
  {precision: 3, separator: ".", delimiter: ","}
246
247
  );
247
-
248
- var string = number.toFixed(options["precision"]).toString();
248
+
249
+ var negative = number < 0;
250
+ var string = Math.abs(number).toFixed(options["precision"]).toString();
249
251
  var parts = string.split(".");
250
252
 
251
253
  number = parts[0];
@@ -263,6 +265,10 @@ I18n.toNumber = function(number, options) {
263
265
  if (options["precision"] > 0) {
264
266
  formattedNumber += options["separator"] + parts[1];
265
267
  }
268
+
269
+ if (negative) {
270
+ formattedNumber = "-" + formattedNumber;
271
+ }
266
272
 
267
273
  return formattedNumber;
268
274
  };
data/test/i18n-test.js CHANGED
@@ -208,6 +208,17 @@ new Test.Unit.Runner({
208
208
  assertEqual("1,234,567.000", I18n.toNumber(1234567));
209
209
  assertEqual("12,345,678.000", I18n.toNumber(12345678));
210
210
  }},
211
+
212
+ // Negative numbers with default settings
213
+ testNegativeNumbersWithDefaultSettings: function() { with(this) {
214
+ assertEqual("-1.000", I18n.toNumber(-1));
215
+ assertEqual("-12.000", I18n.toNumber(-12));
216
+ assertEqual("-123.000", I18n.toNumber(-123));
217
+ assertEqual("-1,234.000", I18n.toNumber(-1234));
218
+ assertEqual("-123,456.000", I18n.toNumber(-123456));
219
+ assertEqual("-1,234,567.000", I18n.toNumber(-1234567));
220
+ assertEqual("-12,345,678.000", I18n.toNumber(-12345678));
221
+ }},
211
222
 
212
223
  // Numbers with partial translation and default options
213
224
  testNumbersWithPartialTranslationAndDefaultOptions: function() { with(this) {
metadata CHANGED
@@ -1,7 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: i18n-js
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ hash: 19
5
+ prerelease: false
6
+ segments:
7
+ - 0
8
+ - 1
9
+ - 4
10
+ version: 0.1.4
5
11
  platform: ruby
6
12
  authors:
7
13
  - Nando Vieira
@@ -9,7 +15,7 @@ autorequire:
9
15
  bindir: bin
10
16
  cert_chain: []
11
17
 
12
- date: 2010-07-28 00:00:00 -03:00
18
+ date: 2010-09-03 00:00:00 -03:00
13
19
  default_executable:
14
20
  dependencies: []
15
21
 
@@ -54,21 +60,27 @@ rdoc_options:
54
60
  require_paths:
55
61
  - lib
56
62
  required_ruby_version: !ruby/object:Gem::Requirement
63
+ none: false
57
64
  requirements:
58
65
  - - ">="
59
66
  - !ruby/object:Gem::Version
67
+ hash: 3
68
+ segments:
69
+ - 0
60
70
  version: "0"
61
- version:
62
71
  required_rubygems_version: !ruby/object:Gem::Requirement
72
+ none: false
63
73
  requirements:
64
74
  - - ">="
65
75
  - !ruby/object:Gem::Version
76
+ hash: 3
77
+ segments:
78
+ - 0
66
79
  version: "0"
67
- version:
68
80
  requirements: []
69
81
 
70
82
  rubyforge_project:
71
- rubygems_version: 1.3.5
83
+ rubygems_version: 1.3.7
72
84
  signing_key:
73
85
  specification_version: 3
74
86
  summary: It's a small library to provide the Rails I18n translations on the Javascript.