i18n_country_select 1.0.8 → 1.0.9
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/i18n_country_select.rb +1 -0
- data/lib/i18n_country_select/instance_tag.rb +19 -19
- data/lib/i18n_country_select/version.rb +1 -1
- metadata +24 -13
data/lib/i18n_country_select.rb
CHANGED
@@ -1,32 +1,32 @@
|
|
1
1
|
module I18nCountrySelect
|
2
|
-
|
3
|
-
|
2
|
+
module InstanceTag
|
3
|
+
include Countries
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
|
5
|
+
def to_country_code_select_tag(priority_countries, options = {}, html_options = {})
|
6
|
+
country_code_select(priority_countries, options, html_options)
|
7
|
+
end
|
8
8
|
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
# Adapted from Rails country_select. Just uses country codes instead of full names.
|
10
|
+
def country_code_select(priority_countries, options, html_options)
|
11
|
+
selected = object.send(@method_name)
|
12
12
|
|
13
|
-
country_translations = COUNTRY_CODES.map{|code| [I18n.t(code, :scope => :countries), code]}
|
13
|
+
country_translations = COUNTRY_CODES.map{|code| [I18n.t(code, :scope => :countries), code]}.sort_alphabetical_by(&:first)
|
14
14
|
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
15
|
+
countries = ""
|
16
|
+
if priority_countries
|
17
|
+
countries += options_for_select(priority_countries, selected)
|
18
|
+
countries += "<option value=\"\" disabled=\"disabled\">-------------</option>\n"
|
19
19
|
elsif options[:include_blank]
|
20
20
|
countries += "<option value=\"\">" + options[:include_blank] + "</options>\n"
|
21
|
-
|
22
|
-
|
21
|
+
countries += "<option value=\"\" disabled=\"disabled\">-------------</option>\n"
|
22
|
+
end
|
23
23
|
|
24
|
-
|
25
|
-
|
24
|
+
countries = countries + options_for_select(country_translations, selected)
|
25
|
+
|
26
26
|
html_options = html_options.stringify_keys
|
27
27
|
add_default_name_and_id(html_options)
|
28
28
|
|
29
29
|
content_tag(:select, countries.html_safe, html_options)
|
30
|
-
|
31
|
-
|
30
|
+
end
|
31
|
+
end
|
32
32
|
end
|
metadata
CHANGED
@@ -1,19 +1,19 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: i18n_country_select
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.9
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
|
-
- Russ Smith (russ@bashme.org), Brian McQuay (brian@onomojo.com)
|
8
|
+
- Russ Smith (russ@bashme.org), Brian McQuay (brian@onomojo.com), Frank Wambutt (frank@mo-stud.io)
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-04-
|
12
|
+
date: 2012-04-18 00:00:00.000000000Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: i18n
|
16
|
-
requirement: &
|
16
|
+
requirement: &70286614267140 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ~>
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '0.5'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70286614267140
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: i18n-country-translations
|
27
|
-
requirement: &
|
27
|
+
requirement: &70286614266680 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,10 +32,21 @@ dependencies:
|
|
32
32
|
version: 0.0.5
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *70286614266680
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
name: sort_alphabetical
|
38
|
+
requirement: &70286614266220 !ruby/object:Gem::Requirement
|
39
|
+
none: false
|
40
|
+
requirements:
|
41
|
+
- - ! '>='
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: 0.1.3
|
44
|
+
type: :runtime
|
45
|
+
prerelease: false
|
46
|
+
version_requirements: *70286614266220
|
36
47
|
- !ruby/object:Gem::Dependency
|
37
48
|
name: rails
|
38
|
-
requirement: &
|
49
|
+
requirement: &70286614301580 !ruby/object:Gem::Requirement
|
39
50
|
none: false
|
40
51
|
requirements:
|
41
52
|
- - ! '>='
|
@@ -43,10 +54,10 @@ dependencies:
|
|
43
54
|
version: 3.0.0
|
44
55
|
type: :development
|
45
56
|
prerelease: false
|
46
|
-
version_requirements: *
|
57
|
+
version_requirements: *70286614301580
|
47
58
|
- !ruby/object:Gem::Dependency
|
48
59
|
name: rspec-rails
|
49
|
-
requirement: &
|
60
|
+
requirement: &70286614301120 !ruby/object:Gem::Requirement
|
50
61
|
none: false
|
51
62
|
requirements:
|
52
63
|
- - ! '>='
|
@@ -54,10 +65,10 @@ dependencies:
|
|
54
65
|
version: 2.7.0
|
55
66
|
type: :development
|
56
67
|
prerelease: false
|
57
|
-
version_requirements: *
|
68
|
+
version_requirements: *70286614301120
|
58
69
|
- !ruby/object:Gem::Dependency
|
59
70
|
name: spork
|
60
|
-
requirement: &
|
71
|
+
requirement: &70286614300660 !ruby/object:Gem::Requirement
|
61
72
|
none: false
|
62
73
|
requirements:
|
63
74
|
- - ~>
|
@@ -65,7 +76,7 @@ dependencies:
|
|
65
76
|
version: 1.0rc
|
66
77
|
type: :development
|
67
78
|
prerelease: false
|
68
|
-
version_requirements: *
|
79
|
+
version_requirements: *70286614300660
|
69
80
|
description: A simple country code select helper that works with I18n translations.
|
70
81
|
Works exactly the same as country_select but uses country codes instead.
|
71
82
|
email: brian@onomojo.com
|