geo_locale 0.0.2 → 0.0.3
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 +4 -4
- data/README.md +9 -4
- data/lib/geo_locale/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6e0767be5acbb167c117d6961f8303e5c0a1cdb2
|
4
|
+
data.tar.gz: 509a7a2923e39c2e1eb74c0bfefc0b0adfbeaf02
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 80245a9cda71f8dd2eebffc8dccb238182bcb432c3be3da5602b346b9dbe1b007bed5d08bbad75f76724efbe71d5b4a57df2e526325ad5ca3d8ef8cae047044e
|
7
|
+
data.tar.gz: 660301084ed8d3d4494263abf54ac6629264b1bfa0699da5ba5022c48f613cede567e1ec3117fe689928099a1b9a430c83a30cf2f85b5c0e632812c5e09d1f1c
|
data/README.md
CHANGED
@@ -26,22 +26,25 @@ Configure default locales
|
|
26
26
|
# in /config/initializers/geo_locale.rb
|
27
27
|
GeoLocale.configure do |config|
|
28
28
|
config.default_country = "de" # set to nil or false if you want to catch fails in geolocation
|
29
|
-
config.default_locale = "en" # country->locale conversion is minimal for now, set this explicitly to ensure GeoLocale.locale
|
29
|
+
config.default_locale = "en" # country->locale conversion is minimal for now, set this explicitly to ensure GeoLocale.locale returns useful value
|
30
30
|
config.default_lcid = "en-us"
|
31
31
|
config.overrides["ee"] = "en" # hash used to override standard country codes
|
32
32
|
end
|
33
33
|
```
|
34
34
|
|
35
35
|
To get country code:
|
36
|
-
|
36
|
+
|
37
|
+
def self.country_code (ip: "")
|
38
|
+
|
37
39
|
Use in controller like so:
|
38
40
|
```ruby
|
39
|
-
GeoLocale.country_code(request.remote_ip)
|
41
|
+
GeoLocale.country_code(ip: request.remote_ip)
|
40
42
|
=> "en"
|
41
43
|
```
|
42
44
|
|
43
45
|
To get locale:
|
44
|
-
|
46
|
+
|
47
|
+
def self.locale (ip: "", country_code: "", lcid: false)
|
45
48
|
```ruby
|
46
49
|
GeoLocale.locale(country_code: "gb")
|
47
50
|
=> "en"
|
@@ -60,6 +63,8 @@ GeoLocale.locale(ip: "97.77.25.20", country_code: "lv")
|
|
60
63
|
|
61
64
|
## Contributing
|
62
65
|
|
66
|
+
Main priority is extending the country_code => locale hash in lib/geo_locale/locale.rb
|
67
|
+
|
63
68
|
1. Fork it ( https://github.com/Epigene/geo_locale/fork )
|
64
69
|
2. Create your feature branch (`git checkout -b my-new-feature`)
|
65
70
|
3. Commit your changes (`git commit -am 'Add some feature'`)
|
data/lib/geo_locale/version.rb
CHANGED