genki-merb_babel 0.1.2.1 → 0.1.2.2

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -5,7 +5,7 @@ require 'merb-core'
5
5
  require 'merb-core/tasks/merb'
6
6
 
7
7
  GEM_NAME = "merb_babel"
8
- GEM_VERSION = "0.1.2.1"
8
+ GEM_VERSION = "0.1.2.2"
9
9
  AUTHOR = "Matt Aimonetti"
10
10
  EMAIL = "mattaimonetti@gmail.com"
11
11
  HOMEPAGE = "http://github.com/mattetti/merb_babel/"
data/lib/merb_babel.rb CHANGED
@@ -37,8 +37,8 @@ if defined?(Merb::Plugins)
37
37
  else
38
38
  MI18n.lookup(options.merge(:keys => args))
39
39
  end
40
- rescue
41
- key.to_s
40
+ #rescue
41
+ # key.to_s
42
42
  end
43
43
  end
44
44
  alias :translate :babelize
@@ -7,6 +7,9 @@ module MI18n
7
7
 
8
8
  raise ArgumentError, "You need to pass a language reference" unless language
9
9
  raise ArgumentError, "You need to pass a localization key" if keys.empty?
10
+ unless ML10n.localizations[language]
11
+ language = Merb::Plugins.config[:merb_babel][:default_language]
12
+ end
10
13
  raise ArgumentError,
11
14
  "language: #{language} not found" unless ML10n.localizations[language]
12
15
 
@@ -106,7 +106,10 @@ module ML10n
106
106
  table_for = proc do |table_name, key, default|
107
107
  keys = ["DateFormat", table_name]
108
108
  table = MI18n.lookup(options.merge(:keys => keys)) || {}
109
- table[key] || default
109
+ case table
110
+ when Hash, Array; table[key] || default
111
+ else default
112
+ end
110
113
  end
111
114
  format = format.to_s.dup
112
115
  format.gsub!(/%a/) do
@@ -146,7 +149,5 @@ module ML10n
146
149
  end
147
150
  end
148
151
  end
149
-
150
152
  end
151
-
152
153
  end
data/spec/m_i18n_spec.rb CHANGED
@@ -53,6 +53,7 @@ describe '#babelize' do
53
53
  it "should translate with domain" do
54
54
  @c.t(:night, :greetings, :language => 'en').should == 'Good evening'
55
55
  @c.t(:night, :greetings, :language => 'ja').should == 'こんばんわ'
56
+ @c.t(:night, :greetings, :language => 'tlh').should == 'Good evening'
56
57
  end
57
58
 
58
59
  it "should localize date" do
@@ -72,8 +73,15 @@ describe '#babelize' do
72
73
  time = Time.now
73
74
  if time.hour < 12
74
75
  @c.t("%p", time, :language => "ja").should == "午前"
76
+ @c.t("%p", time, :language => "en").should == "AM"
75
77
  else
76
78
  @c.t("%p", time, :language => "ja").should == "午後"
79
+ @c.t("%p", time, :language => "en").should == "PM"
77
80
  end
78
81
  end
82
+
83
+ it "should localize time by using default yml if correct one is lacking" do
84
+ date = Date.new(2009,1,1)
85
+ @c.t("%B", date, :language => 'tlh').should == "January"
86
+ end
79
87
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: genki-merb_babel
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2.1
4
+ version: 0.1.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matt Aimonetti