Class: Utopia::Localization::Wrapper
- Inherits:
-
Object
- Object
- Utopia::Localization::Wrapper
- Defined in:
- lib/utopia/localization.rb
Overview
A wrapper to provide easy access to locale related data in the request.
Instance Method Summary collapse
-
#all_locales ⇒ Object
Returns an empty array if not localized.
-
#current_locale ⇒ Object
Returns the current locale or nil if not localized.
-
#default_locale ⇒ Object
Returns the default locale or nil if not localized.
-
#initialize(env) ⇒ Wrapper
constructor
A new instance of Wrapper.
- #localization ⇒ Object
Constructor Details
#initialize(env) ⇒ Wrapper
Returns a new instance of Wrapper.
28 29 30 |
# File 'lib/utopia/localization.rb', line 28 def initialize(env) @env = env end |
Instance Method Details
#all_locales ⇒ Object
Returns an empty array if not localized.
47 48 49 |
# File 'lib/utopia/localization.rb', line 47 def all_locales localization && localization.all_locales || [] end |
#current_locale ⇒ Object
Returns the current locale or nil if not localized.
37 38 39 |
# File 'lib/utopia/localization.rb', line 37 def current_locale @env[CURRENT_LOCALE_KEY] end |
#default_locale ⇒ Object
Returns the default locale or nil if not localized.
42 43 44 |
# File 'lib/utopia/localization.rb', line 42 def default_locale localization && localization.default_locale end |
#localization ⇒ Object
32 33 34 |
# File 'lib/utopia/localization.rb', line 32 def localization @env[LOCALIZATION_KEY] end |