1
0
mirror of https://github.com/meineerde/redmine.git synced 2026-01-04 06:39:38 +00:00

Force UTF-8 encoding of language names.

git-svn-id: http://svn.redmine.org/redmine/trunk@13807 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Jean-Philippe Lang 2014-12-26 11:38:52 +00:00
parent 12890945e5
commit 3fcd683e6b
2 changed files with 7 additions and 1 deletions

View 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)

View File

@ -199,6 +199,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)