Class: I18n::Config
- Defined in:
- lib/active_support/vendor/i18n-0.3.7/i18n.rb
Instance Method Summary collapse
-
#available_locales ⇒ Object
Returns an array of locales for which translations are available.
-
#available_locales=(locales) ⇒ Object
Sets the available locales.
-
#backend ⇒ Object
Returns the current backend.
-
#backend=(backend) ⇒ Object
Sets the current backend.
-
#default_locale ⇒ Object
Returns the current default locale.
-
#default_locale=(locale) ⇒ Object
Sets the current default locale.
-
#default_separator ⇒ Object
Returns the current default scope separator.
-
#default_separator=(separator) ⇒ Object
Sets the current default scope separator.
-
#exception_handler ⇒ Object
Return the current exception handler.
-
#exception_handler=(exception_handler) ⇒ Object
Sets the exception handler.
-
#load_path ⇒ Object
Allow clients to register paths providing translation data sources.
-
#load_path=(load_path) ⇒ Object
Sets the load path instance.
-
#locale ⇒ Object
The only configuration value that is not global and scoped to thread is :locale.
-
#locale=(locale) ⇒ Object
Sets the current locale pseudo-globally, i.e.
Instance Method Details
#available_locales ⇒ Object
Returns an array of locales for which translations are available. Unless you explicitely set the these through I18n.available_locales= the call will be delegated to the backend and memoized on the I18n module.
53 54 55 |
# File 'lib/active_support/vendor/i18n-0.3.7/i18n.rb', line 53 def available_locales @@available_locales ||= backend.available_locales end |
#available_locales=(locales) ⇒ Object
Sets the available locales.
58 59 60 |
# File 'lib/active_support/vendor/i18n-0.3.7/i18n.rb', line 58 def available_locales=(locales) @@available_locales = locales end |
#backend ⇒ Object
Returns the current backend. Defaults to Backend::Simple
.
31 32 33 |
# File 'lib/active_support/vendor/i18n-0.3.7/i18n.rb', line 31 def backend @@backend ||= Backend::Simple.new end |
#backend=(backend) ⇒ Object
Sets the current backend. Used to set a custom backend.
36 37 38 |
# File 'lib/active_support/vendor/i18n-0.3.7/i18n.rb', line 36 def backend=(backend) @@backend = backend end |
#default_locale ⇒ Object
Returns the current default locale. Defaults to :βenβ
41 42 43 |
# File 'lib/active_support/vendor/i18n-0.3.7/i18n.rb', line 41 def default_locale @@default_locale ||= :en end |
#default_locale=(locale) ⇒ Object
Sets the current default locale. Used to set a custom default locale.
46 47 48 |
# File 'lib/active_support/vendor/i18n-0.3.7/i18n.rb', line 46 def default_locale=(locale) @@default_locale = locale.to_sym rescue nil end |
#default_separator ⇒ Object
Returns the current default scope separator. Defaults to β.β
63 64 65 |
# File 'lib/active_support/vendor/i18n-0.3.7/i18n.rb', line 63 def default_separator @@default_separator ||= '.' end |
#default_separator=(separator) ⇒ Object
Sets the current default scope separator.
68 69 70 |
# File 'lib/active_support/vendor/i18n-0.3.7/i18n.rb', line 68 def default_separator=(separator) @@default_separator = separator end |
#exception_handler ⇒ Object
Return the current exception handler. Defaults to :default_exception_handler.
73 74 75 |
# File 'lib/active_support/vendor/i18n-0.3.7/i18n.rb', line 73 def exception_handler @@exception_handler ||= :default_exception_handler end |
#exception_handler=(exception_handler) ⇒ Object
Sets the exception handler.
78 79 80 |
# File 'lib/active_support/vendor/i18n-0.3.7/i18n.rb', line 78 def exception_handler=(exception_handler) @@exception_handler = exception_handler end |
#load_path ⇒ Object
Allow clients to register paths providing translation data sources. The backend defines acceptable sources.
E.g. the provided SimpleBackend accepts a list of paths to translation files which are either named *.rb and contain plain Ruby Hashes or are named *.yml and contain YAML data. So for the SimpleBackend clients may register translation files like this:
I18n.load_path << 'path/to/locale/en.yml'
90 91 92 |
# File 'lib/active_support/vendor/i18n-0.3.7/i18n.rb', line 90 def load_path @@load_path ||= [] end |
#load_path=(load_path) ⇒ Object
Sets the load path instance. Custom implementations are expected to behave like a Ruby Array.
96 97 98 |
# File 'lib/active_support/vendor/i18n-0.3.7/i18n.rb', line 96 def load_path=(load_path) @@load_path = load_path end |
#locale ⇒ Object
The only configuration value that is not global and scoped to thread is :locale. It defaults to the default_locale.
21 22 23 |
# File 'lib/active_support/vendor/i18n-0.3.7/i18n.rb', line 21 def locale @locale ||= default_locale end |
#locale=(locale) ⇒ Object
Sets the current locale pseudo-globally, i.e. in the Thread.current hash.
26 27 28 |
# File 'lib/active_support/vendor/i18n-0.3.7/i18n.rb', line 26 def locale=(locale) @locale = locale.to_sym rescue nil end |