Class: Liquid::I18n
- Inherits:
-
Object
- Object
- Liquid::I18n
- Defined in:
- lib/liquid/i18n.rb
Defined Under Namespace
Classes: TranslationError
Constant Summary collapse
- DEFAULT_LOCALE =
File.join(File.(File.dirname(__FILE__)), "locales", "en.yml")
Instance Attribute Summary collapse
-
#path ⇒ Object
readonly
Returns the value of attribute path.
Instance Method Summary collapse
-
#initialize(path = DEFAULT_LOCALE) ⇒ I18n
constructor
A new instance of I18n.
- #locale ⇒ Object
- #translate(name, vars = {}) ⇒ Object (also: #t)
Constructor Details
#initialize(path = DEFAULT_LOCALE) ⇒ I18n
Returns a new instance of I18n.
12 13 14 |
# File 'lib/liquid/i18n.rb', line 12 def initialize(path = DEFAULT_LOCALE) @path = path end |
Instance Attribute Details
#path ⇒ Object (readonly)
Returns the value of attribute path.
10 11 12 |
# File 'lib/liquid/i18n.rb', line 10 def path @path end |
Instance Method Details
#locale ⇒ Object
21 22 23 |
# File 'lib/liquid/i18n.rb', line 21 def locale @locale ||= YAML.load_file(@path) end |
#translate(name, vars = {}) ⇒ Object Also known as: t
16 17 18 |
# File 'lib/liquid/i18n.rb', line 16 def translate(name, vars = {}) interpolate(deep_fetch_translation(name), vars) end |