i18n-complements 0.0.11 → 0.0.12

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: d3b22b0de1c457756d284aa0a6eb849d5bc0a954
4
- data.tar.gz: e6a52e8aace1e3e30264b41e2bc5a84419b2492c
3
+ metadata.gz: e315e195eaf2ffc7641dafa65b29f64daf5270cf
4
+ data.tar.gz: ade2b242b65632eb4164c42ae859af019604f4d1
5
5
  SHA512:
6
- metadata.gz: c4bc7979b0ec81716b0ab6c6566401dadb9682ad87fcc668129fcc158c0ec845ae84581bee40ead4315f631233281810ff3ba5a0fb2491d664b0664b61535f21
7
- data.tar.gz: 1a58f4a68fd03024545266768f7a305d843064cc24f2b91242ab2cf0013db29c7c336014e870e8c8be01ebb1fc60e71aba6c5d604a17679fa9ee5674bc0a72ad
6
+ metadata.gz: 03d540be38622615ed373e3f48aeb9288b58c16b12fbb5bb5aba1e9bd4e1270806b9ac04faeda0e7596b1a7ea61cf54165549970295ed5e19328e7c1ac3fe07a
7
+ data.tar.gz: 9fe8dc68f570ca829850deebdf3fd1f5bac7c5afbbb3c7bc0aaa8650412dbb1bb2b5ce8b95f631cfe41faffbc9a027077bb81c777835bdd89f747910feed8d7d
@@ -318,7 +318,7 @@ FRF:
318
318
  countries: [fr]
319
319
  number: "250"
320
320
  precision: 2
321
- symbol: 'F'
321
+ unit: 'F'
322
322
  GBP:
323
323
  active: true
324
324
  countries: [gb, gg, im, je]
@@ -53,10 +53,10 @@ module I18nComplements
53
53
  formatcy = I18n.translate("number.currency.formats.#{self.code}".to_sym, :locale => options[:locale], :default => {})
54
54
  formatcy[:negative_format] ||= "-" + formatcy[:format] if formatcy[:format]
55
55
 
56
- prec = {}
57
- prec[:separator] = formatcy[:separator] || defaultt[:separator] || defaults[:separator] || ','
58
- prec[:delimiter] = formatcy[:delimiter] || defaultt[:delimiter] || defaults[:delimiter] || ''
59
- prec[:precision] = formatcy[:precision] || self.precision || defaultt[:precision] || 3
56
+ formatter = {}
57
+ formatter[:separator] = formatcy[:separator] || defaultt[:separator] || defaults[:separator] || ','
58
+ formatter[:delimiter] = formatcy[:delimiter] || defaultt[:delimiter] || defaults[:delimiter] || ''
59
+ formatter[:precision] = formatcy[:precision] || self.precision || defaultt[:precision] || 3
60
60
  format = formatcy[:format] || defaultt[:format] || "%n-%u" # defaults[:format] ||
61
61
  negative_format = formatcy[:negative_format] || defaultt[:negative_format] || defaults[:negative_format] || "-" + format
62
62
  unit = formatcy[:unit] || self.unit || self.code
@@ -68,10 +68,10 @@ module I18nComplements
68
68
 
69
69
  value = amount.to_s
70
70
  integers, decimals = value.split(/\./)
71
- value = integers.gsub(/^0+[1-9]+/, '').gsub(/(\d)(?=(\d\d\d)+(?!\d))/, "\\1#{prec[:delimiter]}")
71
+ value = integers.gsub(/^0+[1-9]+/, '').gsub(/(\d)(?=(\d\d\d)+(?!\d))/, "\\1#{formatter[:delimiter]}")
72
72
  unless decimals.to_s.match(/^\s*$/)
73
- decimals = decimals.gsub(/0+$/, '').ljust(prec[:precision], '0').reverse.split(/(?=\d{3})/).reverse.collect{|x| x.reverse}.join(prec[:delimiter])
74
- value += prec[:separator] + decimals
73
+ value << formatter[:separator]
74
+ value << decimals.gsub(/0+$/, '').ljust(formatter[:precision], '0').scan(/.{1,3}/).join(formatter[:delimiter])
75
75
  end
76
76
  return format.gsub(/%n/, value).gsub(/%u/, unit).gsub(/%s/, "\u{00A0}")
77
77
  end
@@ -1,3 +1,3 @@
1
1
  module I18nComplements
2
- VERSION = "0.0.11"
2
+ VERSION = "0.0.12"
3
3
  end
@@ -45,9 +45,12 @@ class TestCurrencies < Test::Unit::TestCase
45
45
 
46
46
  def test_number_formatting_with_currency
47
47
  number = 413500
48
- assert_equal "¥413,500", ::I18n.localize(number, :locale => :eng, :currency=>"JPY")
49
- assert_equal "413\u{00A0}500\u{00A0}¥", ::I18n.localize(number, :locale => :fra, :currency=>"JPY")
50
- assert_equal "413,500円", ::I18n.localize(number, :locale => :jpn, :currency=>"JPY")
48
+ assert_equal "¥413,500", ::I18n.localize(number, :locale => :eng, :currency => "JPY")
49
+ assert_equal "413\u{00A0}500\u{00A0}¥", ::I18n.localize(number, :locale => :fra, :currency => "JPY")
50
+ assert_equal "413,500円", ::I18n.localize(number, :locale => :jpn, :currency => "JPY")
51
+ assert_equal "€0.325,1", ::I18n.localize(0.3251, :locale => :eng, :currency => "EUR")
52
+ assert_equal "0,325\u{00A0}1\u{00A0}F", ::I18n.localize(0.3251, :locale => :fra, :currency => "FRF")
53
+ assert_equal "€123,852.325,1", ::I18n.localize(123852.3251, :locale => :eng, :currency => "EUR")
51
54
  end
52
55
 
53
56
  def test_number_formatting_with_currency_with_core_extensions
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: i18n-complements
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.11
4
+ version: 0.0.12
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brice Texier