Module: Nls
- Defined in:
- lib/dm_core/nls.rb
Overview
Constant Summary collapse
- CONTINENTS =
['Europe', 'North America', 'South America', 'Oceania', 'Asia', 'Africa', 'Antartica']
Instance Method Summary collapse
-
#nls(message_key, options = {}) ⇒ Object
default scope the msg lookup to the current theme ——————————————————————————.
-
#nls?(message_key) ⇒ Boolean
Check if the message exists ——————————————————————————.
-
#nls_flag_image(lang = nil) ⇒ Object
Helper to generate the image_tag for a language flag.
Instance Method Details
#nls(message_key, options = {}) ⇒ Object
default scope the msg lookup to the current theme
9 10 11 12 13 14 |
# File 'lib/dm_core/nls.rb', line 9 def nls(, = {}) #--- look up message in the scope of current theme, fallback to parent theme key = "#{Account.current.current_theme}.#{.to_s}" fallback = Account.current.parent_theme ? "#{Account.current.parent_theme}.#{.to_s}" : "translation missing: #{key}" I18n.t(key, .merge(default: fallback.to_sym)) end |
#nls?(message_key) ⇒ Boolean
Check if the message exists
18 19 20 21 |
# File 'lib/dm_core/nls.rb', line 18 def nls?() key = "#{Account.current.current_theme}.#{.to_s}" I18n.t key, :raise => true rescue false end |
#nls_flag_image(lang = nil) ⇒ Object
Helper to generate the image_tag for a language flag.
nls_flag_image(:en)
26 27 28 |
# File 'lib/dm_core/nls.rb', line 26 def nls_flag_image(lang = nil) image_tag(DmCore::Language.flag_image(lang)) end |