##// END OF EJS Templates
Force UTF-8 encoding of language names....
Jean-Philippe Lang -
r13425:3fcd683e6bad
parent child
Show More
@@ -93,7 +93,7 module Redmine
93 # The result is cached to prevent from loading all translations files
93 # The result is cached to prevent from loading all translations files
94 # unless :cache => false option is given
94 # unless :cache => false option is given
95 def languages_options(options={})
95 def languages_options(options={})
96 if options[:cache] == false
96 options = if options[:cache] == false
97 valid_languages.
97 valid_languages.
98 select {|locale| ::I18n.exists?(:general_lang_name, locale)}.
98 select {|locale| ::I18n.exists?(:general_lang_name, locale)}.
99 map {|lang| [ll(lang.to_s, :general_lang_name), lang.to_s]}.
99 map {|lang| [ll(lang.to_s, :general_lang_name), lang.to_s]}.
@@ -103,6 +103,7 module Redmine
103 languages_options :cache => false
103 languages_options :cache => false
104 end
104 end
105 end
105 end
106 options.map {|name, lang| [name.force_encoding("UTF-8"), lang.force_encoding("UTF-8")]}
106 end
107 end
107
108
108 def find_language(lang)
109 def find_language(lang)
@@ -199,6 +199,11 class Redmine::I18nTest < ActiveSupport::TestCase
199 assert_include [ja, "ja"], options
199 assert_include [ja, "ja"], options
200 end
200 end
201
201
202 def test_languages_options_should_return_strings_with_utf8_encoding
203 strings = languages_options.flatten
204 assert_equal ["UTF-8"], strings.map(&:encoding).uniq.map(&:name).sort
205 end
206
202 def test_languages_options_should_ignore_locales_without_general_lang_name_key
207 def test_languages_options_should_ignore_locales_without_general_lang_name_key
203 stubs(:valid_languages).returns([:en, :foo])
208 stubs(:valid_languages).returns([:en, :foo])
204 assert_equal [["English", "en"]], languages_options(:cache => false)
209 assert_equal [["English", "en"]], languages_options(:cache => false)
General Comments 0
You need to be logged in to leave comments. Login now