diff options
author | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2014-10-18 09:07:51 +0000 |
---|---|---|
committer | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2014-10-18 09:07:51 +0000 |
commit | 6bdef3ca64f30c391c5433a5a7edfbbdf3c4fa14 (patch) | |
tree | baa6b3f5ada796a5a9a678a6d060e78eb77d22a7 /lib | |
parent | ff9be52e45ed67b3d57ccbfee62f7c230738109c (diff) | |
download | redmine-6bdef3ca64f30c391c5433a5a7edfbbdf3c4fa14.tar.gz redmine-6bdef3ca64f30c391c5433a5a7edfbbdf3c4fa14.zip |
Ignore locales without :general_lang_name key (#18110).
git-svn-id: http://svn.redmine.org/redmine/trunk@13450 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'lib')
-rw-r--r-- | lib/redmine/i18n.rb | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/lib/redmine/i18n.rb b/lib/redmine/i18n.rb index 11be1b613..3e783170f 100644 --- a/lib/redmine/i18n.rb +++ b/lib/redmine/i18n.rb @@ -90,11 +90,19 @@ module Redmine # Returns an array of languages names and code sorted by names, example: # [["Deutsch", "de"], ["English", "en"] ...] # - # The result is cached to prevent from loading all translations files. - def languages_options - ActionController::Base.cache_store.fetch "i18n/languages_options" do - valid_languages.map {|lang| [ll(lang.to_s, :general_lang_name), lang.to_s]}.sort {|x,y| x.first <=> y.first } - end + # 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 + 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 def find_language(lang) |