localized_country_select 0.0.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/.gitignore +3 -0
- data/MIT-LICENSE +20 -0
- data/README.rdoc +59 -0
- data/Rakefile +41 -0
- data/init.rb +5 -0
- data/install.rb +4 -0
- data/lib/localized_country_select.rb +106 -0
- data/lib/tasks/localized_country_select_tasks.rake +91 -0
- data/locale/en.rb +250 -0
- data/locale/ru.rb +250 -0
- data/test/localized_country_select_test.rb +117 -0
- data/uninstall.rb +1 -0
- metadata +81 -0
data/.gitignore
ADDED
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2008 [name of plugin creator]
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
ADDED
@@ -0,0 +1,59 @@
|
|
1
|
+
= LocalizedCountrySelect
|
2
|
+
|
3
|
+
Rails plugin to provide support for localized <tt><select></tt> menu with country names and for
|
4
|
+
storing country information as country _code_ (eg. 'es'), not _name_ (eg. 'Spain'), in the database.
|
5
|
+
|
6
|
+
Uses the Rails internationalization framework (I18n, http://rails-i18n.org) for translating the names of countries.
|
7
|
+
Requires Rails 2.2 (released November 21st, 2008) or later versions.
|
8
|
+
Country names are loaded from hashes in plugin directory, according to <tt>I18n.locale</tt> value.
|
9
|
+
|
10
|
+
You can easily translate country codes in your application like this:
|
11
|
+
|
12
|
+
<%= I18n.t @user.country, :scope => 'countries' %>
|
13
|
+
|
14
|
+
Comes with a Rake task <tt>rake import:country_select 'de'</tt> for importing country names
|
15
|
+
from Unicode.org's CLDR repository (http://www.unicode.org/cldr/data/charts/summary/root.html)
|
16
|
+
Don't forget to restart the application when you add new locale.
|
17
|
+
|
18
|
+
ActionView helper code is adapted from Rails' default +country_select+ plugin (previously in core).
|
19
|
+
See http://github.com/rails/country_select/tree/master/lib/country_select.rb
|
20
|
+
|
21
|
+
== Examples
|
22
|
+
|
23
|
+
Show the complete country name:
|
24
|
+
|
25
|
+
<%= country_select(:user, :country, {}, :include_blank => 'Please choose...') %>
|
26
|
+
|
27
|
+
will become:
|
28
|
+
|
29
|
+
<select name="user[country]" id="user_country">
|
30
|
+
<option value="">Please choose...</option>
|
31
|
+
<option disabled="disabled" value="">-------------</option>
|
32
|
+
<option value="AF">Afghanistan</option>
|
33
|
+
...
|
34
|
+
<option value="ZW">Zimbabwe</option>
|
35
|
+
</select>
|
36
|
+
|
37
|
+
|
38
|
+
Show only the country codes:
|
39
|
+
|
40
|
+
<%= country_select(:user, :country, {:description => :abbreviated}, :include_blank => 'Please choose...') %>
|
41
|
+
|
42
|
+
will become:
|
43
|
+
|
44
|
+
<select name="user[country]" id="user_country">
|
45
|
+
<option value="">Please choose...</option>
|
46
|
+
<option disabled="disabled" value="">-------------</option>
|
47
|
+
<option value="AF">AF</option>
|
48
|
+
...
|
49
|
+
<option value="ZW">ZW</option>
|
50
|
+
</select>
|
51
|
+
for the <tt>en</tt> locale.
|
52
|
+
|
53
|
+
== Other resources
|
54
|
+
|
55
|
+
* http://github.com/rails/country_select (Default Rails plugin)
|
56
|
+
* http://github.com/russ/country_code_select (Stores country code, not name)
|
57
|
+
|
58
|
+
|
59
|
+
Copyright (c) 2008 Karel Minarik (www.karmi.cz), released under the MIT license
|
data/Rakefile
ADDED
@@ -0,0 +1,41 @@
|
|
1
|
+
require 'rake'
|
2
|
+
require 'rake/testtask'
|
3
|
+
require 'rake/rdoctask'
|
4
|
+
|
5
|
+
load File.join(File.dirname(__FILE__), 'lib', 'tasks', 'localized_country_select_tasks.rake')
|
6
|
+
|
7
|
+
desc 'Default: run unit tests.'
|
8
|
+
task :default => :test
|
9
|
+
|
10
|
+
desc 'Test the localized_country_select plugin.'
|
11
|
+
Rake::TestTask.new(:test) do |t|
|
12
|
+
t.libs << 'lib'
|
13
|
+
t.pattern = 'test/**/*_test.rb'
|
14
|
+
t.verbose = true
|
15
|
+
end
|
16
|
+
|
17
|
+
desc 'Generate documentation for the localized_country_select plugin.'
|
18
|
+
Rake::RDocTask.new(:rdoc) do |rdoc|
|
19
|
+
rdoc.rdoc_dir = 'rdoc'
|
20
|
+
rdoc.title = 'LocalizedCountrySelect'
|
21
|
+
rdoc.options << '--line-numbers' << '--inline-source'
|
22
|
+
rdoc.rdoc_files.include('README.rdoc')
|
23
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
24
|
+
end
|
25
|
+
|
26
|
+
#
|
27
|
+
# Jeweler
|
28
|
+
#
|
29
|
+
begin
|
30
|
+
require 'jeweler'
|
31
|
+
Jeweler::Tasks.new do |gemspec|
|
32
|
+
gemspec.name = "localized_country_select"
|
33
|
+
gemspec.summary = "Localized country select list"
|
34
|
+
gemspec.description = "Where are you from ?"
|
35
|
+
gemspec.email = "damien.mathieu@lim.eu"
|
36
|
+
gemspec.homepage = "http://github.com/LIMSAS/localized_country_select"
|
37
|
+
gemspec.authors = ["LIM SAS", "Damien MATHIEU", "Julien SANCHEZ", "Hervé GAUCHER"]
|
38
|
+
end
|
39
|
+
rescue LoadError
|
40
|
+
puts "Jeweler not available. Install it with: gem install jeweler"
|
41
|
+
end
|
data/init.rb
ADDED
data/install.rb
ADDED
@@ -0,0 +1,106 @@
|
|
1
|
+
# = LocalizedCountrySelect
|
2
|
+
#
|
3
|
+
# View helper for displaying select list with countries:
|
4
|
+
#
|
5
|
+
# country_select(:user, :country)
|
6
|
+
#
|
7
|
+
# Works just like the default Rails' +country_select+ plugin, but stores countries as
|
8
|
+
# country *codes*, not *names*, in the database.
|
9
|
+
#
|
10
|
+
# You can easily translate country codes in your application like this:
|
11
|
+
# <%= I18n.t @user.country, :scope => 'countries' %>
|
12
|
+
#
|
13
|
+
# Uses the Rails internationalization framework (I18n) for translating the names of countries.
|
14
|
+
#
|
15
|
+
# Use Rake task <tt>rake import:country_select 'de'</tt> for importing country names
|
16
|
+
# from Unicode.org's CLDR repository (http://www.unicode.org/cldr/data/charts/summary/root.html)
|
17
|
+
#
|
18
|
+
# Code adapted from Rails' default +country_select+ plugin (previously in core)
|
19
|
+
# See http://github.com/rails/country_select/tree/master/lib/country_select.rb
|
20
|
+
#
|
21
|
+
module LocalizedCountrySelect
|
22
|
+
class << self
|
23
|
+
# Returns array with codes and localized country names (according to <tt>I18n.locale</tt>)
|
24
|
+
# for <tt><option></tt> tags
|
25
|
+
def localized_countries_array(options={})
|
26
|
+
if(options[:description]==:abbreviated)
|
27
|
+
I18n.translate(:countries).map { |key, value| [key.to_s.upcase] }.
|
28
|
+
sort_by { |country| country.first }
|
29
|
+
else
|
30
|
+
I18n.translate(:countries).map { |key, value| [value, key.to_s.upcase] }.
|
31
|
+
sort_by { |country| country.first }
|
32
|
+
end
|
33
|
+
end
|
34
|
+
# Return array with codes and localized country names for array of country codes passed as argument
|
35
|
+
# == Example
|
36
|
+
# priority_countries_array([:TW, :CN])
|
37
|
+
# # => [ ['Taiwan', 'TW'], ['China', 'CN'] ]
|
38
|
+
def priority_countries_array(country_codes=[],options={})
|
39
|
+
if(options[:description]==:abbreviated)
|
40
|
+
country_codes.map { |code| [code.to_s.upcase] }
|
41
|
+
else
|
42
|
+
countries = I18n.translate(:countries)
|
43
|
+
country_codes.map { |code| [countries[code.to_s.upcase.to_sym], code.to_s.upcase] }
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
module ActionView
|
50
|
+
module Helpers
|
51
|
+
|
52
|
+
module FormOptionsHelper
|
53
|
+
|
54
|
+
# Return select and option tags for the given object and method, using +localized_country_options_for_select+
|
55
|
+
# to generate the list of option tags. Uses <b>country code</b>, not name as option +value+.
|
56
|
+
# Country codes listed as an array of symbols in +priority_countries+ argument will be listed first
|
57
|
+
# TODO : Implement pseudo-named args with a hash, not the "somebody said PHP?" multiple args sillines
|
58
|
+
def country_select(object, method, priority_countries = nil, options = {}, html_options = {})
|
59
|
+
InstanceTag.new(object, method, self, options.delete(:object)).
|
60
|
+
to_localized_country_select_tag(priority_countries, options, html_options)
|
61
|
+
end
|
62
|
+
|
63
|
+
# Return "named" select and option tags according to given arguments.
|
64
|
+
# Use +selected_value+ for setting initial value
|
65
|
+
# It behaves likes older object-binded brother +localized_country_select+ otherwise
|
66
|
+
# TODO : Implement pseudo-named args with a hash, not the "somebody said PHP?" multiple args sillines
|
67
|
+
def country_select_tag(name, selected_value = nil, priority_countries = nil, html_options = {})
|
68
|
+
select_tag name.to_sym, country_options_for_select(selected_value, priority_countries), html_options.stringify_keys
|
69
|
+
end
|
70
|
+
|
71
|
+
# Returns a string of option tags for countries according to locale. Supply the country code in upper-case ('US', 'DE')
|
72
|
+
# as +selected+ to have it marked as the selected option tag.
|
73
|
+
# Country codes listed as an array of symbols in +priority_countries+ argument will be listed first
|
74
|
+
def country_options_for_select(selected = nil, priority_countries = nil,options={})
|
75
|
+
country_options = ""
|
76
|
+
if priority_countries
|
77
|
+
country_options += options_for_select(LocalizedCountrySelect::priority_countries_array(priority_countries,options), selected)
|
78
|
+
country_options += "<option value=\"\" disabled=\"disabled\">-------------</option>\n"
|
79
|
+
end
|
80
|
+
return country_options + options_for_select(LocalizedCountrySelect::localized_countries_array(options), selected)
|
81
|
+
end
|
82
|
+
|
83
|
+
end
|
84
|
+
|
85
|
+
class InstanceTag
|
86
|
+
def to_localized_country_select_tag(priority_countries, options, html_options)
|
87
|
+
html_options = html_options.stringify_keys
|
88
|
+
add_default_name_and_id(html_options)
|
89
|
+
value = value(object)
|
90
|
+
content_tag("select",
|
91
|
+
add_options(
|
92
|
+
country_options_for_select(value, priority_countries,options),
|
93
|
+
options, value
|
94
|
+
), html_options
|
95
|
+
)
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
99
|
+
class FormBuilder
|
100
|
+
def country_select(method, priority_countries = nil, options = {}, html_options = {})
|
101
|
+
@template.country_select(@object_name, method, priority_countries, options.merge(:object => @object), html_options)
|
102
|
+
end
|
103
|
+
end
|
104
|
+
|
105
|
+
end
|
106
|
+
end
|
@@ -0,0 +1,91 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'open-uri'
|
3
|
+
|
4
|
+
# Rake task for importing country names from Unicode.org's CLDR repository
|
5
|
+
# (http://www.unicode.org/cldr/data/charts/summary/root.html).
|
6
|
+
#
|
7
|
+
# It parses a HTML file from Unicode.org for given locale and saves the
|
8
|
+
# Rails' I18n hash in the plugin +locale+ directory
|
9
|
+
#
|
10
|
+
# Don't forget to restart the application when you add new locale to load it into Rails!
|
11
|
+
#
|
12
|
+
# == Example
|
13
|
+
# rake import:country_select LOCALE=de
|
14
|
+
#
|
15
|
+
# The code is deliberately procedural and simple, so it's easily
|
16
|
+
# understandable by beginners as an introduction to Rake tasks power.
|
17
|
+
# See http://github.com/joshmh/cldr/tree/master/converter.rb for much more robust solution
|
18
|
+
|
19
|
+
namespace :import do
|
20
|
+
|
21
|
+
desc "Import country codes and names for various languages from the Unicode.org CLDR archive. Depends on Hpricot gem."
|
22
|
+
task :country_select do
|
23
|
+
begin
|
24
|
+
require 'hpricot'
|
25
|
+
rescue LoadError
|
26
|
+
puts "Error: Hpricot library required to use this task (import:country_select)"
|
27
|
+
exit
|
28
|
+
end
|
29
|
+
|
30
|
+
# TODO : Implement locale import chooser from CLDR root via Highline
|
31
|
+
|
32
|
+
# Setup variables
|
33
|
+
locale = ENV['LOCALE']
|
34
|
+
unless locale
|
35
|
+
puts "\n[!] Usage: rake import:country_select LOCALE=de\n\n"
|
36
|
+
exit 0
|
37
|
+
end
|
38
|
+
|
39
|
+
# ----- Get the CLDR HTML --------------------------------------------------
|
40
|
+
begin
|
41
|
+
puts "... getting the HTML file for locale '#{locale}'"
|
42
|
+
doc = Hpricot( open("http://www.unicode.org/cldr/data/charts/summary/#{locale}.html") )
|
43
|
+
rescue => e
|
44
|
+
puts "[!] Invalid locale name '#{locale}'! Not found in CLDR (#{e})"
|
45
|
+
exit 0
|
46
|
+
end
|
47
|
+
|
48
|
+
|
49
|
+
# ----- Parse the HTML with Hpricot ----------------------------------------
|
50
|
+
puts "... parsing the HTML file"
|
51
|
+
countries = []
|
52
|
+
doc.search("//tr").each do |row|
|
53
|
+
if row.search("td[@class='n']") &&
|
54
|
+
row.search("td[@class='n']").inner_html =~ /^namesterritory$/ &&
|
55
|
+
row.search("td[@class='g']").inner_html =~ /^[A-Z]{2}/
|
56
|
+
code = row.search("td[@class='g']").inner_text
|
57
|
+
code = code[-code.size, 2]
|
58
|
+
name = row.search("td[@class='v']").inner_text
|
59
|
+
countries << { :code => code.to_sym, :name => name.to_s }
|
60
|
+
print " ... #{name}"
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
|
65
|
+
# ----- Prepare the output format ------------------------------------------
|
66
|
+
output =<<HEAD
|
67
|
+
{ :#{locale} => {
|
68
|
+
|
69
|
+
:countries => {
|
70
|
+
HEAD
|
71
|
+
countries.each do |country|
|
72
|
+
output << "\t\t\t:#{country[:code]} => \"#{country[:name]}\",\n"
|
73
|
+
end
|
74
|
+
output <<<<TAIL
|
75
|
+
}
|
76
|
+
|
77
|
+
}
|
78
|
+
}
|
79
|
+
TAIL
|
80
|
+
|
81
|
+
|
82
|
+
# ----- Write the parsed values into file ---------------------------------
|
83
|
+
puts "\n... writing the output"
|
84
|
+
filename = File.join(File.dirname(__FILE__), '..', '..', 'locale', "#{locale}.rb")
|
85
|
+
filename += '.NEW' if File.exists?(filename) # Append 'NEW' if file exists
|
86
|
+
File.open(filename, 'w+') { |f| f << output }
|
87
|
+
puts "\n---\nWritten values for the '#{locale}' into file: #{filename}\n"
|
88
|
+
# ------------------------------------------------------------------------------
|
89
|
+
end
|
90
|
+
|
91
|
+
end
|
data/locale/en.rb
ADDED
@@ -0,0 +1,250 @@
|
|
1
|
+
{ :en => {
|
2
|
+
|
3
|
+
:countries => {
|
4
|
+
:AD => "Andorra",
|
5
|
+
:AE => "United Arab Emirates",
|
6
|
+
:AF => "Afghanistan",
|
7
|
+
:AG => "Antigua and Barbuda",
|
8
|
+
:AI => "Anguilla",
|
9
|
+
:AL => "Albania",
|
10
|
+
:AM => "Armenia",
|
11
|
+
:AN => "Netherlands Antilles",
|
12
|
+
:AO => "Angola",
|
13
|
+
:AQ => "Antarctica",
|
14
|
+
:AR => "Argentina",
|
15
|
+
:AS => "American Samoa",
|
16
|
+
:AT => "Austria",
|
17
|
+
:AU => "Australia",
|
18
|
+
:AW => "Aruba",
|
19
|
+
:AX => "Aland Islands",
|
20
|
+
:AZ => "Azerbaijan",
|
21
|
+
:BA => "Bosnia and Herzegovina",
|
22
|
+
:BB => "Barbados",
|
23
|
+
:BD => "Bangladesh",
|
24
|
+
:BE => "Belgium",
|
25
|
+
:BF => "Burkina Faso",
|
26
|
+
:BG => "Bulgaria",
|
27
|
+
:BH => "Bahrain",
|
28
|
+
:BI => "Burundi",
|
29
|
+
:BJ => "Benin",
|
30
|
+
:BL => "Saint Barthélemy",
|
31
|
+
:BM => "Bermuda",
|
32
|
+
:BN => "Brunei",
|
33
|
+
:BO => "Bolivia",
|
34
|
+
:BR => "Brazil",
|
35
|
+
:BS => "Bahamas",
|
36
|
+
:BT => "Bhutan",
|
37
|
+
:BV => "Bouvet Island",
|
38
|
+
:BW => "Botswana",
|
39
|
+
:BY => "Belarus",
|
40
|
+
:BZ => "Belize",
|
41
|
+
:CA => "Canada",
|
42
|
+
:CC => "Cocos Islands",
|
43
|
+
:CD => "Congo - Kinshasa",
|
44
|
+
:CF => "Central African Republic",
|
45
|
+
:CG => "Congo - Brazzaville",
|
46
|
+
:CH => "Switzerland",
|
47
|
+
:CI => "Cote d'Ivoire",
|
48
|
+
:CK => "Cook Islands",
|
49
|
+
:CL => "Chile",
|
50
|
+
:CM => "Cameroon",
|
51
|
+
:CN => "China",
|
52
|
+
:CO => "Colombia",
|
53
|
+
:CR => "Costa Rica",
|
54
|
+
:CU => "Cuba",
|
55
|
+
:CV => "Cape Verde",
|
56
|
+
:CX => "Christmas Island",
|
57
|
+
:CY => "Cyprus",
|
58
|
+
:CZ => "Czech Republic",
|
59
|
+
:DE => "Germany",
|
60
|
+
:DJ => "Djibouti",
|
61
|
+
:DK => "Denmark",
|
62
|
+
:DM => "Dominica",
|
63
|
+
:DO => "Dominican Republic",
|
64
|
+
:DZ => "Algeria",
|
65
|
+
:EC => "Ecuador",
|
66
|
+
:EE => "Estonia",
|
67
|
+
:EG => "Egypt",
|
68
|
+
:EH => "Western Sahara",
|
69
|
+
:ER => "Eritrea",
|
70
|
+
:ES => "Spain",
|
71
|
+
:ET => "Ethiopia",
|
72
|
+
:FI => "Finland",
|
73
|
+
:FJ => "Fiji",
|
74
|
+
:FK => "Falkland Islands",
|
75
|
+
:FM => "Micronesia",
|
76
|
+
:FO => "Faroe Islands",
|
77
|
+
:FR => "France",
|
78
|
+
:GA => "Gabon",
|
79
|
+
:GB => "United Kingdom",
|
80
|
+
:GD => "Grenada",
|
81
|
+
:GE => "Georgia",
|
82
|
+
:GF => "French Guiana",
|
83
|
+
:GG => "Guernsey",
|
84
|
+
:GH => "Ghana",
|
85
|
+
:GI => "Gibraltar",
|
86
|
+
:GL => "Greenland",
|
87
|
+
:GM => "Gambia",
|
88
|
+
:GN => "Guinea",
|
89
|
+
:GP => "Guadeloupe",
|
90
|
+
:GQ => "Equatorial Guinea",
|
91
|
+
:GR => "Greece",
|
92
|
+
:GS => "South Georgia and the South Sandwich Islands",
|
93
|
+
:GT => "Guatemala",
|
94
|
+
:GU => "Guam",
|
95
|
+
:GW => "Guinea-Bissau",
|
96
|
+
:GY => "Guyana",
|
97
|
+
:HK => "Hong Kong",
|
98
|
+
:HM => "Heard Island and McDonald Islands",
|
99
|
+
:HN => "Honduras",
|
100
|
+
:HR => "Croatia",
|
101
|
+
:HT => "Haiti",
|
102
|
+
:HU => "Hungary",
|
103
|
+
:ID => "Indonesia",
|
104
|
+
:IE => "Ireland",
|
105
|
+
:IL => "Israel",
|
106
|
+
:IM => "Isle of Man",
|
107
|
+
:IN => "India",
|
108
|
+
:IQ => "Iraq",
|
109
|
+
:IR => "Iran",
|
110
|
+
:IS => "Iceland",
|
111
|
+
:IT => "Italy",
|
112
|
+
:JE => "Jersey",
|
113
|
+
:JM => "Jamaica",
|
114
|
+
:JO => "Jordan",
|
115
|
+
:JP => "Japan",
|
116
|
+
:KE => "Kenya",
|
117
|
+
:KG => "Kyrgyzstan",
|
118
|
+
:KH => "Cambodia",
|
119
|
+
:KI => "Kiribati",
|
120
|
+
:KM => "Comoros",
|
121
|
+
:KN => "Saint Kitts and Nevis",
|
122
|
+
:KP => "North Korea",
|
123
|
+
:KR => "South Korea",
|
124
|
+
:KW => "Kuwait",
|
125
|
+
:KY => "Cayman Islands",
|
126
|
+
:KZ => "Kazakhstan",
|
127
|
+
:LA => "Laos",
|
128
|
+
:LB => "Lebanon",
|
129
|
+
:LC => "Saint Lucia",
|
130
|
+
:LI => "Liechtenstein",
|
131
|
+
:LK => "Sri Lanka",
|
132
|
+
:LR => "Liberia",
|
133
|
+
:LS => "Lesotho",
|
134
|
+
:LT => "Lithuania",
|
135
|
+
:LU => "Luxembourg",
|
136
|
+
:LV => "Latvia",
|
137
|
+
:LY => "Libya",
|
138
|
+
:MA => "Morocco",
|
139
|
+
:MC => "Monaco",
|
140
|
+
:MD => "Moldova",
|
141
|
+
:ME => "Montenegro",
|
142
|
+
:MF => "Saint Martin",
|
143
|
+
:MG => "Madagascar",
|
144
|
+
:MH => "Marshall Islands",
|
145
|
+
:MK => "Macedonia",
|
146
|
+
:ML => "Mali",
|
147
|
+
:MM => "Myanmar",
|
148
|
+
:MN => "Mongolia",
|
149
|
+
:MO => "Macao",
|
150
|
+
:MP => "Northern Mariana Islands",
|
151
|
+
:MQ => "Martinique",
|
152
|
+
:MR => "Mauritania",
|
153
|
+
:MS => "Montserrat",
|
154
|
+
:MT => "Malta",
|
155
|
+
:MU => "Mauritius",
|
156
|
+
:MV => "Maldives",
|
157
|
+
:MW => "Malawi",
|
158
|
+
:MX => "Mexico",
|
159
|
+
:MY => "Malaysia",
|
160
|
+
:MZ => "Mozambique",
|
161
|
+
:NA => "Namibia",
|
162
|
+
:NC => "New Caledonia",
|
163
|
+
:NE => "Niger",
|
164
|
+
:NF => "Norfolk Island",
|
165
|
+
:NG => "Nigeria",
|
166
|
+
:NI => "Nicaragua",
|
167
|
+
:NL => "Netherlands",
|
168
|
+
:NO => "Norway",
|
169
|
+
:NP => "Nepal",
|
170
|
+
:NR => "Nauru",
|
171
|
+
:NU => "Niue",
|
172
|
+
:NZ => "New Zealand",
|
173
|
+
:OM => "Oman",
|
174
|
+
:PA => "Panama",
|
175
|
+
:PE => "Peru",
|
176
|
+
:PF => "French Polynesia",
|
177
|
+
:PG => "Papua New Guinea",
|
178
|
+
:PH => "Philippines",
|
179
|
+
:PK => "Pakistan",
|
180
|
+
:PL => "Poland",
|
181
|
+
:PM => "Saint Pierre and Miquelon",
|
182
|
+
:PN => "Pitcairn",
|
183
|
+
:PR => "Puerto Rico",
|
184
|
+
:PS => "Palestinian Territory",
|
185
|
+
:PT => "Portugal",
|
186
|
+
:PW => "Palau",
|
187
|
+
:PY => "Paraguay",
|
188
|
+
:QA => "Qatar",
|
189
|
+
:RE => "Reunion",
|
190
|
+
:RO => "Romania",
|
191
|
+
:RS => "Serbia",
|
192
|
+
:RU => "Russia",
|
193
|
+
:RW => "Rwanda",
|
194
|
+
:SA => "Saudi Arabia",
|
195
|
+
:SB => "Solomon Islands",
|
196
|
+
:SC => "Seychelles",
|
197
|
+
:SD => "Sudan",
|
198
|
+
:SE => "Sweden",
|
199
|
+
:SG => "Singapore",
|
200
|
+
:SH => "Saint Helena",
|
201
|
+
:SI => "Slovenia",
|
202
|
+
:SJ => "Svalbard and Jan Mayen",
|
203
|
+
:SK => "Slovakia",
|
204
|
+
:SL => "Sierra Leone",
|
205
|
+
:SM => "San Marino",
|
206
|
+
:SN => "Senegal",
|
207
|
+
:SO => "Somalia",
|
208
|
+
:SR => "Suriname",
|
209
|
+
:ST => "Sao Tome and Principe",
|
210
|
+
:SV => "El Salvador",
|
211
|
+
:SY => "Syria",
|
212
|
+
:SZ => "Swaziland",
|
213
|
+
:TC => "Turks and Caicos Islands",
|
214
|
+
:TD => "Chad",
|
215
|
+
:TF => "French Southern Territories",
|
216
|
+
:TG => "Togo",
|
217
|
+
:TH => "Thailand",
|
218
|
+
:TJ => "Tajikistan",
|
219
|
+
:TK => "Tokelau",
|
220
|
+
:TL => "East Timor",
|
221
|
+
:TM => "Turkmenistan",
|
222
|
+
:TN => "Tunisia",
|
223
|
+
:TO => "Tonga",
|
224
|
+
:TR => "Turkey",
|
225
|
+
:TT => "Trinidad and Tobago",
|
226
|
+
:TV => "Tuvalu",
|
227
|
+
:TW => "Taiwan",
|
228
|
+
:TZ => "Tanzania",
|
229
|
+
:UA => "Ukraine",
|
230
|
+
:UG => "Uganda",
|
231
|
+
:US => "United States",
|
232
|
+
:UY => "Uruguay",
|
233
|
+
:UZ => "Uzbekistan",
|
234
|
+
:VA => "Vatican",
|
235
|
+
:VC => "Saint Vincent and the Grenadines",
|
236
|
+
:VE => "Venezuela",
|
237
|
+
:VG => "British Virgin Islands",
|
238
|
+
:VI => "U.S. Virgin Islands",
|
239
|
+
:VN => "Vietnam",
|
240
|
+
:VU => "Vanuatu",
|
241
|
+
:WS => "Samoa",
|
242
|
+
:YE => "Yemen",
|
243
|
+
:YT => "Mayotte",
|
244
|
+
:ZA => "South Africa",
|
245
|
+
:ZM => "Zambia",
|
246
|
+
:ZW => "Zimbabwe",
|
247
|
+
}
|
248
|
+
|
249
|
+
}
|
250
|
+
}
|
data/locale/ru.rb
ADDED
@@ -0,0 +1,250 @@
|
|
1
|
+
{ :ru => {
|
2
|
+
|
3
|
+
:countries => {
|
4
|
+
:AD => "Андорра",
|
5
|
+
:AE => "Объединенные Арабские Эмираты",
|
6
|
+
:AF => "Афганистан",
|
7
|
+
:AG => "Антигуа и Барбуда",
|
8
|
+
:AI => "Ангилья",
|
9
|
+
:AL => "Албания",
|
10
|
+
:AM => "Армения",
|
11
|
+
:AN => "Нидерландские Антильские о-ва",
|
12
|
+
:AO => "Ангола",
|
13
|
+
:AQ => "Антарктида",
|
14
|
+
:AR => "Аргентина",
|
15
|
+
:AS => "Американское Самоа",
|
16
|
+
:AT => "Австрия",
|
17
|
+
:AU => "Австралия",
|
18
|
+
:AW => "Аруба",
|
19
|
+
:AX => "Аландские о-ва",
|
20
|
+
:AZ => "Азербайджан",
|
21
|
+
:BA => "Босния и Герцеговина",
|
22
|
+
:BB => "Барбадос",
|
23
|
+
:BD => "Бангладеш",
|
24
|
+
:BE => "Бельгия",
|
25
|
+
:BF => "Буркина Фасо",
|
26
|
+
:BG => "Болгария",
|
27
|
+
:BH => "Бахрейн",
|
28
|
+
:BI => "Бурунди",
|
29
|
+
:BJ => "Бенин",
|
30
|
+
:BL => "Остров Святого Бартоломея",
|
31
|
+
:BM => "Бермудские о-ва",
|
32
|
+
:BN => "Бруней Даруссалам",
|
33
|
+
:BO => "Боливия",
|
34
|
+
:BR => "Бразилия",
|
35
|
+
:BS => "Багамские о-ва",
|
36
|
+
:BT => "Бутан",
|
37
|
+
:BV => "Остров Буве",
|
38
|
+
:BW => "Ботсвана",
|
39
|
+
:BY => "Беларусь",
|
40
|
+
:BZ => "Белиз",
|
41
|
+
:CA => "Канада",
|
42
|
+
:CC => "Кокосовые о-ва",
|
43
|
+
:CD => "Демократическая Республика Конго",
|
44
|
+
:CF => "Центральноафриканская Республика",
|
45
|
+
:CG => "Конго",
|
46
|
+
:CH => "Швейцария",
|
47
|
+
:CI => "Кот д’Ивуар",
|
48
|
+
:CK => "Острова Кука",
|
49
|
+
:CL => "Чили",
|
50
|
+
:CM => "Камерун",
|
51
|
+
:CN => "Китай",
|
52
|
+
:CO => "Колумбия",
|
53
|
+
:CR => "Коста-Рика",
|
54
|
+
:CU => "Куба",
|
55
|
+
:CV => "Острова Зеленого Мыса",
|
56
|
+
:CX => "Остров Рождества",
|
57
|
+
:CY => "Кипр",
|
58
|
+
:CZ => "Чехия",
|
59
|
+
:DE => "Германия",
|
60
|
+
:DJ => "Джибути",
|
61
|
+
:DK => "Дания",
|
62
|
+
:DM => "Доминика",
|
63
|
+
:DO => "Доминиканская Республика",
|
64
|
+
:DZ => "Алжир",
|
65
|
+
:EC => "Эквадор",
|
66
|
+
:EE => "Эстония",
|
67
|
+
:EG => "Египет",
|
68
|
+
:EH => "Западная Сахара",
|
69
|
+
:ER => "Эритрея",
|
70
|
+
:ES => "Испания",
|
71
|
+
:ET => "Эфиопия",
|
72
|
+
:FI => "Финляндия",
|
73
|
+
:FJ => "Фиджи",
|
74
|
+
:FK => "Фолклендские о-ва",
|
75
|
+
:FM => "Федеративные Штаты Микронезии",
|
76
|
+
:FO => "Фарерские о-ва",
|
77
|
+
:FR => "Франция",
|
78
|
+
:GA => "Габон",
|
79
|
+
:GB => "Великобритания",
|
80
|
+
:GD => "Гренада",
|
81
|
+
:GE => "Грузия",
|
82
|
+
:GF => "Французская Гвиана",
|
83
|
+
:GG => "Гернси",
|
84
|
+
:GH => "Гана",
|
85
|
+
:GI => "Гибралтар",
|
86
|
+
:GL => "Гренландия",
|
87
|
+
:GM => "Гамбия",
|
88
|
+
:GN => "Гвинея",
|
89
|
+
:GP => "Гваделупа",
|
90
|
+
:GQ => "Экваториальная Гвинея",
|
91
|
+
:GR => "Греция",
|
92
|
+
:GS => "Южная Джорджия и Южные Сандвичевы Острова",
|
93
|
+
:GT => "Гватемала",
|
94
|
+
:GU => "Гуам",
|
95
|
+
:GW => "Гвинея-Бисау",
|
96
|
+
:GY => "Гайана",
|
97
|
+
:HK => "Гонконг",
|
98
|
+
:HM => "Острова Херд и Макдональд",
|
99
|
+
:HN => "Гондурас",
|
100
|
+
:HR => "Хорватия",
|
101
|
+
:HT => "Гаити",
|
102
|
+
:HU => "Венгрия",
|
103
|
+
:ID => "Индонезия",
|
104
|
+
:IE => "Ирландия",
|
105
|
+
:IL => "Израиль",
|
106
|
+
:IM => "Остров Мэн",
|
107
|
+
:IN => "Индия",
|
108
|
+
:IQ => "Ирак",
|
109
|
+
:IR => "Иран",
|
110
|
+
:IS => "Исландия",
|
111
|
+
:IT => "Италия",
|
112
|
+
:JE => "Джерси",
|
113
|
+
:JM => "Ямайка",
|
114
|
+
:JO => "Иордания",
|
115
|
+
:JP => "Япония",
|
116
|
+
:KE => "Кения",
|
117
|
+
:KG => "Киргизия",
|
118
|
+
:KH => "Камбоджа",
|
119
|
+
:KI => "Кирибати",
|
120
|
+
:KM => "Коморские о-ва",
|
121
|
+
:KN => "Сент-Киттс и Невис",
|
122
|
+
:KP => "Северная Корея",
|
123
|
+
:KR => "Республика Корея",
|
124
|
+
:KW => "Кувейт",
|
125
|
+
:KY => "Каймановы острова",
|
126
|
+
:KZ => "Казахстан",
|
127
|
+
:LA => "Лаос",
|
128
|
+
:LB => "Ливан",
|
129
|
+
:LC => "Сент-Люсия",
|
130
|
+
:LI => "Лихтенштейн",
|
131
|
+
:LK => "Шри-Ланка",
|
132
|
+
:LR => "Либерия",
|
133
|
+
:LS => "Лесото",
|
134
|
+
:LT => "Литва",
|
135
|
+
:LU => "Люксембург",
|
136
|
+
:LV => "Латвия",
|
137
|
+
:LY => "Ливия",
|
138
|
+
:MA => "Марокко",
|
139
|
+
:MC => "Монако",
|
140
|
+
:MD => "Молдова",
|
141
|
+
:ME => "Черногория",
|
142
|
+
:MF => "Остров Святого Мартина",
|
143
|
+
:MG => "Мадагаскар",
|
144
|
+
:MH => "Маршалловы о-ва",
|
145
|
+
:MK => "Македония",
|
146
|
+
:ML => "Мали",
|
147
|
+
:MM => "Мьянма",
|
148
|
+
:MN => "Монголия",
|
149
|
+
:MO => "Макао",
|
150
|
+
:MP => "Северные Марианские о-ва",
|
151
|
+
:MQ => "Мартиника",
|
152
|
+
:MR => "Мавритания",
|
153
|
+
:MS => "Монтсеррат",
|
154
|
+
:MT => "Мальта",
|
155
|
+
:MU => "Маврикий",
|
156
|
+
:MV => "Мальдивские о-ва",
|
157
|
+
:MW => "Малави",
|
158
|
+
:MX => "Мексика",
|
159
|
+
:MY => "Малайзия",
|
160
|
+
:MZ => "Мозамбик",
|
161
|
+
:NA => "Намибия",
|
162
|
+
:NC => "Новая Каледония",
|
163
|
+
:NE => "Нигер",
|
164
|
+
:NF => "Остров Норфолк",
|
165
|
+
:NG => "Нигерия",
|
166
|
+
:NI => "Никарагуа",
|
167
|
+
:NL => "Нидерланды",
|
168
|
+
:NO => "Норвегия",
|
169
|
+
:NP => "Непал",
|
170
|
+
:NR => "Науру",
|
171
|
+
:NU => "Ниуе",
|
172
|
+
:NZ => "Новая Зеландия",
|
173
|
+
:OM => "Оман",
|
174
|
+
:PA => "Панама",
|
175
|
+
:PE => "Перу",
|
176
|
+
:PF => "Французская Полинезия",
|
177
|
+
:PG => "Папуа – Новая Гвинея",
|
178
|
+
:PH => "Филиппины",
|
179
|
+
:PK => "Пакистан",
|
180
|
+
:PL => "Польша",
|
181
|
+
:PM => "Сен-Пьер и Микелон",
|
182
|
+
:PN => "Питкэрн",
|
183
|
+
:PR => "Пуэрто-Рико",
|
184
|
+
:PS => "Палестинские территории",
|
185
|
+
:PT => "Португалия",
|
186
|
+
:PW => "Палау",
|
187
|
+
:PY => "Парагвай",
|
188
|
+
:QA => "Катар",
|
189
|
+
:RE => "Реюньон",
|
190
|
+
:RO => "Румыния",
|
191
|
+
:RS => "Сербия",
|
192
|
+
:RU => "Россия",
|
193
|
+
:RW => "Руанда",
|
194
|
+
:SA => "Саудовская Аравия",
|
195
|
+
:SB => "Соломоновы о-ва",
|
196
|
+
:SC => "Сейшельские о-ва",
|
197
|
+
:SD => "Судан",
|
198
|
+
:SE => "Швеция",
|
199
|
+
:SG => "Сингапур",
|
200
|
+
:SH => "Остров Святой Елены",
|
201
|
+
:SI => "Словения",
|
202
|
+
:SJ => "Свальбард и Ян-Майен",
|
203
|
+
:SK => "Словакия",
|
204
|
+
:SL => "Сьерра-Леоне",
|
205
|
+
:SM => "Сан-Марино",
|
206
|
+
:SN => "Сенегал",
|
207
|
+
:SO => "Сомали",
|
208
|
+
:SR => "Суринам",
|
209
|
+
:ST => "Сан-Томе и Принсипи",
|
210
|
+
:SV => "Сальвадор",
|
211
|
+
:SY => "Сирия",
|
212
|
+
:SZ => "Свазиленд",
|
213
|
+
:TC => "Острова Тёркс и Кайкос",
|
214
|
+
:TD => "Чад",
|
215
|
+
:TF => "Французские Южные Территории",
|
216
|
+
:TG => "Того",
|
217
|
+
:TH => "Таиланд",
|
218
|
+
:TJ => "Таджикистан",
|
219
|
+
:TK => "Токелау",
|
220
|
+
:TL => "Восточный Тимор",
|
221
|
+
:TM => "Туркменистан",
|
222
|
+
:TN => "Тунис",
|
223
|
+
:TO => "Тонга",
|
224
|
+
:TR => "Турция",
|
225
|
+
:TT => "Тринидад и Тобаго",
|
226
|
+
:TV => "Тувалу",
|
227
|
+
:TW => "Тайвань",
|
228
|
+
:TZ => "Танзания",
|
229
|
+
:UA => "Украина",
|
230
|
+
:UG => "Уганда",
|
231
|
+
:US => "США",
|
232
|
+
:UY => "Уругвай",
|
233
|
+
:UZ => "Узбекистан",
|
234
|
+
:VA => "Ватикан",
|
235
|
+
:VC => "Сент-Винсент и Гренадины",
|
236
|
+
:VE => "Венесуэла",
|
237
|
+
:VG => "Британские Виргинские о-ва",
|
238
|
+
:VI => "Виргинские о-ва (США)",
|
239
|
+
:VN => "Вьетнам",
|
240
|
+
:VU => "Вануату",
|
241
|
+
:WS => "Самоа",
|
242
|
+
:YE => "Йемен",
|
243
|
+
:YT => "Майотта",
|
244
|
+
:ZA => "ЮАР",
|
245
|
+
:ZM => "Замбия",
|
246
|
+
:ZW => "Зимбабве",
|
247
|
+
}
|
248
|
+
|
249
|
+
}
|
250
|
+
}
|
@@ -0,0 +1,117 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
$KCODE = 'u'
|
3
|
+
|
4
|
+
require 'test/unit'
|
5
|
+
|
6
|
+
require 'rubygems'
|
7
|
+
require 'active_support'
|
8
|
+
require 'action_controller'
|
9
|
+
# require 'action_controller/test_process'
|
10
|
+
require 'action_view'
|
11
|
+
require 'action_view/helpers'
|
12
|
+
require 'action_view/helpers/tag_helper'
|
13
|
+
require 'i18n'
|
14
|
+
|
15
|
+
begin
|
16
|
+
require 'redgreen'
|
17
|
+
rescue LoadError
|
18
|
+
puts "[!] Install redgreen gem for better test output ($ sudo gem install redgreen)"
|
19
|
+
end unless ENV["TM_FILEPATH"]
|
20
|
+
|
21
|
+
require 'localized_country_select'
|
22
|
+
|
23
|
+
class LocalizedCountrySelectTest < Test::Unit::TestCase
|
24
|
+
|
25
|
+
include ActionView::Helpers::TagHelper
|
26
|
+
include ActionView::Helpers::FormOptionsHelper
|
27
|
+
include ActionView::Helpers::FormTagHelper
|
28
|
+
|
29
|
+
def test_action_view_should_include_helper_for_object
|
30
|
+
assert ActionView::Helpers::FormBuilder.instance_methods.include?('country_select') # WTF not working with 1.9
|
31
|
+
assert ActionView::Helpers::FormOptionsHelper.instance_methods.include?('country_select')
|
32
|
+
end
|
33
|
+
|
34
|
+
def test_action_view_should_include_helper_tag
|
35
|
+
assert ActionView::Helpers::FormOptionsHelper.instance_methods.include?('country_select_tag') # WTF not working with 1.9
|
36
|
+
end
|
37
|
+
|
38
|
+
def test_should_return_select_tag_with_proper_name_for_object
|
39
|
+
# puts country_select(:user, :country)
|
40
|
+
assert country_select(:user, :country) =~
|
41
|
+
Regexp.new(Regexp.escape('<select id="user_country" name="user[country]">')),
|
42
|
+
"Should have proper name for object"
|
43
|
+
end
|
44
|
+
|
45
|
+
def test_should_return_select_tag_with_proper_name
|
46
|
+
# puts country_select_tag( "competition_submission[data][citizenship]", nil)
|
47
|
+
assert country_select_tag( "competition_submission[data][citizenship]", nil) =~
|
48
|
+
Regexp.new(
|
49
|
+
Regexp.escape('<select id="competition_submission_data_citizenship" name="competition_submission[data][citizenship]">') ),
|
50
|
+
"Should have proper name"
|
51
|
+
end
|
52
|
+
|
53
|
+
def test_should_return_option_tags
|
54
|
+
assert country_select(:user, :country) =~ Regexp.new(Regexp.escape('<option value="ES">Spain</option>'))
|
55
|
+
end
|
56
|
+
|
57
|
+
def test_should_return_localized_option_tags
|
58
|
+
I18n.locale = 'ru'
|
59
|
+
assert country_select(:user, :country) =~ Regexp.new(Regexp.escape('<option value="ES">Испания</option>'))
|
60
|
+
end
|
61
|
+
|
62
|
+
def test_should_return_priority_countries_first
|
63
|
+
assert country_options_for_select(nil, [:ES, :CZ]) =~ Regexp.new(
|
64
|
+
Regexp.escape("<option value=\"ES\">Spain</option>\n<option value=\"CZ\">Czech Republic</option><option value=\"\" disabled=\"disabled\">-------------</option>\n<option value=\"AF\">Afghanistan</option>\n"))
|
65
|
+
end
|
66
|
+
|
67
|
+
def test_i18n_should_know_about_countries
|
68
|
+
assert_equal 'Spain', I18n.t('ES', :scope => 'countries')
|
69
|
+
I18n.locale = 'ru'
|
70
|
+
assert_equal 'Испания', I18n.t('ES', :scope => 'countries')
|
71
|
+
end
|
72
|
+
|
73
|
+
def test_localized_countries_array_returns_correctly
|
74
|
+
assert_nothing_raised { LocalizedCountrySelect::localized_countries_array() }
|
75
|
+
# puts LocalizedCountrySelect::localized_countries_array.inspect
|
76
|
+
I18n.locale = 'en'
|
77
|
+
assert_equal 243, LocalizedCountrySelect::localized_countries_array.size
|
78
|
+
assert_equal 'Afghanistan', LocalizedCountrySelect::localized_countries_array.first[0]
|
79
|
+
I18n.locale = 'ru'
|
80
|
+
assert_equal 243, LocalizedCountrySelect::localized_countries_array.size
|
81
|
+
assert_equal 'Австралия', LocalizedCountrySelect::localized_countries_array.first[0]
|
82
|
+
end
|
83
|
+
|
84
|
+
def test_priority_countries_returns_correctly_and_in_correct_order
|
85
|
+
assert_nothing_raised { LocalizedCountrySelect::priority_countries_array([:TW, :CN]) }
|
86
|
+
I18n.locale = 'en'
|
87
|
+
assert_equal [ ['Taiwan', 'TW'], ['China', 'CN'] ], LocalizedCountrySelect::priority_countries_array([:TW, :CN])
|
88
|
+
end
|
89
|
+
|
90
|
+
def test_priority_countries_allows_passing_either_symbol_or_string
|
91
|
+
I18n.locale = 'en'
|
92
|
+
assert_equal [ ['United States', 'US'], ['Canada', 'CA'] ], LocalizedCountrySelect::priority_countries_array(['US', 'CA'])
|
93
|
+
end
|
94
|
+
|
95
|
+
def test_priority_countries_allows_passing_upcase_or_lowercase
|
96
|
+
I18n.locale = 'en'
|
97
|
+
assert_equal [ ['United States', 'US'], ['Canada', 'CA'] ], LocalizedCountrySelect::priority_countries_array(['us', 'ca'])
|
98
|
+
assert_equal [ ['United States', 'US'], ['Canada', 'CA'] ], LocalizedCountrySelect::priority_countries_array([:us, :ca])
|
99
|
+
end
|
100
|
+
|
101
|
+
def test_should_list_countries_with_accented_names_in_correct_order
|
102
|
+
I18n.locale = 'ru'
|
103
|
+
assert_match Regexp.new(Regexp.escape(%Q{<option value="BT">Бутан</option>\n<option value="VU">Вануату</option>})), country_select(:user, :country)
|
104
|
+
end
|
105
|
+
|
106
|
+
# private
|
107
|
+
|
108
|
+
def setup
|
109
|
+
['ru', 'en'].each do |locale|
|
110
|
+
# I18n.load_translations( File.join(File.dirname(__FILE__), '..', 'locale', "#{locale}.rb") ) # <-- Old style! :)
|
111
|
+
I18n.load_path += Dir[ File.join(File.dirname(__FILE__), '..', 'locale', "#{locale}.rb") ]
|
112
|
+
end
|
113
|
+
# I18n.locale = I18n.default_locale
|
114
|
+
I18n.locale = 'en'
|
115
|
+
end
|
116
|
+
|
117
|
+
end
|
data/uninstall.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
# Uninstall hook code here
|
metadata
ADDED
@@ -0,0 +1,81 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: localized_country_select
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 29
|
5
|
+
prerelease: false
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 0
|
9
|
+
- 1
|
10
|
+
version: 0.0.1
|
11
|
+
platform: ruby
|
12
|
+
authors:
|
13
|
+
- LIM SAS
|
14
|
+
- Damien MATHIEU
|
15
|
+
- Julien SANCHEZ
|
16
|
+
- "Herv\xC3\xA9 GAUCHER"
|
17
|
+
autorequire:
|
18
|
+
bindir: bin
|
19
|
+
cert_chain: []
|
20
|
+
|
21
|
+
date: 2010-07-21 00:00:00 +02:00
|
22
|
+
default_executable:
|
23
|
+
dependencies: []
|
24
|
+
|
25
|
+
description: Where are you from ?
|
26
|
+
email: damien.mathieu@lim.eu
|
27
|
+
executables: []
|
28
|
+
|
29
|
+
extensions: []
|
30
|
+
|
31
|
+
extra_rdoc_files:
|
32
|
+
- README.rdoc
|
33
|
+
files:
|
34
|
+
- .gitignore
|
35
|
+
- MIT-LICENSE
|
36
|
+
- README.rdoc
|
37
|
+
- Rakefile
|
38
|
+
- init.rb
|
39
|
+
- install.rb
|
40
|
+
- lib/localized_country_select.rb
|
41
|
+
- lib/tasks/localized_country_select_tasks.rake
|
42
|
+
- locale/en.rb
|
43
|
+
- locale/ru.rb
|
44
|
+
- test/localized_country_select_test.rb
|
45
|
+
- uninstall.rb
|
46
|
+
has_rdoc: true
|
47
|
+
homepage: http://github.com/LIMSAS/localized_country_select
|
48
|
+
licenses: []
|
49
|
+
|
50
|
+
post_install_message:
|
51
|
+
rdoc_options:
|
52
|
+
- --charset=UTF-8
|
53
|
+
require_paths:
|
54
|
+
- lib
|
55
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
56
|
+
none: false
|
57
|
+
requirements:
|
58
|
+
- - ">="
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
hash: 3
|
61
|
+
segments:
|
62
|
+
- 0
|
63
|
+
version: "0"
|
64
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
66
|
+
requirements:
|
67
|
+
- - ">="
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
hash: 3
|
70
|
+
segments:
|
71
|
+
- 0
|
72
|
+
version: "0"
|
73
|
+
requirements: []
|
74
|
+
|
75
|
+
rubyforge_project:
|
76
|
+
rubygems_version: 1.3.7
|
77
|
+
signing_key:
|
78
|
+
specification_version: 3
|
79
|
+
summary: Localized country select list
|
80
|
+
test_files:
|
81
|
+
- test/localized_country_select_test.rb
|