r18n-rails-api 0.4.5 → 0.4.6

Sign up to get free protection for your applications and to get access to all the features.
data/README.rdoc CHANGED
@@ -9,13 +9,13 @@ Rails I18n compatibility for R18n:
9
9
 
10
10
  === Variables
11
11
 
12
- After require <tt>r18n-rails-api</tt> you can use named variables in any
12
+ After require-ing <tt>r18n-rails-api</tt> you can use named variables in all
13
13
  translations:
14
14
 
15
- greeting: "Hi, {{name}}"
15
+ greeting: "Hi, %{name}"
16
16
  users: !!pl
17
17
  1: One user
18
- n: {{count}} users
18
+ n: %{count} users
19
19
 
20
20
  require 'r18n-rails-api'
21
21
 
@@ -31,7 +31,7 @@ i18n/en.yml:
31
31
  en:
32
32
  posts:
33
33
  one: One post
34
- many: {{count}} posts
34
+ many: %{count} posts
35
35
 
36
36
  example.rb:
37
37
  require 'r18n-rails-api'
@@ -43,7 +43,7 @@ example.rb:
43
43
 
44
44
  === Backend
45
45
 
46
- You can use R18n as backend for Rails I18n:
46
+ You can use R18n as a backend for Rails I18n:
47
47
 
48
48
  require 'r18n-rails-api'
49
49
 
@@ -62,7 +62,7 @@ You can use R18n as backend for Rails I18n:
62
62
  * Custom translations loaders.
63
63
  * Translation support for any classes.
64
64
  * Time and number localization.
65
- * Several user language support.
65
+ * Several user languages support.
66
66
 
67
67
  == License
68
68
 
@@ -19,20 +19,22 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
19
19
 
20
20
  # Filter to use Rails named variables:
21
21
  #
22
- # name: "My name is {{name}}"
22
+ # name: "My name is %{name}"
23
23
  #
24
24
  # i18n.name(name: 'Ivan') #=> "My name is Ivan"
25
25
  R18n::Filters.add(String, :named_variables) do |content, config, params|
26
26
  if params.is_a? Hash
27
27
  content = content.clone
28
28
  params.each_pair do |name, value|
29
- content.gsub! "{{#{name}}}", config[:locale].localize(value)
29
+ v = config[:locale].localize(value)
30
+ content.gsub! "%{#{name}}", v
31
+ content.gsub! "{{#{name}}}", v
30
32
  end
31
33
  end
32
34
  content
33
35
  end
34
36
 
35
- # Pluralization by named variable <tt>{{count}}</tt>.
37
+ # Pluralization by named variable <tt>%{count}</tt>.
36
38
  R18n::Filters.add('pl', :named_pluralization) do |content, config, param|
37
39
  if param.is_a? Hash and param.has_key? :count
38
40
  type = config[:locale].pluralize(param[:count])
@@ -18,4 +18,4 @@ en:
18
18
 
19
19
  users:
20
20
  one: 1 user
21
- many: "{{count}} users"
21
+ many: "%{count} users"
data/spec/filters_spec.rb CHANGED
@@ -7,17 +7,22 @@ describe 'Rails filters' do
7
7
  end
8
8
 
9
9
  it "should use named variables" do
10
- i18n = R18n::Translation.new(@en, '', @en, {'echo' => 'Value is {{value}}'})
10
+ i18n = R18n::Translation.new(@en, '', @en, {'echo' => 'Value is %{value}'})
11
11
 
12
12
  i18n.echo(:value => 'R18n').should == 'Value is R18n'
13
13
  i18n.echo(:value => -5.5).should == 'Value is −5.5'
14
14
  i18n.echo(:value => 5000).should == 'Value is 5,000'
15
- i18n.echo.should == 'Value is {{value}}'
15
+ i18n.echo.should == 'Value is %{value}'
16
16
  end
17
17
 
18
- it "should pluralize by variable {{count}}" do
18
+ it "should use old variables syntax" do
19
+ i18n = R18n::Translation.new(@en, '', @en, {'echo' => 'Value is {{value}}',})
20
+ i18n.echo(:value => 'Old').should == 'Value is Old'
21
+ end
22
+
23
+ it "should pluralize by variable %{count}" do
19
24
  i18n = R18n::Translation.new(@en, '', @en, {'users' => R18n::Typed.new('pl',
20
- { 0 => 'no users', 1 => '1 user', 'n' => '{{count}} users' }
25
+ { 0 => 'no users', 1 => '1 user', 'n' => '%{count} users' }
21
26
  ) })
22
27
 
23
28
  i18n.users(:count => 0).should == 'no users'
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 4
8
- - 5
9
- version: 0.4.5
8
+ - 6
9
+ version: 0.4.6
10
10
  platform: ruby
11
11
  authors:
12
12
  - Andrey "A.I." Sitnik
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-04-19 00:00:00 +04:00
17
+ date: 2010-06-22 00:00:00 +04:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
@@ -27,8 +27,8 @@ dependencies:
27
27
  segments:
28
28
  - 0
29
29
  - 4
30
- - 5
31
- version: 0.4.5
30
+ - 6
31
+ version: 0.4.6
32
32
  type: :runtime
33
33
  version_requirements: *id001
34
34
  - !ruby/object:Gem::Dependency
@@ -54,9 +54,9 @@ extra_rdoc_files:
54
54
  - LICENSE
55
55
  files:
56
56
  - lib/r18n-rails-api.rb
57
- - lib/r18n-rails-api/filters.rb
58
57
  - lib/r18n-rails-api/loader.rb
59
58
  - lib/r18n-rails-api/backend.rb
59
+ - lib/r18n-rails-api/filters.rb
60
60
  - LICENSE
61
61
  - README.rdoc
62
62
  has_rdoc: true
@@ -90,13 +90,13 @@ signing_key:
90
90
  specification_version: 3
91
91
  summary: Rails I18n compatibility for R18n
92
92
  test_files:
93
- - spec/spec_helper.rb
94
- - spec/backend_spec.rb
95
- - spec/filters_spec.rb
96
- - spec/loader_spec.rb
97
- - spec/data/other/ru.yml
98
- - spec/data/other/en.yml
99
93
  - spec/data/general/en.yml
100
94
  - spec/data/simple/russian.yml
101
- - spec/data/simple/ru.rb
102
95
  - spec/data/simple/en.yml
96
+ - spec/data/simple/ru.rb
97
+ - spec/data/other/en.yml
98
+ - spec/data/other/ru.yml
99
+ - spec/spec_helper.rb
100
+ - spec/backend_spec.rb
101
+ - spec/loader_spec.rb
102
+ - spec/filters_spec.rb