summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2012-11-18 18:01:24 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2012-11-18 18:01:24 +0000
commita49de1c39d1292259580ed6db1f6e455259094ff (patch)
treed6007302f34ce91dee43acce6304a002c9c7cc5c /lib
parent3739810afa3545e6747a9111185dc8808fff6078 (diff)
downloadredmine-a49de1c39d1292259580ed6db1f6e455259094ff.tar.gz
redmine-a49de1c39d1292259580ed6db1f6e455259094ff.zip
Cache languages names to avoid loading all translations files.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@10844 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'lib')
-rw-r--r--lib/redmine/i18n.rb10
1 files changed, 10 insertions, 0 deletions
diff --git a/lib/redmine/i18n.rb b/lib/redmine/i18n.rb
index 304175ee5..e48db09b4 100644
--- a/lib/redmine/i18n.rb
+++ b/lib/redmine/i18n.rb
@@ -70,6 +70,16 @@ module Redmine
::I18n.available_locales
end
+ # 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
+ end
+
def find_language(lang)
@@languages_lookup = valid_languages.inject({}) {|k, v| k[v.to_s.downcase] = v; k }
@@languages_lookup[lang.to_s.downcase]