i18n_country_select 1.1.4 → 1.2.1
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 82f8b2d7daa60b7db167828e0678b38a7dba9272
|
4
|
+
data.tar.gz: a5b19a559ae9e7b39d66da90466bcbefba1610f9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 01b24bfbfd876dcd543904ae8f9243756a1b32dfcb1bd69c2f010568ae7978fa2b162cb42901623eae5b3286f847801ba3030aeeacb54c51dd6e17c263021958
|
7
|
+
data.tar.gz: 9f1791b9c9c2d3a3daf814d69c6d2932d55cfbf5ffd0f7872e9711927a6e513b5880ae634226be1d77b0ca9d9edb7fd2f4d743c33fc91a4808a9547c4b2f7e28
|
data/README.rdoc
CHANGED
@@ -1,13 +1,11 @@
|
|
1
|
-
|
1
|
+
{<img src="https://travis-ci.org/onomojo/i18n_country_select.svg?branch=master" alt="Build Status" />}[https://travis-ci.org/onomojo/i18n_country_select]
|
2
2
|
|
3
|
-
A simple country code select helper with I18n translations for the countries. Works exactly the same as country_select but uses country codes instead and has i18n translations for the country names.
|
4
3
|
|
5
|
-
|
4
|
+
== Country Code Select
|
6
5
|
|
7
|
-
|
6
|
+
A simple country code select helper with I18n translations for the countries. Works exactly the same as country_select but uses country codes instead and has i18n translations for the country names.
|
8
7
|
|
9
|
-
|
10
|
-
* Ruby 1.9.2+
|
8
|
+
NOTE: The old country_code_select repository that this one was forked from is outdated and no longer maintained. This i18_country_select repository is the most current.
|
11
9
|
|
12
10
|
== Installation
|
13
11
|
Put the following in your Gemfile
|
@@ -22,43 +20,15 @@ Simple use supplying model and attribute as parameters:
|
|
22
20
|
Supplying priority countries to be placed at the top of the list:
|
23
21
|
|
24
22
|
country_code_select(:user, :country, [[ 'US', 'United States' ], [ 'CA', 'Canada' ]])
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
* Brad Carson from Base 3 Media
|
31
|
-
* (https://github.com/dmilisic)
|
32
|
-
* Andreas Wolff (https://github.com/rubyphunk)
|
33
|
-
* Valentin Rabanelly (https://github.com/vjrabanelly)
|
34
|
-
* Karl-Petter Åkesson (https://github.com/karl-petter)
|
35
|
-
* Hélder Tavares da Silva (https://github.com/heldersilva)
|
36
|
-
* Marten Klitzke (https://github.com/mortik)
|
37
|
-
* Victor D. (https://github.com/V1c70r)
|
38
|
-
* Alexey Degtyarev (https://github.com/alexhifer)
|
39
|
-
* Björn Wilmsmann (https://github.com/BjoernKW)
|
40
|
-
* https://github.com/durandom
|
41
|
-
* Stefan Slaveykov (https://github.com/wizardone)
|
42
|
-
* Leonardo D. Schlossmacher (https://github.com/leods92)
|
23
|
+
|
24
|
+
Specifying different selected value:
|
25
|
+
|
26
|
+
country_code_select(:user, :country, [], selected: 'CA')
|
27
|
+
|
43
28
|
|
44
29
|
Based on the deprecated country_code_select by: Russ Smith (russ@bashme.org) and Frank Wambutt (frank@mo-stud.io)
|
45
30
|
|
46
|
-
== Version History
|
47
|
-
* 1.1.4 - Fixed options being ignored when running Rails 4
|
48
|
-
* 1.1.3 - Removed Netherlands Antilles. Added Bonaire, Curacao, Sint Maarten, and South Sudan
|
49
|
-
* 1.1.2 - Adding Thread variable to speed up rendering
|
50
|
-
* 1.1.1 - Bumping required version of country translations
|
51
|
-
* 1.1.0 - Rails 4 support
|
52
|
-
* 1.0.19 - Added Macedonia
|
53
|
-
* 1.0.18 - Fixed translated sorting
|
54
|
-
* 1.0.17 - Removing duplicate country code IE
|
55
|
-
* 1.0.16 - Removing unnecessary value attribute and corrected spelling error on the include_blank option tag
|
56
|
-
* 1.0.15 - Removing more duplicate country codes
|
57
|
-
* 1.0.14 - Removing duplicate country codes and adding Norway
|
58
|
-
* 1.0.13 - Ignore missing translations from i18n-country-translations
|
59
|
-
* 1.0.12 - Adds the ability to specify text to use in a blank option
|
60
31
|
|
61
32
|
== License
|
62
33
|
|
63
34
|
MIT or GPL
|
64
|
-
|
@@ -1,7 +1,5 @@
|
|
1
1
|
module I18nCountrySelect
|
2
2
|
module InstanceTag
|
3
|
-
include Countries
|
4
|
-
|
5
3
|
def to_country_code_select_tag(priority_countries, html_options = {}, options = {})
|
6
4
|
# Rails 4 stores options sent when creating an InstanceTag.
|
7
5
|
# Let's use them!
|
@@ -12,7 +10,7 @@ module I18nCountrySelect
|
|
12
10
|
|
13
11
|
# Adapted from Rails country_select. Just uses country codes instead of full names.
|
14
12
|
def country_code_select(priority_countries, options, html_options)
|
15
|
-
selected = object.
|
13
|
+
selected = options.fetch(:selected, object.respond_to?(@method_name) ? object.send(@method_name) : nil)
|
16
14
|
|
17
15
|
countries = ""
|
18
16
|
|
@@ -26,7 +24,13 @@ module I18nCountrySelect
|
|
26
24
|
countries += "<option value=\"\" disabled=\"disabled\">-------------</option>\n"
|
27
25
|
end
|
28
26
|
|
29
|
-
|
27
|
+
translations = if options[:exclude].present?
|
28
|
+
country_translations.reject { |ct| options[:exclude].include? ct[1] }
|
29
|
+
else
|
30
|
+
country_translations
|
31
|
+
end
|
32
|
+
|
33
|
+
countries = countries + options_for_select(translations, selected)
|
30
34
|
|
31
35
|
html_options = html_options.stringify_keys
|
32
36
|
add_default_name_and_id(html_options)
|
@@ -37,7 +41,7 @@ module I18nCountrySelect
|
|
37
41
|
def country_translations
|
38
42
|
Thread.current[:country_translations] ||= {}
|
39
43
|
Thread.current[:country_translations][I18n.locale] ||= begin
|
40
|
-
|
44
|
+
(I18n.t 'countries').keys.map do |code|
|
41
45
|
translation = I18n.t(code, :scope => :countries, :default => 'missing')
|
42
46
|
translation == 'missing' ? nil : [translation, code]
|
43
47
|
end.compact.sort_by do |translation, code|
|
data/lib/i18n_country_select.rb
CHANGED
@@ -2,15 +2,14 @@ require 'unicode_utils/canonical_decomposition'
|
|
2
2
|
require 'unicode_utils/general_category'
|
3
3
|
|
4
4
|
require "i18n-country-translations"
|
5
|
-
require "i18n_country_select/countries"
|
6
5
|
require "i18n_country_select/form_builder"
|
7
6
|
require "i18n_country_select/form_helpers"
|
8
7
|
require "i18n_country_select/instance_tag"
|
9
8
|
|
10
9
|
ActionView::Base.send(:include, I18nCountrySelect::FormHelpers)
|
11
10
|
if Rails::VERSION::MAJOR >= 4
|
12
|
-
ActionView::Helpers::
|
11
|
+
ActionView::Helpers::Tags::Select.send(:include, I18nCountrySelect::InstanceTag)
|
13
12
|
else
|
14
13
|
ActionView::Helpers::InstanceTag.send(:include, I18nCountrySelect::InstanceTag)
|
15
14
|
end
|
16
|
-
ActionView::Helpers::FormBuilder.send(:include, I18nCountrySelect::FormBuilder)
|
15
|
+
ActionView::Helpers::FormBuilder.send(:include, I18nCountrySelect::FormBuilder)
|
metadata
CHANGED
@@ -1,125 +1,110 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: i18n_country_select
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1
|
4
|
+
version: 1.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brian McQuay (brian@onomojo.com)
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-02-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: i18n
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - ~>
|
17
|
+
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
19
|
+
version: 0.9.3
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - ~>
|
24
|
+
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version:
|
26
|
+
version: 0.9.3
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: i18n-country-translations
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - ~>
|
31
|
+
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '1.0'
|
34
|
-
- -
|
34
|
+
- - ">="
|
35
35
|
- !ruby/object:Gem::Version
|
36
|
-
version: 1.0
|
36
|
+
version: 1.3.0
|
37
37
|
type: :runtime
|
38
38
|
prerelease: false
|
39
39
|
version_requirements: !ruby/object:Gem::Requirement
|
40
40
|
requirements:
|
41
|
-
- - ~>
|
41
|
+
- - "~>"
|
42
42
|
- !ruby/object:Gem::Version
|
43
43
|
version: '1.0'
|
44
|
-
- -
|
44
|
+
- - ">="
|
45
45
|
- !ruby/object:Gem::Version
|
46
|
-
version: 1.0
|
46
|
+
version: 1.3.0
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: unicode_utils
|
49
49
|
requirement: !ruby/object:Gem::Requirement
|
50
50
|
requirements:
|
51
|
-
- - ~>
|
51
|
+
- - "~>"
|
52
52
|
- !ruby/object:Gem::Version
|
53
53
|
version: '1.0'
|
54
|
-
- -
|
54
|
+
- - ">="
|
55
55
|
- !ruby/object:Gem::Version
|
56
56
|
version: 1.0.0
|
57
57
|
type: :runtime
|
58
58
|
prerelease: false
|
59
59
|
version_requirements: !ruby/object:Gem::Requirement
|
60
60
|
requirements:
|
61
|
-
- - ~>
|
61
|
+
- - "~>"
|
62
62
|
- !ruby/object:Gem::Version
|
63
63
|
version: '1.0'
|
64
|
-
- -
|
64
|
+
- - ">="
|
65
65
|
- !ruby/object:Gem::Version
|
66
66
|
version: 1.0.0
|
67
67
|
- !ruby/object:Gem::Dependency
|
68
68
|
name: rails
|
69
69
|
requirement: !ruby/object:Gem::Requirement
|
70
70
|
requirements:
|
71
|
-
- - ~>
|
71
|
+
- - "~>"
|
72
72
|
- !ruby/object:Gem::Version
|
73
|
-
version: '
|
74
|
-
- -
|
73
|
+
version: '4.0'
|
74
|
+
- - ">="
|
75
75
|
- !ruby/object:Gem::Version
|
76
|
-
version:
|
76
|
+
version: 4.0.0
|
77
77
|
type: :development
|
78
78
|
prerelease: false
|
79
79
|
version_requirements: !ruby/object:Gem::Requirement
|
80
80
|
requirements:
|
81
|
-
- - ~>
|
81
|
+
- - "~>"
|
82
82
|
- !ruby/object:Gem::Version
|
83
|
-
version: '
|
84
|
-
- -
|
83
|
+
version: '4.0'
|
84
|
+
- - ">="
|
85
85
|
- !ruby/object:Gem::Version
|
86
|
-
version:
|
86
|
+
version: 4.0.0
|
87
87
|
- !ruby/object:Gem::Dependency
|
88
88
|
name: rspec-rails
|
89
89
|
requirement: !ruby/object:Gem::Requirement
|
90
90
|
requirements:
|
91
|
-
- - ~>
|
91
|
+
- - "~>"
|
92
92
|
- !ruby/object:Gem::Version
|
93
|
-
version: '
|
94
|
-
- -
|
93
|
+
version: '3.5'
|
94
|
+
- - ">="
|
95
95
|
- !ruby/object:Gem::Version
|
96
|
-
version:
|
96
|
+
version: 3.5.2
|
97
97
|
type: :development
|
98
98
|
prerelease: false
|
99
99
|
version_requirements: !ruby/object:Gem::Requirement
|
100
100
|
requirements:
|
101
|
-
- - ~>
|
101
|
+
- - "~>"
|
102
102
|
- !ruby/object:Gem::Version
|
103
|
-
version: '
|
104
|
-
- -
|
103
|
+
version: '3.5'
|
104
|
+
- - ">="
|
105
105
|
- !ruby/object:Gem::Version
|
106
|
-
version:
|
107
|
-
- !ruby/object:Gem::Dependency
|
108
|
-
name: spork
|
109
|
-
requirement: !ruby/object:Gem::Requirement
|
110
|
-
requirements:
|
111
|
-
- - ~>
|
112
|
-
- !ruby/object:Gem::Version
|
113
|
-
version: 1.0rc
|
114
|
-
type: :development
|
115
|
-
prerelease: false
|
116
|
-
version_requirements: !ruby/object:Gem::Requirement
|
117
|
-
requirements:
|
118
|
-
- - ~>
|
119
|
-
- !ruby/object:Gem::Version
|
120
|
-
version: 1.0rc
|
106
|
+
version: 3.5.2
|
121
107
|
description: A simple country code select helper that works with I18n translations.
|
122
|
-
Works exactly the same as country_select but uses country codes instead.
|
123
108
|
email: brian@onomojo.com
|
124
109
|
executables: []
|
125
110
|
extensions: []
|
@@ -128,7 +113,6 @@ files:
|
|
128
113
|
- MIT-LICENSE
|
129
114
|
- README.rdoc
|
130
115
|
- lib/i18n_country_select.rb
|
131
|
-
- lib/i18n_country_select/countries.rb
|
132
116
|
- lib/i18n_country_select/form_builder.rb
|
133
117
|
- lib/i18n_country_select/form_helpers.rb
|
134
118
|
- lib/i18n_country_select/instance_tag.rb
|
@@ -136,7 +120,7 @@ files:
|
|
136
120
|
homepage: https://github.com/onomojo/i18n_country_select
|
137
121
|
licenses:
|
138
122
|
- MIT
|
139
|
-
- GPL-
|
123
|
+
- GPL-3.0
|
140
124
|
metadata: {}
|
141
125
|
post_install_message:
|
142
126
|
rdoc_options: []
|
@@ -144,17 +128,17 @@ require_paths:
|
|
144
128
|
- lib
|
145
129
|
required_ruby_version: !ruby/object:Gem::Requirement
|
146
130
|
requirements:
|
147
|
-
- -
|
131
|
+
- - ">="
|
148
132
|
- !ruby/object:Gem::Version
|
149
133
|
version: '0'
|
150
134
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
151
135
|
requirements:
|
152
|
-
- -
|
136
|
+
- - ">="
|
153
137
|
- !ruby/object:Gem::Version
|
154
138
|
version: 1.3.5
|
155
139
|
requirements: []
|
156
|
-
rubyforge_project:
|
157
|
-
rubygems_version: 2.
|
140
|
+
rubyforge_project: "[none]"
|
141
|
+
rubygems_version: 2.5.2
|
158
142
|
signing_key:
|
159
143
|
specification_version: 4
|
160
144
|
summary: I18n country select helper
|
@@ -1,28 +0,0 @@
|
|
1
|
-
module I18nCountrySelect
|
2
|
-
module Countries
|
3
|
-
COUNTRY_CODES = 'AF','AL','DZ','AS','AD','AO','AI','AQ','AG','AR',
|
4
|
-
'AM','AW','AU','AT','AZ','BS','BH','BD','BB','BY',
|
5
|
-
'BE','BZ','BJ','BM','BO','BA','BW','BV','BR','IO',
|
6
|
-
'BN','BG','BF','BI','BT','KH','CM','CA','CV','KY',
|
7
|
-
'CF','TD','CL','CN','CX','CC','CO','KM','CG','CK',
|
8
|
-
'CR','HR','CU','CY','CZ','CS','DK','DJ','DM','DO',
|
9
|
-
'EC','EG','SV','GQ','EE','ET','FK','FO','FJ','FI',
|
10
|
-
'FR','FX','TF','GA','GM','GE','DE','GH','GI','GB',
|
11
|
-
'GR','GL','GD','GP','GU','GT','GN','GW','GY','GF',
|
12
|
-
'HT','HM','HN','HK','HU','IS','IN','ID','IR','IQ',
|
13
|
-
'IE','IL','IT','CI','JM','JP','JO','KZ','KE','KG',
|
14
|
-
'KI','KP','KR','KW','LA','LV','LB','LS','LR','LY',
|
15
|
-
'LI','LT','LU','MO','MK','MG','MW','MY','MV','ML',
|
16
|
-
'MT','MH','MQ','MR','MU','MX','FM','MD','MC','MN',
|
17
|
-
'MS','MA','MZ','MM','NA','NR','NO','NP','NL','BQ',
|
18
|
-
'NC','NZ','NI','NE','NG','NU','NF','MP','OM','PK',
|
19
|
-
'PW','PA','PG','PY','PE','PH','PN','PL','PF','PT',
|
20
|
-
'PR','QA','RE','RO','RS','RU','RW','LC','WS','SM',
|
21
|
-
'SA','SN','SC','SL','SG','SK','SI','SB','SO','ZA',
|
22
|
-
'ES','LK','SH','PM','ST','KN','VC','SD','SR','SJ',
|
23
|
-
'SZ','SE','CH','SY','TJ','TW','TZ','TH','TG','TK',
|
24
|
-
'TO','TT','TN','TR','TM','TC','TV','UG','UA','AE',
|
25
|
-
'US','UY','UM','UZ','VU','VA','VE','VN','VG','VI',
|
26
|
-
'WF','EH','YE','ZM','ZW','CW','SX','SS'
|
27
|
-
end
|
28
|
-
end
|