##// END OF EJS Templates
Merged r13807....
Jean-Philippe Lang -
r13426:8238e66fb1b3
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)
@@ -198,6 +198,11 class Redmine::I18nTest < ActiveSupport::TestCase
198 assert_include [ja, "ja"], options
198 assert_include [ja, "ja"], options
199 end
199 end
200
200
201 def test_languages_options_should_return_strings_with_utf8_encoding
202 strings = languages_options.flatten
203 assert_equal ["UTF-8"], strings.map(&:encoding).uniq.map(&:name).sort
204 end
205
201 def test_languages_options_should_ignore_locales_without_general_lang_name_key
206 def test_languages_options_should_ignore_locales_without_general_lang_name_key
202 stubs(:valid_languages).returns([:en, :foo])
207 stubs(:valid_languages).returns([:en, :foo])
203 assert_equal [["English", "en"]], languages_options(:cache => false)
208 assert_equal [["English", "en"]], languages_options(:cache => false)
General Comments 0
You need to be logged in to leave comments. Login now