gettext_i18n_rails 0.9.3 → 0.9.4
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.
- data/Gemfile.lock +1 -1
- data/Readme.md +1 -2
- data/lib/gettext_i18n_rails/backend.rb +5 -1
- data/lib/gettext_i18n_rails/version.rb +1 -1
- data/spec/gettext_i18n_rails/backend_spec.rb +9 -0
- metadata +4 -4
data/Gemfile.lock
CHANGED
data/Readme.md
CHANGED
@@ -28,8 +28,7 @@ Setup
|
|
28
28
|
|
29
29
|
##### Optional:
|
30
30
|
Add `gettext` if you want to find translations or build .mo files<br/>
|
31
|
-
Add `ruby_parser` if you want to find translations inside haml/slim files
|
32
|
-
|
31
|
+
Add `ruby_parser` if you want to find translations inside haml/slim files
|
33
32
|
|
34
33
|
# Gemfile
|
35
34
|
gem 'gettext', '>=1.9.3', :require => false, :group => :development
|
@@ -17,7 +17,11 @@ module GettextI18nRails
|
|
17
17
|
|
18
18
|
def translate(locale, key, options)
|
19
19
|
if gettext_key = gettext_key(key, options)
|
20
|
-
translation =
|
20
|
+
translation = if options[:count]
|
21
|
+
FastGettext.n_(gettext_key, options[:count])
|
22
|
+
else
|
23
|
+
FastGettext._(gettext_key)
|
24
|
+
end
|
21
25
|
interpolate(translation, options)
|
22
26
|
else
|
23
27
|
result = backend.translate(locale, key, options)
|
@@ -41,6 +41,15 @@ describe GettextI18nRails::Backend do
|
|
41
41
|
subject.translate('xx', 'd', :scope=>['ab']).should == 'a%{a}b'
|
42
42
|
end
|
43
43
|
|
44
|
+
it "uses plural translation if count is given" do
|
45
|
+
repo = {'ab.e' => 'existing'}
|
46
|
+
repo.should_receive(:plural).and_return %w(single plural)
|
47
|
+
repo.stub(:pluralisation_rule).and_return nil
|
48
|
+
FastGettext.stub(:current_repository).and_return repo
|
49
|
+
subject.translate('xx', 'ab.e', :count => 1).should == 'single'
|
50
|
+
subject.translate('xx', 'ab.e', :count => 2).should == 'plural'
|
51
|
+
end
|
52
|
+
|
44
53
|
it "can translate with gettext using symbols" do
|
45
54
|
FastGettext.should_receive(:current_repository).and_return 'xy.z.v'=>'a'
|
46
55
|
subject.translate('xx',:v ,:scope=>['xy','z']).should == 'a'
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gettext_i18n_rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.9.
|
4
|
+
version: 0.9.4
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-
|
12
|
+
date: 2013-04-12 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: fast_gettext
|
@@ -103,7 +103,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
103
103
|
version: '0'
|
104
104
|
segments:
|
105
105
|
- 0
|
106
|
-
hash:
|
106
|
+
hash: 3233874037614167619
|
107
107
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
108
108
|
none: false
|
109
109
|
requirements:
|
@@ -112,7 +112,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
112
112
|
version: '0'
|
113
113
|
segments:
|
114
114
|
- 0
|
115
|
-
hash:
|
115
|
+
hash: 3233874037614167619
|
116
116
|
requirements: []
|
117
117
|
rubyforge_project:
|
118
118
|
rubygems_version: 1.8.25
|