]> source.dussan.org Git - redmine.git/commitdiff
Merged r13807.
authorJean-Philippe Lang <jp_lang@yahoo.fr>
Fri, 26 Dec 2014 11:41:05 +0000 (11:41 +0000)
committerJean-Philippe Lang <jp_lang@yahoo.fr>
Fri, 26 Dec 2014 11:41:05 +0000 (11:41 +0000)
git-svn-id: http://svn.redmine.org/redmine/branches/2.6-stable@13808 e93f8b46-1217-0410-a6f0-8f06a7374b81

lib/redmine/i18n.rb
test/unit/lib/redmine/i18n_test.rb

index 3e783170fb68dbd2c4181c02b2bdd1b0c694a308..95983198649fcbcc7282ec0aa8528e9d0ae7030b 100644 (file)
@@ -93,7 +93,7 @@ module Redmine
     # 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]}.
@@ -103,6 +103,7 @@ module Redmine
           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)
index 6d35614866d8b21735ed184737b7bd0e8d4d83f8..1cb7a3d0f0b194c82e32a28a9e0709c659199290 100644 (file)
@@ -198,6 +198,11 @@ class Redmine::I18nTest < ActiveSupport::TestCase
     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)