i18nliner 0.0.5 → 0.0.6

Sign up to get free protection for your applications and to get access to all the features.
@@ -25,6 +25,10 @@ module I18nliner
25
25
 
26
26
  def self.setting(key, value)
27
27
  instance_eval <<-CODE
28
+ def #{key}=(value)
29
+ @#{key} = value
30
+ end
31
+
28
32
  def #{key}(value = nil)
29
33
  if value && block_given?
30
34
  begin
@@ -4,8 +4,17 @@ module I18nliner
4
4
  def inferpolate(options)
5
5
  default = options[:default]
6
6
  return options unless default
7
+ if default.is_a?(Hash)
8
+ default.each { |key, value| inferpolate_value!(value, options) }
9
+ else
10
+ inferpolate_value!(default, options)
11
+ end
7
12
 
8
- default.gsub!(/%\{((@)?\w+(.\w+)*)\}/).each do
13
+ options
14
+ end
15
+
16
+ def inferpolate_value!(value, options)
17
+ value.gsub!(/%\{((@)?\w+(.\w+)*)\}/).each do
9
18
  match = $~
10
19
  key = $1
11
20
  ivar = $2
@@ -21,7 +30,6 @@ module I18nliner
21
30
  options[new_key.to_sym] = value
22
31
  "%{#{new_key}}"
23
32
  end
24
- options
25
33
  end
26
34
  end
27
35
  end
data/lib/i18nliner.rb CHANGED
@@ -3,5 +3,6 @@ require 'i18nliner/base'
3
3
 
4
4
  require 'i18nliner/extensions/core'
5
5
  I18n.send :extend, I18nliner::Extensions::Core
6
+ I18n::RESERVED_KEYS << :i18n_scope
6
7
 
7
8
  require 'i18nliner/railtie' if defined?(Rails)
@@ -38,4 +38,12 @@ describe I18nliner::Extensions::Inferpolation do
38
38
  options = {:default => "hello %{@lol} %{@bar.baz.lol}"}
39
39
  foo.inferpolate(options).should == options
40
40
  end
41
+
42
+ it "should work with pluralization hashes" do
43
+ options = {:default => {:one => "%{bar2} has 1 item", :other => "%{bar2} has %{count} items"}}
44
+ foo.inferpolate(options).should == {
45
+ :default => {:one => "%{bar2} has 1 item", :other => "%{bar2} has %{count} items"},
46
+ :bar2 => foo.bar2
47
+ }
48
+ end
41
49
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: i18nliner
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: