world-flags 0.4.0 → 0.4.1
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +5 -4
- data/VERSION +1 -1
- data/lib/world_flags/helper/locale.rb +14 -2
- data/world-flags.gemspec +1 -1
- metadata +2 -2
data/README.md
CHANGED
@@ -280,15 +280,16 @@ before_filter :set_locale
|
|
280
280
|
And it should set the I18n.locale appropriately, trying `params[locale], browser, ip address` in succession, defaulting to `I18n.default_locale`.
|
281
281
|
|
282
282
|
|
283
|
-
Under the covers, the `set_locale` filter uses the
|
283
|
+
Under the covers, the `set_locale` filter uses the `locale_sources`method to get the locale:
|
284
284
|
|
285
285
|
```ruby
|
286
|
-
def
|
287
|
-
[params[:locale], extract_locale_from_tld,
|
286
|
+
def locale_sources
|
287
|
+
[params[:locale], extract_locale_from_tld,
|
288
|
+
browser_locale, ip_country_code, I18n.default_locale]
|
288
289
|
end
|
289
290
|
```
|
290
291
|
|
291
|
-
Note: You can override this method to set
|
292
|
+
Note: You can override this method in your controller to set the priority order for getting the user locale. Each code will be mapped to a locale code using the `WorldFlags#locale` mapping helper method.
|
292
293
|
|
293
294
|
For each locale it will check if it is a valid locale. By default it will call `valid_locales` in the controller, which will first try `I18n.available_locales` and then fall-back to `WorldFlags#valid_locales`.
|
294
295
|
You can override this behavior by defining you custom `valid_locales` method in the controller.
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.4.
|
1
|
+
0.4.1
|
@@ -13,8 +13,13 @@ module WorldFlags
|
|
13
13
|
end
|
14
14
|
end
|
15
15
|
|
16
|
+
# ensure all country/language/domain types are mapped to their equivalent locale code
|
16
17
|
def locales
|
17
|
-
|
18
|
+
locale_sources.downcase.map {|loc| WorldFlags.locale(loc) }
|
19
|
+
end
|
20
|
+
|
21
|
+
def locale_sources
|
22
|
+
[params[:locale], extract_locale_from_tld, browser_locale, ip_country_code, I18n.default_locale]
|
18
23
|
end
|
19
24
|
|
20
25
|
# Get locale from top-level domain or return nil if such locale is not available
|
@@ -24,9 +29,16 @@ module WorldFlags
|
|
24
29
|
# 127.0.0.1 application.pl
|
25
30
|
# in your /etc/hosts file to try this out locally
|
26
31
|
def extract_locale_from_tld
|
27
|
-
parsed_locale = request.host.split('.').last
|
28
32
|
I18n.available_locales.include?(parsed_locale.to_sym) ? parsed_locale : nil
|
29
33
|
end
|
34
|
+
|
35
|
+
def parsed_locale
|
36
|
+
WorldFlags.locale(parsed_domain)
|
37
|
+
end
|
38
|
+
|
39
|
+
def parsed_domain
|
40
|
+
request.host.split('.').last
|
41
|
+
end
|
30
42
|
end
|
31
43
|
end
|
32
44
|
end
|
data/world-flags.gemspec
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: world-flags
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -194,7 +194,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
194
194
|
version: '0'
|
195
195
|
segments:
|
196
196
|
- 0
|
197
|
-
hash:
|
197
|
+
hash: 3849876865143425182
|
198
198
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
199
199
|
none: false
|
200
200
|
requirements:
|