From: Jean-Philippe Lang Date: Mon, 27 Oct 2008 12:34:01 +0000 (+0000) Subject: Makes GLoc language global. X-Git-Tag: 0.8.0-RC1~140 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=6cd4f0c07ec77c82c6c84ac5c0d23869663dec0f;p=redmine.git Makes GLoc language global. git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@1957 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- diff --git a/vendor/plugins/gloc-1.1.0/lib/gloc.rb b/vendor/plugins/gloc-1.1.0/lib/gloc.rb index bcad0ed9b..8123785b7 100644 --- a/vendor/plugins/gloc-1.1.0/lib/gloc.rb +++ b/vendor/plugins/gloc-1.1.0/lib/gloc.rb @@ -52,7 +52,7 @@ module GLoc # Sets the current language for this instance/class. # Setting the language of a class effects all instances unless the instance has its own language defined. def set_language(language) - @gloc_language= language.nil? ? nil : language.to_sym + GLoc.current_language = language end # Sets the current language if the language passed is a valid language. @@ -75,7 +75,7 @@ module GLoc include ::GLoc::InstanceMethods # Returns the instance-level current language, or if not set, returns the class-level current language. def current_language - @gloc_language || self.class.current_language + GLoc.current_language end #--------------------------------------------------------------------------- @@ -87,7 +87,7 @@ module GLoc include ::GLoc::InstanceMethods # Returns the current language, or if not set, returns the GLoc current language. def current_language - @gloc_language || GLoc.current_language + GLoc.current_language end end @@ -103,10 +103,16 @@ module GLoc class << self include ::GLoc::InstanceMethods + + @@current_language = nil - # Returns the default language + # Returns the current language def current_language - GLoc::CONFIG[:default_language] + @@current_language || GLoc::CONFIG[:default_language] + end + + def current_language=(lang) + @@current_language = lang.blank? ? nil : lang.to_sym end # Adds a collection of localized strings to the in-memory string store.