i81n 0.3.0 → 0.3.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (5) hide show
  1. data/README.md +3 -1
  2. data/i81n.gemspec +1 -1
  3. data/lib/i81n.rb +6 -2
  4. data/test/test_i81n.rb +8 -0
  5. metadata +14 -11
data/README.md CHANGED
@@ -19,7 +19,9 @@ Rails をお使いの際は Gemfile に以下を追記して bundle install を
19
19
 
20
20
  I18n.backend を以下のように設定してください(Rails では config/initializers/i81n.rb 等に書いておくとよいでしょう)。
21
21
 
22
- I18n.backend = I18n::Backend::I81n.new(:ignore => /^(helpers\.label|activerecord\.attributes)/)
22
+ I18n.backend = I18n::Backend::I81n.new(
23
+ :ignore => /^(helpers\.|activerecord\.|attributes\.|errors\.)/
24
+ )
23
25
 
24
26
  使い方
25
27
  ----
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = "i81n"
5
- s.version = "0.3.0"
5
+ s.version = "0.3.1"
6
6
  s.authors = ["jugyo"]
7
7
  s.email = ["jugyo.org@gmail.com"]
8
8
  s.homepage = "https://github.com/jugyo/i81n"
@@ -8,10 +8,14 @@ class I18n::Backend::I81n < I18n::Backend::Simple
8
8
  end
9
9
 
10
10
  def lookup(locale, key, scope = [], options = {})
11
- if ignore && ignore =~ key.to_s
11
+ return super if options.delete(:i81n) == false
12
+ return super if options[:default]
13
+
14
+ key_str = key.to_s
15
+ if ignore && ignore =~ key_str
12
16
  super
13
17
  else
14
- super || key.to_s
18
+ super || key_str
15
19
  end
16
20
  end
17
21
  end
@@ -30,5 +30,13 @@ class TestI81n < Test::Unit::TestCase
30
30
  should "ignore by the regexp" do
31
31
  assert_equal('translation missing: en.aaa.bbb', I18n.t('aaa.bbb'))
32
32
  end
33
+
34
+ should "ignore by specify the option" do
35
+ assert_equal('translation missing: en.ccc.ddd', I18n.t('ccc.ddd', :i81n => false))
36
+ end
37
+
38
+ should ":default option works" do
39
+ assert_equal('foo', I18n.t('ccc.ddd', :default => 'foo'))
40
+ end
33
41
  end
34
42
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: i81n
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.3.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-11-19 00:00:00.000000000 Z
12
+ date: 2011-12-06 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: i18n
16
- requirement: &14846660 !ruby/object:Gem::Requirement
16
+ requirement: &70136703065540 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *14846660
24
+ version_requirements: *70136703065540
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: shoulda
27
- requirement: &14777940 !ruby/object:Gem::Requirement
27
+ requirement: &70136703076660 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '0'
33
33
  type: :development
34
34
  prerelease: false
35
- version_requirements: *14777940
35
+ version_requirements: *70136703076660
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: bundler
38
- requirement: &14776600 !ruby/object:Gem::Requirement
38
+ requirement: &70136703071980 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: '0'
44
44
  type: :development
45
45
  prerelease: false
46
- version_requirements: *14776600
46
+ version_requirements: *70136703071980
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: jeweler
49
- requirement: &14775600 !ruby/object:Gem::Requirement
49
+ requirement: &70136703071060 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ! '>='
@@ -54,7 +54,7 @@ dependencies:
54
54
  version: '0'
55
55
  type: :development
56
56
  prerelease: false
57
- version_requirements: *14775600
57
+ version_requirements: *70136703071060
58
58
  description: I81n aims that make I18n easy to use.
59
59
  email:
60
60
  - jugyo.org@gmail.com
@@ -98,4 +98,7 @@ rubygems_version: 1.8.11
98
98
  signing_key:
99
99
  specification_version: 3
100
100
  summary: I81n is 'Internationalizaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaation'.
101
- test_files: []
101
+ test_files:
102
+ - test/fixtures/en.yml
103
+ - test/helper.rb
104
+ - test/test_i81n.rb