From 158a01f2b7a83c634827c220d7d27c507672d740 Mon Sep 17 00:00:00 2001 From: Toshi MARUYAMA Date: Fri, 26 Dec 2014 16:06:44 +0000 Subject: [PATCH] 2.6-stable: fix r13807 on Ruby 1.8.7 git-svn-id: http://svn.redmine.org/redmine/branches/2.6-stable@13817 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- lib/redmine/i18n.rb | 8 +++++++- test/unit/lib/redmine/i18n_test.rb | 6 ++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/lib/redmine/i18n.rb b/lib/redmine/i18n.rb index 959831986..89dacb0cb 100644 --- a/lib/redmine/i18n.rb +++ b/lib/redmine/i18n.rb @@ -103,7 +103,13 @@ module Redmine languages_options :cache => false end end - options.map {|name, lang| [name.force_encoding("UTF-8"), lang.force_encoding("UTF-8")]} + options.map do |name, lang| + n = name + l = lang + n.force_encoding("UTF-8") if n.respond_to?(:force_encoding) + l.force_encoding("UTF-8") if l.respond_to?(:force_encoding) + [n, l] + end end def find_language(lang) diff --git a/test/unit/lib/redmine/i18n_test.rb b/test/unit/lib/redmine/i18n_test.rb index 1cb7a3d0f..256fcb0e3 100644 --- a/test/unit/lib/redmine/i18n_test.rb +++ b/test/unit/lib/redmine/i18n_test.rb @@ -199,8 +199,10 @@ class Redmine::I18nTest < ActiveSupport::TestCase 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 + if "".respond_to?(:force_encoding) + strings = languages_options.flatten + assert_equal ["UTF-8"], strings.map(&:encoding).uniq.map(&:name).sort + end end def test_languages_options_should_ignore_locales_without_general_lang_name_key -- 2.39.5