Module: Remarkable::I18n
- Included in:
- Remarkable
- Defined in:
- lib/remarkable/i18n.rb
Overview
This is a wrapper for I18n default functionality.
Remarkable shouldn’t rely on I18n default locale, because it might change throughout tests. So it’s Remarkable responsibility to hold its own locale and send it to I18n.
Instance Method Summary collapse
-
#add_locale(*locales) ⇒ Object
Add locale files to I18n and to load path, if it exists.
-
#locale ⇒ Object
Get Remarkable own locale.
-
#locale=(locale) ⇒ Object
Set Remarkable own locale.
-
#localize(object, options = {}) ⇒ Object
(also: #l)
Wrapper for I18n.localize.
-
#translate(string, options = {}) ⇒ Object
(also: #t)
Wrapper for I18n.translate.
Instance Method Details
#add_locale(*locales) ⇒ Object
Add locale files to I18n and to load path, if it exists.
Examples
Remarkable.add_locale "path/to/locale"
16 17 18 19 |
# File 'lib/remarkable/i18n.rb', line 16 def add_locale(*locales) ::I18n.backend.load_translations *locales ::I18n.load_path += locales if ::I18n.respond_to?(:load_path) end |
#locale ⇒ Object
38 39 40 |
# File 'lib/remarkable/i18n.rb', line 38 def locale @@locale end |
#locale=(locale) ⇒ Object
27 28 29 |
# File 'lib/remarkable/i18n.rb', line 27 def locale=(locale) @@locale = locale end |
#localize(object, options = {}) ⇒ Object Also known as: l
Wrapper for I18n.localize
51 52 53 |
# File 'lib/remarkable/i18n.rb', line 51 def localize(object, = {}) ::I18n.localize object, { :locale => @@locale }.merge() end |
#translate(string, options = {}) ⇒ Object Also known as: t
Wrapper for I18n.translate
44 45 46 |
# File 'lib/remarkable/i18n.rb', line 44 def translate(string, = {}) ::I18n.translate string, { :locale => @@locale }.merge() end |