localize_multi_digit 3.0 → 4.0

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.
@@ -1,5 +1,5 @@
1
1
  $ld = LocalizedDigits::Base.new()
2
2
 
3
- [String, Fixnum, Float, Date, Time, ActiveSupport::TimeWithZone].each do |item|
3
+ [String, Fixnum, Float, Date, Time, ActiveSupport::TimeWithZone,NilClass].each do |item|
4
4
  item.send(:include, LocalizeMultiDigit)
5
5
  end
@@ -7,12 +7,15 @@ module LocalizeMultiDigit
7
7
  def to_ld
8
8
  item = self
9
9
  digit_map = $ld.get_localized_digits["digits"]
10
+
10
11
  translated_item = ""
11
12
  begin
12
13
  locale = I18n.locale
13
14
  rescue Exception => error
14
15
  locale = :en
15
16
  end
17
+ return self if !digit_map.keys.include?(locale.to_s)
18
+
16
19
  item.to_s.split("").each do |c|
17
20
  if c.to_i > 0 || c == '0'
18
21
  translated_item += digit_map[locale.to_s][c]
@@ -29,7 +32,7 @@ module LocalizedDigits
29
32
  require 'yaml'
30
33
  class Base
31
34
  def initialize
32
- @digits = YAML.load_file("#{Rails.root}/config/locales/localized_digits.yml")
35
+ @digits = YAML.load_file("#{Rails.root}/config/locales/localized_digits.yml") rescue YAML.load_file(File.dirname(__FILE__) + '/generators/localized_digits.yml')
33
36
  end
34
37
  def get_localized_digits
35
38
  @digits
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: localize_multi_digit
3
3
  version: !ruby/object:Gem::Version
4
- version: '3.0'
4
+ version: '4.0'
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: