mirror of
https://github.com/meineerde/redmine.git
synced 2026-04-01 21:51:14 +00:00
Ignore locales without :general_lang_name key (#18110).
git-svn-id: http://svn.redmine.org/redmine/trunk@13450 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
parent
ff9be52e45
commit
6bdef3ca64
@ -90,11 +90,19 @@ module Redmine
|
|||||||
# Returns an array of languages names and code sorted by names, example:
|
# Returns an array of languages names and code sorted by names, example:
|
||||||
# [["Deutsch", "de"], ["English", "en"] ...]
|
# [["Deutsch", "de"], ["English", "en"] ...]
|
||||||
#
|
#
|
||||||
# The result is cached to prevent from loading all translations files.
|
# The result is cached to prevent from loading all translations files
|
||||||
def languages_options
|
# unless :cache => false option is given
|
||||||
ActionController::Base.cache_store.fetch "i18n/languages_options" do
|
def languages_options(options={})
|
||||||
valid_languages.map {|lang| [ll(lang.to_s, :general_lang_name), lang.to_s]}.sort {|x,y| x.first <=> y.first }
|
if options[:cache] == false
|
||||||
end
|
valid_languages.
|
||||||
|
select {|locale| ::I18n.exists?(:general_lang_name, locale)}.
|
||||||
|
map {|lang| [ll(lang.to_s, :general_lang_name), lang.to_s]}.
|
||||||
|
sort {|x,y| x.first <=> y.first }
|
||||||
|
else
|
||||||
|
ActionController::Base.cache_store.fetch "i18n/languages_options" do
|
||||||
|
languages_options :cache => false
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def find_language(lang)
|
def find_language(lang)
|
||||||
|
|||||||
@ -198,6 +198,11 @@ class Redmine::I18nTest < ActiveSupport::TestCase
|
|||||||
assert_include [ja, "ja"], options
|
assert_include [ja, "ja"], options
|
||||||
end
|
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)
|
||||||
|
end
|
||||||
|
|
||||||
def test_locales_validness
|
def test_locales_validness
|
||||||
lang_files_count = Dir["#{Rails.root}/config/locales/*.yml"].size
|
lang_files_count = Dir["#{Rails.root}/config/locales/*.yml"].size
|
||||||
assert_equal lang_files_count, valid_languages.size
|
assert_equal lang_files_count, valid_languages.size
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user