sinatra-r18n 1.0.0 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -94,15 +94,8 @@ information.
94
94
  You can change default locale and translations dir:
95
95
 
96
96
  ```ruby
97
- set :default_locale, 'ru'
98
- set :translations, './translations'
99
- ```
100
-
101
- You can also provide an Array of translations directories, which may be
102
- useful, for instance, in a plugin-based architecture:
103
-
104
- ```ruby
105
- set :translations, Dir.glob('./myplugins/*/i18n')
97
+ R18n::I18n.default = 'ru'
98
+ R18n.default_places { './translations' }
106
99
  ```
107
100
 
108
101
  # License
data/lib/sinatra/r18n.rb CHANGED
@@ -25,14 +25,18 @@ module Sinatra
25
25
  module R18n
26
26
  def self.registered(app)
27
27
  app.helpers ::R18n::Helpers
28
- app.set :default_locale, 'en'
29
- app.set :translations, Proc.new { File.join(app.root, 'i18n/') }
28
+ app.set :default_locale, Proc.new { ::R18n::I18n.default }
29
+ app.set :translations, Proc.new { ::R18n.default_places }
30
30
 
31
- ::R18n.default_places { settings.translations }
31
+ ::R18n.default_places { File.join(app.root, 'i18n/') }
32
32
 
33
33
  app.before do
34
+ ::R18n.clear_cache! if self.class.development?
35
+
34
36
  ::R18n.set do
35
- ::R18n::I18n.default = settings.default_locale
37
+ if settings.default_locale
38
+ ::R18n::I18n.default = settings.default_locale
39
+ end
36
40
 
37
41
  locales = ::R18n::I18n.parse_http(request.env['HTTP_ACCEPT_LANGUAGE'])
38
42
  if params[:locale]
@@ -37,7 +37,7 @@ describe Sinatra::R18n do
37
37
  end
38
38
 
39
39
  it "should use locale from session" do
40
- get '/locale', {}, { 'rack.session' => { :locale => 'ru' } }
40
+ get '/locale', { }, { 'rack.session' => { :locale => 'ru' } }
41
41
  last_response.should be_ok
42
42
  last_response.body.should == 'Русский'
43
43
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sinatra-r18n
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
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: 2012-06-24 00:00:00.000000000 Z
12
+ date: 2012-06-30 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: sinatra
@@ -34,7 +34,7 @@ dependencies:
34
34
  requirements:
35
35
  - - '='
36
36
  - !ruby/object:Gem::Version
37
- version: 1.0.0
37
+ version: 1.0.1
38
38
  type: :runtime
39
39
  prerelease: false
40
40
  version_requirements: !ruby/object:Gem::Requirement
@@ -42,7 +42,7 @@ dependencies:
42
42
  requirements:
43
43
  - - '='
44
44
  - !ruby/object:Gem::Version
45
- version: 1.0.0
45
+ version: 1.0.1
46
46
  - !ruby/object:Gem::Dependency
47
47
  name: bundler
48
48
  requirement: !ruby/object:Gem::Requirement
@@ -217,7 +217,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
217
217
  version: '0'
218
218
  segments:
219
219
  - 0
220
- hash: 4184599958665730813
220
+ hash: -1494427918030029459
221
221
  required_rubygems_version: !ruby/object:Gem::Requirement
222
222
  none: false
223
223
  requirements:
@@ -226,7 +226,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
226
226
  version: '0'
227
227
  segments:
228
228
  - 0
229
- hash: 4184599958665730813
229
+ hash: -1494427918030029459
230
230
  requirements: []
231
231
  rubyforge_project:
232
232
  rubygems_version: 1.8.23