Skip to content

Commit

Permalink
FIX that countries beginning with accented characters (Ägyptien, Špan…
Browse files Browse the repository at this point in the history
…ělsko, etc) are listed in correct order, not at the end of the list
  • Loading branch information
karmi committed Sep 30, 2009
1 parent c96ea30 commit ca5ccd1
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/localized_country_select.rb
Expand Up @@ -23,7 +23,8 @@ class << self
# Returns array with codes and localized country names (according to <tt>I18n.locale</tt>)
# for <tt><option></tt> tags
def localized_countries_array
I18n.translate(:countries).map { |key, value| [value, key.to_s.upcase] }.sort
I18n.translate(:countries).map { |key, value| [value, key.to_s.upcase] }.
sort_by { |country| country.first.parameterize }
end
# Return array with codes and localized country names for array of country codes passed as argument
# == Example
Expand Down
5 changes: 5 additions & 0 deletions test/localized_country_select_test.rb
Expand Up @@ -95,6 +95,11 @@ def test_priority_countries_allows_passing_upcase_or_lowercase
assert_equal [ ['United States', 'US'], ['Canada', 'CA'] ], LocalizedCountrySelect::priority_countries_array([:us, :ca])
end

def test_should_list_countries_with_accented_names_in_correct_order
I18n.locale = 'cz'
assert_match Regexp.new(Regexp.escape(%Q{<option value="BI">Burundi</option>\n<option value="TD">Čad</option>})), localized_country_select(:user, :country)
end

private

def setup
Expand Down

0 comments on commit ca5ccd1

Please sign in to comment.