r18n-rails-api 1.1.6 → 1.1.7

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: bd1fc59c9a4506599bb014be8fb4b2ab9c3626c7
4
+ data.tar.gz: beecc81ed67e7bc8c46e38009fb19292bbcaa129
5
+ SHA512:
6
+ metadata.gz: 56d55bd17db8acf6da867e4bb2d31052aaf13420a68bb201f8bfb57877cd5b4e24ca2dc1ee3a2ee31fc823f89e3699e7ce4a97172a97c09ca2c976df851557b5
7
+ data.tar.gz: 228fab5091587df40014149bbcf4ff8375c2f77577e961657f4c14dd55dfe1c5aa90487e183f5927fed1b082c26e1ad9bfba11466a221bff410243ce45ca22e8
data/Rakefile CHANGED
@@ -1,33 +1,13 @@
1
- # encoding: utf-8
2
-
3
1
  require 'rubygems'
4
2
 
5
- begin
6
- require 'bundler/setup'
7
- Bundler::GemHelper.install_tasks
8
- rescue LoadError
9
- puts "Bundler not available. Install it with: gem install bundler"
10
- end
11
-
12
- PKG_NAME = 'r18n-rails-api'
13
- require '../r18n-core/lib/r18n-core/version'
3
+ require 'bundler/setup'
4
+ Bundler::GemHelper.install_tasks
14
5
 
15
6
  require 'rspec/core/rake_task'
16
-
17
7
  RSpec::Core::RakeTask.new
8
+ task :default => :spec
18
9
 
19
- require 'yard'
20
- YARD::Rake::YardocTask.new do |yard|
21
- yard.options << "--title='R18n Rails API #{R18n::VERSION}'"
22
- end
23
-
24
- task :clobber_doc do
25
- rm_r 'doc' rescue nil
26
- rm_r '.yardoc' rescue nil
27
- end
28
10
  task :clobber_package do
29
11
  rm_r 'pkg' rescue nil
30
12
  end
31
- task :clobber => [:clobber_package, :clobber_doc]
32
-
33
- task :default => :spec
13
+ task :clobber => [:clobber_package]
@@ -18,6 +18,8 @@ You should have received a copy of the GNU Lesser General Public License
18
18
  along with this program. If not, see <http://www.gnu.org/licenses/>.
19
19
  =end
20
20
 
21
+ require 'i18n/backend/transliterator'
22
+
21
23
  module R18n
22
24
  # R18n backend for Rails I18n. You must set R18n I18n object before use this
23
25
  # backend:
@@ -26,6 +28,8 @@ module R18n
26
28
  #
27
29
  # I18n.l Time.now, :format => :full #=> "6th of December, 2009 22:44"
28
30
  class Backend
31
+ include ::I18n::Backend::Transliterator
32
+
29
33
  RESERVED_KEYS = [:scope, :default, :separator]
30
34
 
31
35
  # Find translation in R18n. It didn’t use +locale+ argument, only current
@@ -42,7 +46,10 @@ module R18n
42
46
  if result.is_a? Untranslated
43
47
  options = options.reject { |key, value| key == :default }
44
48
 
45
- Array(default).each do |entry|
49
+ default = [] if default.nil?
50
+ default = [default] unless default.is_a? Array
51
+
52
+ default.each do |entry|
46
53
  if entry.is_a? Symbol
47
54
  value = lookup(locale, scope, entry, separator, params)
48
55
  return value unless value.is_a? Untranslated
@@ -23,6 +23,7 @@ Gem::Specification.new do |s|
23
23
  s.author = 'Andrey "A.I." Sitnik'
24
24
  s.email = 'andrey@sitnik.ru'
25
25
  s.homepage = 'https://github.com/ai/r18n/tree/master/r18n-rails-api'
26
+ s.license = 'LGPL-3'
26
27
 
27
28
  s.add_dependency 'r18n-core', ["= #{R18n::VERSION}"]
28
29
  s.add_dependency 'i18n'
data/spec/backend_spec.rb CHANGED
@@ -8,11 +8,11 @@ describe R18n::Backend do
8
8
  R18n.set('en', R18n::Loader::Rails.new)
9
9
  end
10
10
 
11
- it "should return available locales" do
11
+ it "returns available locales" do
12
12
  I18n.available_locales.should =~ [:en, :ru]
13
13
  end
14
14
 
15
- it "should localize objects" do
15
+ it "localizes objects" do
16
16
  time = Time.at(0).utc
17
17
  date = Date.parse('1970-01-01')
18
18
 
@@ -25,34 +25,34 @@ describe R18n::Backend do
25
25
  I18n.l(-5000.5).should == '−5,000.5'
26
26
  end
27
27
 
28
- it "should translate by key and scope" do
28
+ it "translates by key and scope" do
29
29
  I18n.t('in.another.level').should == 'Hierarchical'
30
30
  I18n.t(:level, :scope => 'in.another').should == 'Hierarchical'
31
31
  I18n.t(:'another.level', :scope => 'in').should == 'Hierarchical'
32
32
  end
33
33
 
34
- it "should use pluralization and variables" do
34
+ it "uses pluralization and variables" do
35
35
  I18n.t('users', :count => 0).should == '0 users'
36
36
  I18n.t('users', :count => 1).should == '1 user'
37
37
  I18n.t('users', :count => 5).should == '5 users'
38
38
  end
39
39
 
40
- it "should use another separator" do
40
+ it "uses another separator" do
41
41
  I18n.t('in/another/level', :separator => '/').should == 'Hierarchical'
42
42
  end
43
43
 
44
- it "should translate array" do
44
+ it "translates array" do
45
45
  I18n.t(['in.another.level', 'in.default']).should == ['Hierarchical',
46
46
  'Default']
47
47
  end
48
48
 
49
- it "should use default value" do
49
+ it "uses default value" do
50
50
  I18n.t(:missed, :default => 'Default').should == 'Default'
51
51
  I18n.t(:missed, :default => :default, :scope => :in).should == 'Default'
52
52
  I18n.t(:missed, :default => [:also_no, :'in.default']).should == 'Default'
53
53
  end
54
54
 
55
- it "should raise error on no translation" do
55
+ it "raises error on no translation" do
56
56
  lambda {
57
57
  I18n.backend.translate(:en, :missed)
58
58
  }.should raise_error(::I18n::MissingTranslationData)
@@ -61,23 +61,23 @@ describe R18n::Backend do
61
61
  }.should raise_error(::I18n::MissingTranslationData)
62
62
  end
63
63
 
64
- it "should reload translations" do
64
+ it "reloads translations" do
65
65
  lambda { I18n.t(:other) }.should raise_error(::I18n::MissingTranslationData)
66
66
  I18n.load_path << OTHER
67
67
  I18n.reload!
68
68
  I18n.t(:other).should == 'Other'
69
69
  end
70
70
 
71
- it "should return plain classes" do
71
+ it "returns plain classes" do
72
72
  I18n.t('in.another.level').class.should == ActiveSupport::SafeBuffer
73
73
  I18n.t('in.another').class.should == Hash
74
74
  end
75
75
 
76
- it "should return correct unpluralized hash" do
76
+ it "returns correct unpluralized hash" do
77
77
  I18n.t('users').should == { :one => '1 user', :other => '%{count} users' }
78
78
  end
79
79
 
80
- it "should correct detect untranslated, whem path is deeper than string" do
80
+ it "corrects detect untranslated, whem path is deeper than string" do
81
81
  lambda {
82
82
  I18n.t('in.another.level.deeper')
83
83
  }.should raise_error(::I18n::MissingTranslationData)
@@ -87,28 +87,28 @@ describe R18n::Backend do
87
87
  }.should raise_error(::I18n::MissingTranslationData)
88
88
  end
89
89
 
90
- it "should not call String methods" do
90
+ it "doesn't call String methods" do
91
91
  I18n.t('in.another').class.should == Hash
92
92
  end
93
93
 
94
- it "should not call object methods" do
94
+ it "doesn't call object methods" do
95
95
  lambda {
96
96
  I18n.t('in.another.level.to_sym')
97
97
  }.should raise_error(::I18n::MissingTranslationData)
98
98
  end
99
99
 
100
- it "should work deeper pluralization" do
100
+ it "works deeper pluralization" do
101
101
  I18n.t('users.other', :count => 5).should == '5 users'
102
102
  end
103
103
 
104
- it "should return hash with symbols keys" do
104
+ it "returns hash with symbols keys" do
105
105
  I18n.t('in').should == {
106
106
  :another => { :level => 'Hierarchical' },
107
107
  :default => 'Default'
108
108
  }
109
109
  end
110
110
 
111
- it "should change locale in place" do
111
+ it "changes locale in place" do
112
112
  I18n.load_path << PL
113
113
  I18n.t('users', :count => 5).should == '5 users'
114
114
  I18n.t('users', :count => 5, :locale => :ru).should == 'Много'
@@ -116,4 +116,8 @@ describe R18n::Backend do
116
116
  I18n.l(Date.parse('1970-01-01'), :locale => :ru).should == '01.01.1970'
117
117
  end
118
118
 
119
+ it "has transliterate method" do
120
+ I18n.transliterate('café').should == 'cafe'
121
+ end
122
+
119
123
  end
data/spec/filters_spec.rb CHANGED
@@ -3,7 +3,7 @@ require File.expand_path('../spec_helper', __FILE__)
3
3
 
4
4
  describe 'Rails filters' do
5
5
 
6
- it "should use named variables" do
6
+ it "uses named variables" do
7
7
  i18n = R18n::Translation.new(EN, '', :locale => EN,
8
8
  :translations => { 'echo' => 'Value is %{value}' })
9
9
 
@@ -14,13 +14,13 @@ describe 'Rails filters' do
14
14
  i18n.echo.should == 'Value is %{value}'
15
15
  end
16
16
 
17
- it "should use old variables syntax" do
17
+ it "uses old variables syntax" do
18
18
  i18n = R18n::Translation.new(EN, '', :locale => EN,
19
19
  :translations => { 'echo' => 'Value is {{value}}' })
20
20
  i18n.echo(:value => 'Old').should == 'Value is Old'
21
21
  end
22
22
 
23
- it "should pluralize by variable %{count}" do
23
+ it "pluralizes by variable %{count}" do
24
24
  i18n = R18n::Translation.new(EN, '', :locale => EN,
25
25
  :translations => {
26
26
  'users' => R18n::Typed.new('pl', {
data/spec/loader_spec.rb CHANGED
@@ -7,15 +7,15 @@ describe R18n::Loader::Rails do
7
7
  @loader = R18n::Loader::Rails.new
8
8
  end
9
9
 
10
- it "should return available locales" do
10
+ it "returns available locales" do
11
11
  @loader.available.should =~ [EN, RU]
12
12
  end
13
13
 
14
- it "should load translation" do
14
+ it "loads translation" do
15
15
  @loader.load(RU).should == { 'one' => 'Один', 'two' => 'Два' }
16
16
  end
17
17
 
18
- it "should change pluralization" do
18
+ it "changes pluralization" do
19
19
  @loader.load(EN).should == {
20
20
  'users' => R18n::Typed.new('pl', {
21
21
  0 => 'Zero', 1 => 'One', 2 => 'Few', 'n' => 'Other'
@@ -23,7 +23,7 @@ describe R18n::Loader::Rails do
23
23
  }
24
24
  end
25
25
 
26
- it "should change Russian pluralization" do
26
+ it "changes Russian pluralization" do
27
27
  I18n.load_path = [PL]
28
28
  @loader.load(RU).should == {
29
29
  'users' => R18n::Typed.new('pl', {
@@ -32,13 +32,13 @@ describe R18n::Loader::Rails do
32
32
  }
33
33
  end
34
34
 
35
- it "should reload translations on load_path changes" do
35
+ it "reloads translations on load_path changes" do
36
36
  I18n.load_path << OTHER
37
37
  @loader.load(RU).should == { 'one' => 'Один', 'two' => 'Два',
38
38
  'three' => 'Три' }
39
39
  end
40
40
 
41
- it "should change hash on load_path changes" do
41
+ it "changes hash on load_path changes" do
42
42
  before = @loader.hash
43
43
  I18n.load_path << OTHER
44
44
  @loader.hash.should_not == before
metadata CHANGED
@@ -1,53 +1,50 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: r18n-rails-api
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.6
5
- prerelease:
4
+ version: 1.1.7
6
5
  platform: ruby
7
6
  authors:
8
7
  - Andrey "A.I." Sitnik
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2013-08-25 00:00:00.000000000 Z
11
+ date: 2013-10-13 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: r18n-core
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
17
  - - '='
20
18
  - !ruby/object:Gem::Version
21
- version: 1.1.6
19
+ version: 1.1.7
22
20
  type: :runtime
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
24
  - - '='
28
25
  - !ruby/object:Gem::Version
29
- version: 1.1.6
26
+ version: 1.1.7
30
27
  - !ruby/object:Gem::Dependency
31
28
  name: i18n
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
- - - ! '>='
31
+ - - '>='
36
32
  - !ruby/object:Gem::Version
37
33
  version: '0'
38
34
  type: :runtime
39
35
  prerelease: false
40
36
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
37
  requirements:
43
- - - ! '>='
38
+ - - '>='
44
39
  - !ruby/object:Gem::Version
45
40
  version: '0'
46
- description: ! " R18n backend for Rails I18n and R18n filters and loader to support
47
- Rails\n translation format.\n R18n has nice Ruby-style syntax, filters, flexible
48
- locales, custom loaders,\n translation support for any classes, time and number
49
- localization, several\n user language support, agnostic core package with out-of-box
50
- support for\n Rails, Sinatra and desktop applications.\n"
41
+ description: |2
42
+ R18n backend for Rails I18n and R18n filters and loader to support Rails
43
+ translation format.
44
+ R18n has nice Ruby-style syntax, filters, flexible locales, custom loaders,
45
+ translation support for any classes, time and number localization, several
46
+ user language support, agnostic core package with out-of-box support for
47
+ Rails, Sinatra and desktop applications.
51
48
  email: andrey@sitnik.ru
52
49
  executables: []
53
50
  extensions: []
@@ -56,7 +53,6 @@ extra_rdoc_files:
56
53
  - LICENSE
57
54
  files:
58
55
  - .rspec
59
- - .yardopts
60
56
  - LICENSE
61
57
  - README.md
62
58
  - Rakefile
@@ -79,34 +75,39 @@ files:
79
75
  - spec/loader_spec.rb
80
76
  - spec/spec_helper.rb
81
77
  homepage: https://github.com/ai/r18n/tree/master/r18n-rails-api
82
- licenses: []
78
+ licenses:
79
+ - LGPL-3
80
+ metadata: {}
83
81
  post_install_message:
84
82
  rdoc_options: []
85
83
  require_paths:
86
84
  - lib
87
85
  required_ruby_version: !ruby/object:Gem::Requirement
88
- none: false
89
86
  requirements:
90
- - - ! '>='
87
+ - - '>='
91
88
  - !ruby/object:Gem::Version
92
89
  version: '0'
93
- segments:
94
- - 0
95
- hash: 3657696565378386384
96
90
  required_rubygems_version: !ruby/object:Gem::Requirement
97
- none: false
98
91
  requirements:
99
- - - ! '>='
92
+ - - '>='
100
93
  - !ruby/object:Gem::Version
101
94
  version: '0'
102
- segments:
103
- - 0
104
- hash: 3657696565378386384
105
95
  requirements: []
106
96
  rubyforge_project:
107
- rubygems_version: 1.8.23
97
+ rubygems_version: 2.0.3
108
98
  signing_key:
109
- specification_version: 3
99
+ specification_version: 4
110
100
  summary: Rails I18n compatibility for R18n
111
- test_files: []
112
- has_rdoc:
101
+ test_files:
102
+ - spec/backend_spec.rb
103
+ - spec/data/general/en.yml
104
+ - spec/data/general/ru.yml
105
+ - spec/data/other/en.yml
106
+ - spec/data/other/ru.yml
107
+ - spec/data/pl/ru.yml
108
+ - spec/data/simple/en.yml
109
+ - spec/data/simple/ru.rb
110
+ - spec/data/simple/russian.yml
111
+ - spec/filters_spec.rb
112
+ - spec/loader_spec.rb
113
+ - spec/spec_helper.rb
data/.yardopts DELETED
@@ -1,3 +0,0 @@
1
- --charset utf-8
2
- -
3
- README.md