sinatra-r18n 0.4.3 → 0.4.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.
@@ -27,11 +27,13 @@ require 'r18n-core'
27
27
 
28
28
  module Sinatra #::nodoc::
29
29
  module R18n #::nodoc::
30
- module Helpers
31
- # Return tool for i18n support. It will be R18n::I18n object, see it
32
- # documentation for more information.
33
- def r18n
34
- unless @i18n
30
+ def self.registered(app) #::nodoc::
31
+ app.helpers ::R18n::Helpers
32
+ app.set :default_locale, 'en'
33
+ app.set :translations, Proc.new { File.join(app.root, 'i18n/') }
34
+
35
+ app.before do
36
+ ::R18n.set do
35
37
  ::R18n::I18n.default = options.default_locale
36
38
 
37
39
  locales = ::R18n::I18n.parse_http(request.env['HTTP_ACCEPT_LANGUAGE'])
@@ -41,30 +43,9 @@ module Sinatra #::nodoc::
41
43
  locales.insert(0, session[:locale])
42
44
  end
43
45
 
44
- @i18n = ::R18n::I18n.new(locales, options.translations)
45
- ::R18n.set(@i18n)
46
- else
47
- @i18n
46
+ ::R18n::I18n.new(locales, options.translations)
48
47
  end
49
48
  end
50
- alias i18n r18n
51
-
52
-
53
- # Translate message. Alias for <tt>r18n.t</tt>.
54
- def t(*params)
55
- i18n.t(*params)
56
- end
57
-
58
- # Localize object. Alias for <tt>r18n.l</tt>.
59
- def l(*params)
60
- i18n.l(*params)
61
- end
62
- end
63
-
64
- def self.registered(app) #::nodoc::
65
- app.helpers Helpers
66
- app.set :default_locale, 'en'
67
- app.set :translations, Proc.new { File.join(app.root, 'i18n/') }
68
49
 
69
50
  ::R18n::Filters.off(:untranslated)
70
51
  ::R18n::Filters.add(::R18n::Untranslated, :untranslated_html) do
@@ -8,9 +8,9 @@ describe Sinatra::R18n do
8
8
  end
9
9
 
10
10
  it "should translate messages" do
11
- get '/ru/posts/1'
11
+ get '/en/posts/1'
12
12
  last_response.should be_ok
13
- last_response.body.should == "<h1>Запись 1</h1>\n"
13
+ last_response.body.should == "<h1>Post 1</h1>\n"
14
14
  end
15
15
 
16
16
  it "should use translations from default locale" do
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: 0.4.3
4
+ version: 0.4.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrey "A.I." Sitnik
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2010-02-26 00:00:00 +03:00
12
+ date: 2010-03-29 00:00:00 +04:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -20,7 +20,7 @@ dependencies:
20
20
  requirements:
21
21
  - - "="
22
22
  - !ruby/object:Gem::Version
23
- version: 0.4.3
23
+ version: 0.4.4
24
24
  version:
25
25
  description: " A Sinatra extension that provides i18n support to translate your web\n application. It is just a wrapper for R18n core library.\n It has nice Ruby-style syntax, filters, flexible locales, custom loaders,\n translation support for any classes, time and number localization, several\n user language support, agnostic core package with out-of-box support for\n Rails, Sinatra, Merb and desktop applications.\n"
26
26
  email: andrey@sitnik.ru