rack-locale_chooser 1.0 → 1.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -23,19 +23,21 @@ module Rack::LocaleChooser
23
23
 
24
24
  @logger.debug("Request URL: #{@original_url} | Localized URL: #{localized_url} | URL Locale: #{url_locale} | Cookie Locale: #{cookie_locale} | Geo Locale: #{geo_locale} | Browser Locale: #{browser_locale} | Definitive Locale: #{locale} | City: #{@env['rack.city']}") if @logger
25
25
 
26
- @app.call(env) if @request.post? || @request.put? || @request.delete?
27
-
28
- if @original_url != localized_url then
29
- [301, {'Location' => localized_url}, '']
30
- else
31
- status, headers, body = @app.call(env)
32
- response = Rack::Response.new(body, status, headers)
33
- response.set_cookie('locale', {
34
- :value => I18n.locale,
35
- :path => '/',
36
- :domain => @env["rack.session.options"][:domain]})
37
- response.finish
38
- end
26
+ if @request.post? || @request.put? || @request.delete? then
27
+ @app.call(env)
28
+ else
29
+ if @original_url != localized_url then
30
+ [301, {'Location' => localized_url}, '']
31
+ else
32
+ status, headers, body = @app.call(env)
33
+ response = Rack::Response.new(body, status, headers)
34
+ response.set_cookie('locale', {
35
+ :value => I18n.locale,
36
+ :path => '/',
37
+ :domain => @env["rack.session.options"][:domain]})
38
+ response.finish
39
+ end
40
+ end
39
41
  end
40
42
 
41
43
  def set_session_options
@@ -89,7 +91,7 @@ module Rack::LocaleChooser
89
91
  end
90
92
 
91
93
  def localized_url
92
- current_host = @request.host.gsub(/http:\/\//, '')
94
+ current_host = @request.host.gsub(/http:\/\//, '')
93
95
  return @request.url.gsub(current_host, @options[:host_mappings][locale.to_sym]) if @options[:host_mappings][locale.to_sym]
94
96
  @original_url
95
97
  end
@@ -1,5 +1,5 @@
1
1
  module Rack
2
2
  module LocaleChooser
3
- VERSION = "1.0"
3
+ VERSION = "1.1"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,12 +1,12 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rack-locale_chooser
3
3
  version: !ruby/object:Gem::Version
4
- hash: 15
4
+ hash: 13
5
5
  prerelease: false
6
6
  segments:
7
7
  - 1
8
- - 0
9
- version: "1.0"
8
+ - 1
9
+ version: "1.1"
10
10
  platform: ruby
11
11
  authors:
12
12
  - "Jefferson Jean Martins Gir\xC3\xA3o"
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-11-15 00:00:00 -03:00
17
+ date: 2010-11-17 00:00:00 -03:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency