auto_locale 0.1.0 → 0.2.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 +7 -0
- data/Gemfile +1 -1
- data/README.rdoc +1 -1
- data/Rakefile +1 -1
- data/auto_locale.gemspec +7 -7
- data/lib/auto_locale.rb +10 -12
- data/lib/auto_locale/version.rb +1 -1
- metadata +9 -12
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA1:
|
|
3
|
+
metadata.gz: 1f6b511354e15ff95bc45356a341afcb97a45ceb
|
|
4
|
+
data.tar.gz: 9d0883e0911dd3db1ac246119aa1e366a6453014
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 5025078d64d10e06921b97e0284f3f660e18320ce2d5d55328cadbe8508eb9b5db4059bb64a1370e5db8e2c72bb9684df0394b8ef8dac0fdb7cf78e174ea8897
|
|
7
|
+
data.tar.gz: cd31bfcb685047eaf5b7454a8de1dbfe5cc180b46288d48768a092550114707fbe704d2843b15754778d453d4f1db24010f74b7f4d85c59b5e95eaf494aef14a
|
data/Gemfile
CHANGED
data/README.rdoc
CHANGED
data/Rakefile
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
require
|
|
1
|
+
require 'bundler/gem_tasks'
|
data/auto_locale.gemspec
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
|
2
|
-
$:.push File.expand_path(
|
|
3
|
-
require
|
|
2
|
+
$:.push File.expand_path('../lib', __FILE__)
|
|
3
|
+
require 'auto_locale/version'
|
|
4
4
|
|
|
5
5
|
Gem::Specification.new do |s|
|
|
6
|
-
s.name =
|
|
6
|
+
s.name = 'auto_locale'
|
|
7
7
|
s.version = AutoLocale::VERSION
|
|
8
|
-
s.authors = [
|
|
9
|
-
s.email = [
|
|
10
|
-
s.homepage =
|
|
8
|
+
s.authors = ['Florian Schwab']
|
|
9
|
+
s.email = ['me@ydkn.de']
|
|
10
|
+
s.homepage = 'http://github.com/ydkn/auto_locale'
|
|
11
11
|
s.summary = %q{Automatically set the locale from the browsers HTTP_ACCEPT_LANGUAGE header}
|
|
12
12
|
s.description = %q{Use this gem to automatically set the current locale from the browsers HTTP_ACCEPT_LANGUAGE header}
|
|
13
13
|
|
|
14
14
|
s.files = `git ls-files`.split("\n")
|
|
15
15
|
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
|
16
16
|
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
|
17
|
-
s.require_paths = [
|
|
17
|
+
s.require_paths = ['lib']
|
|
18
18
|
end
|
data/lib/auto_locale.rb
CHANGED
|
@@ -15,26 +15,25 @@
|
|
|
15
15
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
16
16
|
|
|
17
17
|
|
|
18
|
-
require
|
|
18
|
+
require 'auto_locale/version'
|
|
19
19
|
|
|
20
20
|
module AutoLocale
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
base.before_filter :set_auto_locale
|
|
21
|
+
def self.included(base)
|
|
22
|
+
base.before_action :set_auto_locale
|
|
24
23
|
end
|
|
25
|
-
|
|
24
|
+
|
|
26
25
|
def set_auto_locale
|
|
27
|
-
available_locales = I18n.available_locales.
|
|
28
|
-
|
|
29
|
-
locales = request.accept_language.split(/\s*,\s*/).
|
|
26
|
+
available_locales = I18n.available_locales.map(&:to_s)
|
|
27
|
+
|
|
28
|
+
locales = request.accept_language.split(/\s*,\s*/).map do |l|
|
|
30
29
|
l += ';q=1.0' unless l =~ /;q=\d+\.\d+$/
|
|
31
30
|
l.split(';q=')
|
|
32
31
|
end.sort do |a, b|
|
|
33
32
|
b.last.to_f <=> a.last.to_f
|
|
34
|
-
end.
|
|
35
|
-
l.first.downcase.gsub(/-[a-z]+$/i) {|c| c.upcase}
|
|
33
|
+
end.map do |l|
|
|
34
|
+
l.first.downcase.gsub(/-[a-z]+$/i) { |c| c.upcase }
|
|
36
35
|
end
|
|
37
|
-
|
|
36
|
+
|
|
38
37
|
locales.each do |l|
|
|
39
38
|
available_locales.each do |al|
|
|
40
39
|
if l == al
|
|
@@ -49,7 +48,6 @@ module AutoLocale
|
|
|
49
48
|
rescue
|
|
50
49
|
I18n.locale = I18n.default_locale
|
|
51
50
|
end
|
|
52
|
-
|
|
53
51
|
end
|
|
54
52
|
|
|
55
53
|
ActionController::Base.send :include, AutoLocale
|
data/lib/auto_locale/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,16 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: auto_locale
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
5
|
-
prerelease:
|
|
4
|
+
version: 0.2.0
|
|
6
5
|
platform: ruby
|
|
7
6
|
authors:
|
|
8
7
|
- Florian Schwab
|
|
9
8
|
autorequire:
|
|
10
9
|
bindir: bin
|
|
11
10
|
cert_chain: []
|
|
12
|
-
date:
|
|
13
|
-
default_executable:
|
|
11
|
+
date: 2016-07-11 00:00:00.000000000 Z
|
|
14
12
|
dependencies: []
|
|
15
13
|
description: Use this gem to automatically set the current locale from the browsers
|
|
16
14
|
HTTP_ACCEPT_LANGUAGE header
|
|
@@ -20,7 +18,7 @@ executables: []
|
|
|
20
18
|
extensions: []
|
|
21
19
|
extra_rdoc_files: []
|
|
22
20
|
files:
|
|
23
|
-
- .gitignore
|
|
21
|
+
- ".gitignore"
|
|
24
22
|
- Gemfile
|
|
25
23
|
- LICENSE
|
|
26
24
|
- README.rdoc
|
|
@@ -28,29 +26,28 @@ files:
|
|
|
28
26
|
- auto_locale.gemspec
|
|
29
27
|
- lib/auto_locale.rb
|
|
30
28
|
- lib/auto_locale/version.rb
|
|
31
|
-
has_rdoc: true
|
|
32
29
|
homepage: http://github.com/ydkn/auto_locale
|
|
33
30
|
licenses: []
|
|
31
|
+
metadata: {}
|
|
34
32
|
post_install_message:
|
|
35
33
|
rdoc_options: []
|
|
36
34
|
require_paths:
|
|
37
35
|
- lib
|
|
38
36
|
required_ruby_version: !ruby/object:Gem::Requirement
|
|
39
|
-
none: false
|
|
40
37
|
requirements:
|
|
41
|
-
- -
|
|
38
|
+
- - ">="
|
|
42
39
|
- !ruby/object:Gem::Version
|
|
43
40
|
version: '0'
|
|
44
41
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
45
|
-
none: false
|
|
46
42
|
requirements:
|
|
47
|
-
- -
|
|
43
|
+
- - ">="
|
|
48
44
|
- !ruby/object:Gem::Version
|
|
49
45
|
version: '0'
|
|
50
46
|
requirements: []
|
|
51
47
|
rubyforge_project:
|
|
52
|
-
rubygems_version:
|
|
48
|
+
rubygems_version: 2.5.1
|
|
53
49
|
signing_key:
|
|
54
|
-
specification_version:
|
|
50
|
+
specification_version: 4
|
|
55
51
|
summary: Automatically set the locale from the browsers HTTP_ACCEPT_LANGUAGE header
|
|
56
52
|
test_files: []
|
|
53
|
+
has_rdoc:
|