localized_country_select 0.9.11 → 0.10.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/README.rdoc +11 -5
- data/lib/localized_country_select.rb +7 -21
- data/lib/localized_country_select/version.rb +1 -1
- data/locale/cz.rb +1 -3
- data/locale/en.rb +1 -3
- data/test/localized_country_select_test.rb +3 -5
- metadata +14 -35
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 1d99659f08bcc782b281fb10a20cf41e46a0249a0a6d7a811e831505f1bbf758
|
4
|
+
data.tar.gz: d180d2b3657226eb58e6b0b0d7a4ac49895a160d5766fdcd965edf0d7ef5e854
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: c497d965af1e14c3baa5a4725273a654df02ba2244adeb480276eb24d272cee4cbe6b11ef6138e230064e6441e8a3526230c0e7308ee4d01b0aa91da3dd99353
|
7
|
+
data.tar.gz: 4d06428996b60c8253f641e4f0d5dccc6e7bd9fcf37adaedc4059feb7c80e940172dbb3b98113058a19d507f40a1cf7feb104a9a6b8aae2454833a08192c3901
|
data/README.rdoc
CHANGED
@@ -11,18 +11,24 @@ You can easily translate country codes in your application like this:
|
|
11
11
|
|
12
12
|
<%= I18n.t @user.country, :scope => 'countries' %>
|
13
13
|
|
14
|
-
Comes with a Rake task <tt>
|
14
|
+
Comes with a Rake task <tt>rails import:country_select LOCALE=de</tt> for importing country names
|
15
15
|
from Unicode.org's CLDR repository (http://www.unicode.org/cldr/data/charts/summary/root.html)
|
16
16
|
Don't forget to restart the application when you add new locale.
|
17
17
|
|
18
18
|
ActionView helper code is adapted from Rails' default +country_select+ plugin (previously in core).
|
19
19
|
See http://github.com/rails/country_select/tree/master/lib/country_select.rb
|
20
20
|
|
21
|
+
== Rails 5 / Rails 6
|
22
|
+
|
23
|
+
In your Gemfile add:
|
24
|
+
|
25
|
+
gem 'localized_country_select', '~> 0.10.0'
|
26
|
+
|
21
27
|
== Rails 3 / Rails 4
|
22
28
|
|
23
29
|
In your Gemfile add:
|
24
30
|
|
25
|
-
gem 'localized_country_select', '
|
31
|
+
gem 'localized_country_select', '= 0.9.11'
|
26
32
|
|
27
33
|
== Rails 2.3
|
28
34
|
|
@@ -35,7 +41,7 @@ In environment.rb add
|
|
35
41
|
|
36
42
|
Show full country names:
|
37
43
|
|
38
|
-
<%= localized_country_select(:user, :country, [], {:
|
44
|
+
<%= localized_country_select(:user, :country, [], {include_blank: 'Please choose...'}) %>
|
39
45
|
|
40
46
|
will become:
|
41
47
|
|
@@ -50,7 +56,7 @@ will become:
|
|
50
56
|
|
51
57
|
Show only country codes:
|
52
58
|
|
53
|
-
<%= localized_country_select(:user, :country, [], {:
|
59
|
+
<%= localized_country_select(:user, :country, [], {include_blank: 'Please choose...', description: :abbreviated}) %>
|
54
60
|
|
55
61
|
will become:
|
56
62
|
|
@@ -68,7 +74,7 @@ for the <tt>en</tt> locale.
|
|
68
74
|
|
69
75
|
You can exclude countries by code using the exclude option (a single code or an array of country codes):
|
70
76
|
|
71
|
-
localized_country_select(:user, :country, [], {:
|
77
|
+
localized_country_select(:user, :country, [], {exclude: [:ZZ, :US]})
|
72
78
|
|
73
79
|
|
74
80
|
== Formtastic and SimpleForm
|
@@ -26,7 +26,7 @@ module LocalizedCountrySelect
|
|
26
26
|
def localized_countries_array(options={})
|
27
27
|
exclude = Array(options[:exclude]).map {|code| code.to_s.upcase }
|
28
28
|
|
29
|
-
if(options[:description]
|
29
|
+
if(options[:description] == :abbreviated)
|
30
30
|
I18n.translate(:countries).map { |key, value| [key.to_s.upcase] if !exclude.include?(key.to_s.upcase) }
|
31
31
|
else
|
32
32
|
I18n.translate(:countries).map { |key, value| [value, key.to_s.upcase] if !exclude.include?(key.to_s.upcase) }
|
@@ -36,8 +36,8 @@ module LocalizedCountrySelect
|
|
36
36
|
# == Example
|
37
37
|
# priority_countries_array([:TW, :CN])
|
38
38
|
# # => [ ['Taiwan', 'TW'], ['China', 'CN'] ]
|
39
|
-
def priority_countries_array(country_codes=[],options={})
|
40
|
-
if(options[:description]
|
39
|
+
def priority_countries_array(country_codes=[], options={})
|
40
|
+
if(options[:description] == :abbreviated)
|
41
41
|
country_codes.map { |code| [code.to_s.upcase] }
|
42
42
|
else
|
43
43
|
countries = I18n.translate(:countries)
|
@@ -57,13 +57,7 @@ module ActionView
|
|
57
57
|
# Country codes listed as an array of symbols in +priority_countries+ argument will be listed first
|
58
58
|
# TODO : Implement pseudo-named args with a hash, not the "somebody said PHP?" multiple args sillines
|
59
59
|
def localized_country_select(object, method, priority_countries = nil, options = {}, html_options = {})
|
60
|
-
tag =
|
61
|
-
ActionView::Helpers::InstanceTag.instance_method(:initialize).arity != 0
|
62
|
-
|
63
|
-
InstanceTag.new(object, method, self, options.delete(:object))
|
64
|
-
else
|
65
|
-
CountrySelect.new(object, method, self, options)
|
66
|
-
end
|
60
|
+
tag = CountrySelect.new(object, method, self, options)
|
67
61
|
|
68
62
|
tag.to_localized_country_select_tag(priority_countries, options, html_options)
|
69
63
|
end
|
@@ -99,7 +93,6 @@ module ActionView
|
|
99
93
|
def to_localized_country_select_tag(priority_countries, options, html_options)
|
100
94
|
html_options = html_options.stringify_keys
|
101
95
|
add_default_name_and_id(html_options)
|
102
|
-
value = value(object)
|
103
96
|
content_tag("select",
|
104
97
|
add_options(
|
105
98
|
localized_country_options_for_select(value, priority_countries, options).html_safe,
|
@@ -109,20 +102,13 @@ module ActionView
|
|
109
102
|
end
|
110
103
|
end
|
111
104
|
|
112
|
-
|
113
|
-
|
114
|
-
class InstanceTag
|
115
|
-
include ToCountrySelectTag
|
116
|
-
end
|
117
|
-
else
|
118
|
-
class CountrySelect < Tags::Base
|
119
|
-
include ToCountrySelectTag
|
120
|
-
end
|
105
|
+
class CountrySelect < Tags::Base
|
106
|
+
include ToCountrySelectTag
|
121
107
|
end
|
122
108
|
|
123
109
|
class FormBuilder
|
124
110
|
def localized_country_select(method, priority_countries = nil, options = {}, html_options = {})
|
125
|
-
@template.localized_country_select(@object_name, method, priority_countries, options.merge(:
|
111
|
+
@template.localized_country_select(@object_name, method, priority_countries, options.merge(object: @object), html_options)
|
126
112
|
end
|
127
113
|
alias_method :country_select, :localized_country_select
|
128
114
|
end
|
data/locale/cz.rb
CHANGED
@@ -95,7 +95,6 @@
|
|
95
95
|
:GU => "Guam",
|
96
96
|
:GW => "Guinea-Bissau",
|
97
97
|
:GY => "Guyana",
|
98
|
-
:HK => "Hongkong, zvláštní administrativní oblast Číny",
|
99
98
|
:HK => "Hongkong",
|
100
99
|
:HM => "Ostrovy Heard a McDonald",
|
101
100
|
:HN => "Honduras",
|
@@ -149,7 +148,6 @@
|
|
149
148
|
:ML => "Mali",
|
150
149
|
:MM => "Myanmar",
|
151
150
|
:MN => "Mongolsko",
|
152
|
-
:MO => "Zvláštní administrativní oblast Číny Macao",
|
153
151
|
:MO => "Macao",
|
154
152
|
:MP => "Severní Mariany",
|
155
153
|
:MQ => "Martinik",
|
@@ -253,7 +251,7 @@
|
|
253
251
|
:ZM => "Zambie",
|
254
252
|
:ZW => "Zimbabwe",
|
255
253
|
:ZZ => "Neznámá nebo neplatná oblast",
|
256
|
-
}
|
254
|
+
}
|
257
255
|
|
258
256
|
}
|
259
257
|
}
|
data/locale/en.rb
CHANGED
@@ -100,7 +100,6 @@
|
|
100
100
|
:GU => "Guam",
|
101
101
|
:GW => "Guinea-Bissau",
|
102
102
|
:GY => "Guyana",
|
103
|
-
:HK => "Hong Kong SAR China",
|
104
103
|
:HK => "Hong Kong",
|
105
104
|
:HM => "Heard Island and McDonald Islands",
|
106
105
|
:HN => "Honduras",
|
@@ -156,7 +155,6 @@
|
|
156
155
|
:ML => "Mali",
|
157
156
|
:MM => "Myanmar",
|
158
157
|
:MN => "Mongolia",
|
159
|
-
:MO => "Macau SAR China",
|
160
158
|
:MO => "Macau",
|
161
159
|
:MP => "Northern Mariana Islands",
|
162
160
|
:MQ => "Martinique",
|
@@ -269,7 +267,7 @@
|
|
269
267
|
:ZM => "Zambia",
|
270
268
|
:ZW => "Zimbabwe",
|
271
269
|
:ZZ => "Unknown or Invalid Region",
|
272
|
-
}
|
270
|
+
}
|
273
271
|
|
274
272
|
}
|
275
273
|
}
|
@@ -34,17 +34,15 @@ class LocalizedCountrySelectTest < Test::Unit::TestCase
|
|
34
34
|
end
|
35
35
|
|
36
36
|
def test_should_return_select_tag_with_proper_name_for_object
|
37
|
-
# puts localized_country_select(:user, :country)
|
38
37
|
assert localized_country_select(:user, :country) =~
|
39
|
-
Regexp.new(Regexp.escape('<select
|
38
|
+
Regexp.new(Regexp.escape('<select name="user[country]" id="user_country">')),
|
40
39
|
"Should have proper name for object"
|
41
40
|
end
|
42
41
|
|
43
42
|
def test_should_return_select_tag_with_proper_name
|
44
|
-
# puts localized_country_select_tag( "competition_submission[data][citizenship]", nil)
|
45
43
|
assert localized_country_select_tag( "competition_submission[data][citizenship]", nil) =~
|
46
44
|
Regexp.new(
|
47
|
-
Regexp.escape('<select
|
45
|
+
Regexp.escape('<select name="competition_submission[data][citizenship]" id="competition_submission_data_citizenship">') ),
|
48
46
|
"Should have proper name"
|
49
47
|
end
|
50
48
|
|
@@ -70,7 +68,7 @@ class LocalizedCountrySelectTest < Test::Unit::TestCase
|
|
70
68
|
|
71
69
|
def test_excludes_countries
|
72
70
|
assert_nothing_raised { LocalizedCountrySelect::localized_countries_array(:exclude => :ZZ) }
|
73
|
-
|
71
|
+
|
74
72
|
assert_block do
|
75
73
|
not LocalizedCountrySelect::localized_countries_array(:exclude => :ZZ).any? {|country| country.last == "ZZ"}
|
76
74
|
end
|
metadata
CHANGED
@@ -1,8 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: localized_country_select
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
5
|
-
prerelease:
|
4
|
+
version: 0.10.0
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- karmi
|
@@ -15,42 +14,24 @@ authors:
|
|
15
14
|
autorequire:
|
16
15
|
bindir: bin
|
17
16
|
cert_chain: []
|
18
|
-
date:
|
17
|
+
date: 2019-12-27 00:00:00.000000000 Z
|
19
18
|
dependencies:
|
20
19
|
- !ruby/object:Gem::Dependency
|
21
20
|
name: actionpack
|
22
21
|
requirement: !ruby/object:Gem::Requirement
|
23
|
-
none: false
|
24
22
|
requirements:
|
25
|
-
- -
|
23
|
+
- - ">="
|
26
24
|
- !ruby/object:Gem::Version
|
27
|
-
version: '
|
25
|
+
version: '5.0'
|
28
26
|
type: :runtime
|
29
27
|
prerelease: false
|
30
28
|
version_requirements: !ruby/object:Gem::Requirement
|
31
|
-
none: false
|
32
29
|
requirements:
|
33
|
-
- -
|
30
|
+
- - ">="
|
34
31
|
- !ruby/object:Gem::Version
|
35
|
-
version: '
|
36
|
-
|
37
|
-
|
38
|
-
requirement: !ruby/object:Gem::Requirement
|
39
|
-
none: false
|
40
|
-
requirements:
|
41
|
-
- - ! '>='
|
42
|
-
- !ruby/object:Gem::Version
|
43
|
-
version: 2.0.0
|
44
|
-
type: :development
|
45
|
-
prerelease: false
|
46
|
-
version_requirements: !ruby/object:Gem::Requirement
|
47
|
-
none: false
|
48
|
-
requirements:
|
49
|
-
- - ! '>='
|
50
|
-
- !ruby/object:Gem::Version
|
51
|
-
version: 2.0.0
|
52
|
-
description: ! ' Localized "country_select" helper with Rake task for downloading
|
53
|
-
locales from Unicode.org''s CLDR '
|
32
|
+
version: '5.0'
|
33
|
+
description: ' Localized "country_select" helper with Rake task for downloading locales
|
34
|
+
from Unicode.org''s CLDR '
|
54
35
|
email:
|
55
36
|
-
|
56
37
|
- maciej@litwiniuk.net
|
@@ -63,7 +44,7 @@ executables: []
|
|
63
44
|
extensions: []
|
64
45
|
extra_rdoc_files: []
|
65
46
|
files:
|
66
|
-
- .gitignore
|
47
|
+
- ".gitignore"
|
67
48
|
- MIT-LICENSE
|
68
49
|
- README.rdoc
|
69
50
|
- Rakefile
|
@@ -79,27 +60,25 @@ files:
|
|
79
60
|
homepage: https://github.com/mlitwiniuk/localized_country_select
|
80
61
|
licenses:
|
81
62
|
- MIT
|
63
|
+
metadata: {}
|
82
64
|
post_install_message:
|
83
65
|
rdoc_options: []
|
84
66
|
require_paths:
|
85
67
|
- lib
|
86
68
|
required_ruby_version: !ruby/object:Gem::Requirement
|
87
|
-
none: false
|
88
69
|
requirements:
|
89
|
-
- -
|
70
|
+
- - ">="
|
90
71
|
- !ruby/object:Gem::Version
|
91
72
|
version: '0'
|
92
73
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
93
|
-
none: false
|
94
74
|
requirements:
|
95
|
-
- -
|
75
|
+
- - ">="
|
96
76
|
- !ruby/object:Gem::Version
|
97
77
|
version: '0'
|
98
78
|
requirements: []
|
99
|
-
|
100
|
-
rubygems_version: 1.8.23.2
|
79
|
+
rubygems_version: 3.0.3
|
101
80
|
signing_key:
|
102
|
-
specification_version:
|
81
|
+
specification_version: 4
|
103
82
|
summary: Localized "country_select" helper with Rake task for downloading locales
|
104
83
|
from Unicode.org's CLDR
|
105
84
|
test_files:
|