# The result is cached to prevent from loading all translations files
# unless :cache => false option is given
def languages_options(options={})
- if options[:cache] == false
+ options = if options[:cache] == false
valid_languages.
select {|locale| ::I18n.exists?(:general_lang_name, locale)}.
map {|lang| [ll(lang.to_s, :general_lang_name), lang.to_s]}.
languages_options :cache => false
end
end
+ options.map {|name, lang| [name.force_encoding("UTF-8"), lang.force_encoding("UTF-8")]}
end
def find_language(lang)
assert_include [ja, "ja"], options
end
+ def test_languages_options_should_return_strings_with_utf8_encoding
+ strings = languages_options.flatten
+ assert_equal ["UTF-8"], strings.map(&:encoding).uniq.map(&:name).sort
+ end
+
def test_languages_options_should_ignore_locales_without_general_lang_name_key
stubs(:valid_languages).returns([:en, :foo])
assert_equal [["English", "en"]], languages_options(:cache => false)