world-flags 0.4.0 → 0.4.1

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.
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 following method to get the locale:
283
+ Under the covers, the `set_locale` filter uses the `locale_sources`method to get the locale:
284
284
 
285
285
  ```ruby
286
- def locales
287
- [params[:locale], extract_locale_from_tld, browser_locale, ip_country_code, I18n.default_locale].downcase
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 which the priority order for getting the user locale.
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.0
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
- [params[:locale], extract_locale_from_tld, browser_locale, ip_country_code, I18n.default_locale].downcase
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
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "world-flags"
8
- s.version = "0.4.0"
8
+ s.version = "0.4.1"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Kristian Mandrup"]
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.0
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: -1443906191312410055
197
+ hash: 3849876865143425182
198
198
  required_rubygems_version: !ruby/object:Gem::Requirement
199
199
  none: false
200
200
  requirements: