sinatra-r18n 1.1.11 → 2.0.0
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.
- checksums.yaml +4 -4
- data/lib/sinatra/r18n.rb +1 -2
- data/sinatra-r18n.gemspec +5 -5
- data/spec/app/app.rb +0 -1
- data/spec/sinatra-r18n_spec.rb +21 -23
- data/spec/spec_helper.rb +0 -1
- metadata +5 -5
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: ec4e1325d8290c79eed4af34379b6e3722f393e2
|
|
4
|
+
data.tar.gz: 8c3896235edb6f362e789e63076759ef7f368049
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 800d2320d72f9a7d395b8171b0e987b4ab93ab786989a32c561a8fb91c2ff5924fc0c92747332527c281e8d6f6f3c99ab7396ebb2c0eba1c2be98644156ead67
|
|
7
|
+
data.tar.gz: 8665c0bbf9206fa58fae3f8e2d5630c0d75823b8c4ec7f29a4fefe7a0dc466f0f9676705922efd9a1eb1ef381872c86816f5fbd457314bff328ce3a1d7505408
|
data/lib/sinatra/r18n.rb
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
# encoding: utf-8
|
|
2
1
|
=begin
|
|
3
2
|
Sinatra extension to i18n support.
|
|
4
3
|
|
|
@@ -46,7 +45,7 @@ module Sinatra
|
|
|
46
45
|
end
|
|
47
46
|
|
|
48
47
|
::R18n::I18n.new(locales, ::R18n.default_places,
|
|
49
|
-
:
|
|
48
|
+
off_filters: :untranslated, on_filters: :untranslated_html)
|
|
50
49
|
end
|
|
51
50
|
end
|
|
52
51
|
end
|
data/sinatra-r18n.gemspec
CHANGED
|
@@ -2,11 +2,11 @@ require File.expand_path('../../r18n-core/lib/r18n-core/version', __FILE__)
|
|
|
2
2
|
|
|
3
3
|
Gem::Specification.new do |s|
|
|
4
4
|
s.platform = Gem::Platform::RUBY
|
|
5
|
-
s.name
|
|
6
|
-
s.version
|
|
7
|
-
s.date
|
|
8
|
-
|
|
9
|
-
|
|
5
|
+
s.name = 'sinatra-r18n'
|
|
6
|
+
s.version = R18n::VERSION.dup
|
|
7
|
+
s.date = Time.now.strftime('%Y-%m-%d')
|
|
8
|
+
|
|
9
|
+
s.summary = 'A Sinatra extension that provides i18n support'
|
|
10
10
|
s.description = <<-EOF
|
|
11
11
|
A Sinatra extension that provides i18n support to translate your web
|
|
12
12
|
application. It is just a wrapper for R18n core library.
|
data/spec/app/app.rb
CHANGED
data/spec/sinatra-r18n_spec.rb
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
# encoding: utf-8
|
|
2
1
|
require File.expand_path('../spec_helper', __FILE__)
|
|
3
2
|
|
|
4
3
|
describe Sinatra::R18n do
|
|
5
4
|
before(:all) do
|
|
6
5
|
Sinatra::R18n.registered(app)
|
|
7
|
-
|
|
6
|
+
end
|
|
8
7
|
|
|
9
8
|
after do
|
|
10
9
|
app.set :default_locale, 'en'
|
|
@@ -13,58 +12,57 @@ describe Sinatra::R18n do
|
|
|
13
12
|
|
|
14
13
|
it "translates messages" do
|
|
15
14
|
get '/en/posts/1'
|
|
16
|
-
last_response.
|
|
17
|
-
last_response.body.
|
|
15
|
+
expect(last_response).to be_ok
|
|
16
|
+
expect(last_response.body).to eq "<h1>Post 1</h1>\n"
|
|
18
17
|
end
|
|
19
18
|
|
|
20
19
|
it "uses translations from default locale" do
|
|
21
20
|
get '/ru/posts/1/comments'
|
|
22
|
-
last_response.
|
|
23
|
-
last_response.body.
|
|
21
|
+
expect(last_response).to be_ok
|
|
22
|
+
expect(last_response.body).to eq '3 comments'
|
|
24
23
|
end
|
|
25
24
|
|
|
26
25
|
it "uses default locale" do
|
|
27
26
|
app.set :default_locale, 'ru'
|
|
28
27
|
get '/locale'
|
|
29
|
-
last_response.
|
|
30
|
-
last_response.body.
|
|
28
|
+
expect(last_response).to be_ok
|
|
29
|
+
expect(last_response.body).to eq 'Русский'
|
|
31
30
|
end
|
|
32
31
|
|
|
33
32
|
it "autodetects user locale" do
|
|
34
33
|
get '/locale', {}, {'HTTP_ACCEPT_LANGUAGE' => 'ru,en;q=0.9'}
|
|
35
|
-
last_response.
|
|
36
|
-
last_response.body.
|
|
34
|
+
expect(last_response).to be_ok
|
|
35
|
+
expect(last_response.body).to eq 'Русский'
|
|
37
36
|
end
|
|
38
37
|
|
|
39
38
|
it "uses locale from session" do
|
|
40
|
-
get '/locale', { }, { 'rack.session' => { :
|
|
41
|
-
last_response.
|
|
42
|
-
last_response.body.
|
|
39
|
+
get '/locale', { }, { 'rack.session' => { locale: 'ru' } }
|
|
40
|
+
expect(last_response).to be_ok
|
|
41
|
+
expect(last_response.body).to eq 'Русский'
|
|
43
42
|
end
|
|
44
43
|
|
|
45
44
|
it "returns locales list" do
|
|
46
45
|
get '/locales'
|
|
47
|
-
last_response.
|
|
48
|
-
last_response.body.
|
|
46
|
+
expect(last_response).to be_ok
|
|
47
|
+
expect(last_response.body).to eq 'en: English; ru: Русский'
|
|
49
48
|
end
|
|
50
49
|
|
|
51
50
|
it "formats untranslated string" do
|
|
52
51
|
get '/untranslated'
|
|
53
|
-
last_response.
|
|
54
|
-
last_response.body.
|
|
52
|
+
expect(last_response).to be_ok
|
|
53
|
+
expect(last_response.body).to eq 'post.<span style="color: red">[no]</span>'
|
|
55
54
|
end
|
|
56
55
|
|
|
57
56
|
it "localizes objects" do
|
|
58
57
|
get '/time'
|
|
59
|
-
last_response.
|
|
60
|
-
last_response.body.
|
|
58
|
+
expect(last_response).to be_ok
|
|
59
|
+
expect(last_response.body).to eq "01/01/1970 00:00"
|
|
61
60
|
end
|
|
62
61
|
|
|
63
62
|
it "sets default places" do
|
|
64
|
-
|
|
65
|
-
|
|
63
|
+
path = Pathname(__FILE__).dirname.expand_path.join('app/i18n/').to_s
|
|
64
|
+
expect(R18n.default_places).to eq path
|
|
66
65
|
R18n.set('en')
|
|
67
|
-
R18n.get.post.title(1).
|
|
66
|
+
expect(R18n.get.post.title(1)).to eq 'Post 1'
|
|
68
67
|
end
|
|
69
|
-
|
|
70
68
|
end
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: sinatra-r18n
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version:
|
|
4
|
+
version: 2.0.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Andrey Sitnik
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2014-05
|
|
11
|
+
date: 2014-12-05 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: sinatra
|
|
@@ -30,14 +30,14 @@ dependencies:
|
|
|
30
30
|
requirements:
|
|
31
31
|
- - '='
|
|
32
32
|
- !ruby/object:Gem::Version
|
|
33
|
-
version:
|
|
33
|
+
version: 2.0.0
|
|
34
34
|
type: :runtime
|
|
35
35
|
prerelease: false
|
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
|
37
37
|
requirements:
|
|
38
38
|
- - '='
|
|
39
39
|
- !ruby/object:Gem::Version
|
|
40
|
-
version:
|
|
40
|
+
version: 2.0.0
|
|
41
41
|
description: |2
|
|
42
42
|
A Sinatra extension that provides i18n support to translate your web
|
|
43
43
|
application. It is just a wrapper for R18n core library.
|
|
@@ -87,7 +87,7 @@ rubyforge_project:
|
|
|
87
87
|
rubygems_version: 2.2.2
|
|
88
88
|
signing_key:
|
|
89
89
|
specification_version: 4
|
|
90
|
-
summary: A Sinatra extension that provides i18n support
|
|
90
|
+
summary: A Sinatra extension that provides i18n support
|
|
91
91
|
test_files:
|
|
92
92
|
- spec/app/app.rb
|
|
93
93
|
- spec/app/i18n/en.yml
|