rack-user-locale 0.3.0 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/{LICENSE.txt → MIT-LICENSE} +1 -1
- data/README.md +46 -40
- data/VERSION +1 -1
- metadata +18 -26
- data/.document +0 -5
- data/.gitignore +0 -52
- data/.rubocop.yml +0 -25
- data/.ruby-version +0 -1
- data/.travis.yml +0 -1
- data/Gemfile +0 -8
- data/Gemfile.lock +0 -51
- data/rack-user-locale.gemspec +0 -36
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 119a5ba73803ba26f032ce0bfbde1af51cb53e43e75bd78eb2706a9c271b85a2
|
4
|
+
data.tar.gz: f494a70dfced6bfea8a6e95f073bdd1abbb0ccfd42c7fb91e84a7fa8db42a608
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8f11e2cdf8425315e195bbf61d0cf4b5055e3890302247e0d8ffe1760539c22371a9901168e9ea829199126afb93583c0087b30194e7393ae30e9dd533b41a6e
|
7
|
+
data.tar.gz: ccf6cbc538febba95cd6a5b023747503614901a3d8574bb7484fac05cd7f2f9a6e01415970183cee2e9d2a71665605d1766aecdce856e89f2949a42094039aea
|
data/{LICENSE.txt → MIT-LICENSE}
RENAMED
data/README.md
CHANGED
@@ -1,18 +1,16 @@
|
|
1
|
-
|
2
|
-
----------------
|
1
|
+
# Rack User Locale
|
3
2
|
|
4
|
-
[![Gem Version](https://badge.fury.io/rb/rack-user-locale.png)](http://badge.fury.io/rb/rack-user-locale) [![Build Status](https://secure.travis-ci.org/
|
3
|
+
[![Gem Version](https://badge.fury.io/rb/rack-user-locale.png)](http://badge.fury.io/rb/rack-user-locale) [![Build Status](https://secure.travis-ci.org/schinery/rack-user-locale.png)](http://travis-ci.org/schinery/rack-user-locale)
|
5
4
|
|
6
5
|
A Rack module for getting and setting a user's locale via a cookie or browser default language.
|
7
6
|
|
8
7
|
Credit to these gems for pointing me in the direction I wanted to go in...
|
9
8
|
|
10
|
-
|
11
|
-
|
12
|
-
|
9
|
+
- https://github.com/rack/rack-contrib/blob/master/lib/rack/contrib/locale.rb
|
10
|
+
- https://github.com/jeremyvdw/rack-locale-selector
|
11
|
+
- https://github.com/jeffersongirao/rack-locale_chooser
|
13
12
|
|
14
|
-
Installation
|
15
|
-
============
|
13
|
+
## Installation
|
16
14
|
|
17
15
|
```
|
18
16
|
gem install rack-user-locale
|
@@ -24,12 +22,11 @@ In a Gemfile:
|
|
24
22
|
gem 'rack-user-locale'
|
25
23
|
```
|
26
24
|
|
27
|
-
Usage
|
28
|
-
=====
|
25
|
+
## Usage
|
29
26
|
|
30
27
|
Add the following line to your Rack application
|
31
28
|
|
32
|
-
```
|
29
|
+
```ruby
|
33
30
|
use Rack::UserLocale
|
34
31
|
```
|
35
32
|
|
@@ -37,19 +34,9 @@ and thats it!!
|
|
37
34
|
|
38
35
|
Your application will now attempt to set the I18n.locale value based on the following:
|
39
36
|
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
There is the option to pass in an accepted array of locales, like so:
|
45
|
-
|
46
|
-
```
|
47
|
-
use Rack::UserLocale, :accepted_locales => [:de, :en, :es, :fr, :ja, :pt, :zh, (whatever codes you support)]
|
48
|
-
```
|
49
|
-
|
50
|
-
If this option is supplied the the users locale will either be set to one of the accepted locales in the array, otherwise it will be set to the I18n.default_locale value.
|
51
|
-
|
52
|
-
Should you wish to overwrite a users locale value at any point in your application, like for changing language prefs, then simple rewrite the "user-locale" cookie with a new value.
|
37
|
+
- Whether a user has a `user-locale` cookie set
|
38
|
+
- The "HTTP_ACCEPT_LANGUAGE" value. If there are multiple values it will attempt to set the one ranked highest
|
39
|
+
- The I18n.default_locale value (basically a fallback)
|
53
40
|
|
54
41
|
**Note:**
|
55
42
|
|
@@ -59,27 +46,46 @@ If you don't want this happen then you can use Rack::Static in your application
|
|
59
46
|
|
60
47
|
Something like this:
|
61
48
|
|
49
|
+
```ruby
|
50
|
+
use Rack::Static, urls: ["/css", "/js"], root: "public"
|
62
51
|
```
|
63
|
-
|
64
|
-
|
65
|
-
would serve anything in your public folder statically and wouldn't create a Rack::Request.
|
52
|
+
|
53
|
+
This would serve anything in your public folder statically and wouldn't create a Rack::Request.
|
66
54
|
|
67
55
|
See the [Rack::Static docs](http://rack.rubyforge.org/doc/classes/Rack/Static.html) for more info.
|
68
56
|
|
69
|
-
|
70
|
-
|
57
|
+
## Options
|
58
|
+
|
59
|
+
### Accepted Locales
|
60
|
+
|
61
|
+
```ruby
|
62
|
+
use Rack::UserLocale, accepted_locales: [:de, :en, :es, :fr, :ja, :pt, :zh] #(whatever codes you support)
|
63
|
+
```
|
64
|
+
|
65
|
+
If this option is supplied the users locale will either be set to one of the accepted locales in the array, otherwise it will be set to the `I18n.default_locale` value.
|
66
|
+
|
67
|
+
Should you wish to overwrite a users locale value at any point in your application, like for changing language prefs, then simple rewrite the `user-locale` cookie with a new value.
|
68
|
+
|
69
|
+
### Cookie Name
|
70
|
+
|
71
|
+
If you don't want to use the default cookie name of `user-locale`, you can set it to something else by passing a `cookie_name` option.
|
72
|
+
|
73
|
+
```ruby
|
74
|
+
use Rack::UserLocale, cookie_name: "some-cookie-name"
|
75
|
+
```
|
76
|
+
|
77
|
+
## Contributing to rack-user-locale
|
71
78
|
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
+
- Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
|
80
|
+
- Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it.
|
81
|
+
- Fork the project.
|
82
|
+
- Start a feature/bugfix branch.
|
83
|
+
- Commit and push until you are happy with your contribution.
|
84
|
+
- Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
|
85
|
+
- Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
|
79
86
|
|
80
|
-
Copyright
|
81
|
-
=========
|
87
|
+
## Copyright
|
82
88
|
|
83
|
-
Copyright (c)
|
89
|
+
Copyright (c) 2019 [Stuart Chinery](https://github.com/schinery) and [Dave Hrycyszyn](https://github.com/futurechimp).
|
84
90
|
|
85
|
-
See LICENSE.txt for further details.
|
91
|
+
See LICENSE.txt for further details.
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.4.0
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rack-user-locale
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Stuart Chinery
|
8
8
|
autorequire:
|
9
|
-
bindir:
|
9
|
+
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-11-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: i18n
|
@@ -44,98 +44,98 @@ dependencies:
|
|
44
44
|
requirements:
|
45
45
|
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: 2.0
|
47
|
+
version: '2.0'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: 2.0
|
54
|
+
version: '2.0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: minitest
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
59
|
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: 5.12
|
61
|
+
version: '5.12'
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: 5.12
|
68
|
+
version: '5.12'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: minitest-fail-fast
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
73
|
- - "~>"
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version: 0.1
|
75
|
+
version: '0.1'
|
76
76
|
type: :development
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
80
|
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version: 0.1
|
82
|
+
version: '0.1'
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
84
|
name: minitest-macos-notification
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
87
|
- - "~>"
|
88
88
|
- !ruby/object:Gem::Version
|
89
|
-
version: 0.
|
89
|
+
version: '0.1'
|
90
90
|
type: :development
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
94
|
- - "~>"
|
95
95
|
- !ruby/object:Gem::Version
|
96
|
-
version: 0.
|
96
|
+
version: '0.1'
|
97
97
|
- !ruby/object:Gem::Dependency
|
98
98
|
name: minitest-reporters
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
100
100
|
requirements:
|
101
101
|
- - "~>"
|
102
102
|
- !ruby/object:Gem::Version
|
103
|
-
version: 1.
|
103
|
+
version: '1.4'
|
104
104
|
type: :development
|
105
105
|
prerelease: false
|
106
106
|
version_requirements: !ruby/object:Gem::Requirement
|
107
107
|
requirements:
|
108
108
|
- - "~>"
|
109
109
|
- !ruby/object:Gem::Version
|
110
|
-
version: 1.
|
110
|
+
version: '1.4'
|
111
111
|
- !ruby/object:Gem::Dependency
|
112
112
|
name: rack-test
|
113
113
|
requirement: !ruby/object:Gem::Requirement
|
114
114
|
requirements:
|
115
115
|
- - "~>"
|
116
116
|
- !ruby/object:Gem::Version
|
117
|
-
version: 1.1
|
117
|
+
version: '1.1'
|
118
118
|
type: :development
|
119
119
|
prerelease: false
|
120
120
|
version_requirements: !ruby/object:Gem::Requirement
|
121
121
|
requirements:
|
122
122
|
- - "~>"
|
123
123
|
- !ruby/object:Gem::Version
|
124
|
-
version: 1.1
|
124
|
+
version: '1.1'
|
125
125
|
- !ruby/object:Gem::Dependency
|
126
126
|
name: rake
|
127
127
|
requirement: !ruby/object:Gem::Requirement
|
128
128
|
requirements:
|
129
129
|
- - "~>"
|
130
130
|
- !ruby/object:Gem::Version
|
131
|
-
version: 13.0
|
131
|
+
version: '13.0'
|
132
132
|
type: :development
|
133
133
|
prerelease: false
|
134
134
|
version_requirements: !ruby/object:Gem::Requirement
|
135
135
|
requirements:
|
136
136
|
- - "~>"
|
137
137
|
- !ruby/object:Gem::Version
|
138
|
-
version: 13.0
|
138
|
+
version: '13.0'
|
139
139
|
description: A Rack module for getting and setting a user's locale via a cookie or
|
140
140
|
browser default language.
|
141
141
|
email:
|
@@ -144,20 +144,12 @@ executables: []
|
|
144
144
|
extensions: []
|
145
145
|
extra_rdoc_files: []
|
146
146
|
files:
|
147
|
-
-
|
148
|
-
- ".gitignore"
|
149
|
-
- ".rubocop.yml"
|
150
|
-
- ".ruby-version"
|
151
|
-
- ".travis.yml"
|
152
|
-
- Gemfile
|
153
|
-
- Gemfile.lock
|
154
|
-
- LICENSE.txt
|
147
|
+
- MIT-LICENSE
|
155
148
|
- README.md
|
156
149
|
- Rakefile
|
157
150
|
- VERSION
|
158
151
|
- lib/rack/user-locale/version.rb
|
159
152
|
- lib/user-locale.rb
|
160
|
-
- rack-user-locale.gemspec
|
161
153
|
homepage: https://github.com/schinery/rack-user-locale
|
162
154
|
licenses:
|
163
155
|
- MIT
|
data/.document
DELETED
data/.gitignore
DELETED
@@ -1,52 +0,0 @@
|
|
1
|
-
# rcov generated
|
2
|
-
coverage
|
3
|
-
coverage.data
|
4
|
-
|
5
|
-
# rdoc generated
|
6
|
-
rdoc
|
7
|
-
|
8
|
-
# yard generated
|
9
|
-
doc
|
10
|
-
.yardoc
|
11
|
-
|
12
|
-
# bundler
|
13
|
-
.bundle
|
14
|
-
|
15
|
-
# jeweler generated
|
16
|
-
pkg
|
17
|
-
|
18
|
-
# Have editor/IDE/OS specific files you need to ignore? Consider using a global gitignore:
|
19
|
-
#
|
20
|
-
# * Create a file at ~/.gitignore
|
21
|
-
# * Include files you want ignored
|
22
|
-
# * Run: git config --global core.excludesfile ~/.gitignore
|
23
|
-
#
|
24
|
-
# After doing this, these files will be ignored in all your git projects,
|
25
|
-
# saving you from having to 'pollute' every project you touch with them
|
26
|
-
#
|
27
|
-
# Not sure what to needs to be ignored for particular editors/OSes? Here's some ideas to get you started. (Remember, remove the leading # of the line)
|
28
|
-
#
|
29
|
-
# For MacOS:
|
30
|
-
#
|
31
|
-
.DS_Store
|
32
|
-
|
33
|
-
# For TextMate
|
34
|
-
#*.tmproj
|
35
|
-
#tmtags
|
36
|
-
|
37
|
-
# For emacs:
|
38
|
-
#*~
|
39
|
-
#\#*
|
40
|
-
#.\#*
|
41
|
-
|
42
|
-
# For vim:
|
43
|
-
#*.swp
|
44
|
-
|
45
|
-
# For redcar:
|
46
|
-
#.redcar
|
47
|
-
|
48
|
-
# For rubinius:
|
49
|
-
#*.rbc
|
50
|
-
|
51
|
-
.rvmrc
|
52
|
-
.byebug_history
|
data/.rubocop.yml
DELETED
@@ -1,25 +0,0 @@
|
|
1
|
-
AllCops:
|
2
|
-
TargetRubyVersion: 2.5
|
3
|
-
|
4
|
-
# Use double quotes ALL THE TIME!!!
|
5
|
-
Style/StringLiterals:
|
6
|
-
EnforcedStyle: double_quotes
|
7
|
-
|
8
|
-
# Disable Style/Documentation because...
|
9
|
-
Style/Documentation:
|
10
|
-
Enabled: false
|
11
|
-
|
12
|
-
# Increase line length to 120
|
13
|
-
Metrics/LineLength:
|
14
|
-
Max: 120
|
15
|
-
|
16
|
-
# Exclude class and method length for test
|
17
|
-
Metrics/BlockLength:
|
18
|
-
Exclude:
|
19
|
-
- "test/**/*"
|
20
|
-
Metrics/ClassLength:
|
21
|
-
Exclude:
|
22
|
-
- "test/**/*"
|
23
|
-
Metrics/MethodLength:
|
24
|
-
Exclude:
|
25
|
-
- "test/**/*"
|
data/.ruby-version
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
2.6.4
|
data/.travis.yml
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
language: ruby
|
data/Gemfile
DELETED
data/Gemfile.lock
DELETED
@@ -1,51 +0,0 @@
|
|
1
|
-
PATH
|
2
|
-
remote: .
|
3
|
-
specs:
|
4
|
-
rack-user-locale (0.3.0)
|
5
|
-
i18n (>= 0.6.6)
|
6
|
-
rack (>= 1.6.11)
|
7
|
-
|
8
|
-
GEM
|
9
|
-
remote: https://rubygems.org/
|
10
|
-
specs:
|
11
|
-
ansi (1.5.0)
|
12
|
-
builder (3.2.3)
|
13
|
-
concurrent-ruby (1.1.5)
|
14
|
-
i18n (1.6.0)
|
15
|
-
concurrent-ruby (~> 1.0)
|
16
|
-
minitest (5.12.2)
|
17
|
-
minitest-fail-fast (0.1.0)
|
18
|
-
minitest (~> 5)
|
19
|
-
minitest-macos-notification (0.0.6)
|
20
|
-
minitest (~> 5.0)
|
21
|
-
minitest-reporters (~> 1.3)
|
22
|
-
os (~> 1.0)
|
23
|
-
terminal-notifier (~> 2.0)
|
24
|
-
minitest-reporters (1.3.8)
|
25
|
-
ansi
|
26
|
-
builder
|
27
|
-
minitest (>= 5.0)
|
28
|
-
ruby-progressbar
|
29
|
-
os (1.0.1)
|
30
|
-
rack (2.0.7)
|
31
|
-
rack-test (1.1.0)
|
32
|
-
rack (>= 1.0, < 3)
|
33
|
-
rake (13.0.0)
|
34
|
-
ruby-progressbar (1.10.1)
|
35
|
-
terminal-notifier (2.0.0)
|
36
|
-
|
37
|
-
PLATFORMS
|
38
|
-
ruby
|
39
|
-
|
40
|
-
DEPENDENCIES
|
41
|
-
bundler (~> 2.0.2)
|
42
|
-
minitest (~> 5.12.2)
|
43
|
-
minitest-fail-fast (~> 0.1.0)
|
44
|
-
minitest-macos-notification (~> 0.0.5)
|
45
|
-
minitest-reporters (~> 1.3.5)
|
46
|
-
rack-test (~> 1.1.0)
|
47
|
-
rack-user-locale!
|
48
|
-
rake (~> 13.0.0)
|
49
|
-
|
50
|
-
BUNDLED WITH
|
51
|
-
2.0.2
|
data/rack-user-locale.gemspec
DELETED
@@ -1,36 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
lib = File.expand_path("lib", __dir__)
|
4
|
-
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
5
|
-
require "rack/user-locale/version"
|
6
|
-
|
7
|
-
Gem::Specification.new do |spec|
|
8
|
-
spec.name = "rack-user-locale"
|
9
|
-
spec.version = Rack::UserLocale::VERSION
|
10
|
-
spec.authors = ["Stuart Chinery"]
|
11
|
-
spec.email = ["stuart.chinery@gmail.com"]
|
12
|
-
|
13
|
-
spec.summary = "A Rack module for getting and setting a user's locale"
|
14
|
-
spec.description = "A Rack module for getting and setting a user's locale via a cookie or browser default language."
|
15
|
-
spec.homepage = "https://github.com/schinery/rack-user-locale"
|
16
|
-
spec.license = "MIT"
|
17
|
-
|
18
|
-
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
19
|
-
f.match(%r{^(test|spec|features)/})
|
20
|
-
end
|
21
|
-
|
22
|
-
spec.bindir = "exe"
|
23
|
-
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
24
|
-
spec.require_paths = ["lib"]
|
25
|
-
|
26
|
-
spec.add_dependency "i18n", ">= 0.6.6"
|
27
|
-
spec.add_dependency "rack", ">= 1.6.11"
|
28
|
-
|
29
|
-
spec.add_development_dependency "bundler", "~> 2.0.2"
|
30
|
-
spec.add_development_dependency "minitest", "~> 5.12.2"
|
31
|
-
spec.add_development_dependency "minitest-fail-fast", "~> 0.1.0"
|
32
|
-
spec.add_development_dependency "minitest-macos-notification", "~> 0.0.5"
|
33
|
-
spec.add_development_dependency "minitest-reporters", "~> 1.3.5"
|
34
|
-
spec.add_development_dependency "rack-test", "~> 1.1.0"
|
35
|
-
spec.add_development_dependency "rake", "~> 13.0.0"
|
36
|
-
end
|