Module: Slang::Helpers
- Included in:
- Slang
- Defined in:
- lib/slang.rb
Overview
Slang helpers module.
Instance Method Summary collapse
-
#locale_code ⇒ Symbol
Returns the locale code for the current Thread or Fiber.
-
#locale_code=(locale_code) ⇒ Object
Sets the current locale code (for the current Thread or Fiber).
-
#t(key, variable_hash = {}) ⇒ String
Get the content / translation for the given key.
Instance Method Details
#locale_code ⇒ Symbol
Returns the locale code for the current Thread or Fiber.
53 54 55 |
# File 'lib/slang.rb', line 53 def locale_code Thread.current[:slang_locale_code] ||= :en end |
#locale_code=(locale_code) ⇒ Object
Sets the current locale code (for the current Thread or Fiber).
61 62 63 |
# File 'lib/slang.rb', line 61 def locale_code=(locale_code) Thread.current[:slang_locale_code] = locale_code.to_sym end |
#t(key, variable_hash = {}) ⇒ String
Get the content / translation for the given key.
In development mode, if a key is not found, a human-readable placeholder is returned (and the missing key is reported to the Slang service).
In production mode, if a key is not found, a placeholder string of the form “{locale_code:key}” is returned.
45 46 47 |
# File 'lib/slang.rb', line 45 def t(key, variable_hash={}) Slang.internal_translate(key, variable_hash) end |