Module: ActiverecordI18n
- Defined in:
- lib/activerecord_i18n.rb,
lib/activerecord_i18n/engine.rb,
lib/activerecord_i18n/helper.rb,
lib/activerecord_i18n/railtie.rb,
lib/activerecord_i18n/version.rb,
lib/generators/activerecord_i18n/install_generator.rb
Defined Under Namespace
Modules: Generators, Helper
Classes: Engine, Railtie
Constant Summary
collapse
- VERSION =
'0.1.2'
Class Method Summary
collapse
Class Method Details
.get_item(key, default_value = nil) ⇒ Object
17
18
19
20
21
22
23
24
|
# File 'lib/activerecord_i18n.rb', line 17
def self.get_item(key, default_value=nil)
translation = ActiverecordI18nTranslation.where(key: key.downcase, locale: I18n.locale).first_or_create()
if !translation.value
translation.value = (default_value || '').gsub('-', ' ')
translation.save
end
return translation.value
end
|
.get_translation(key, default_value = nil, current_template = nil) ⇒ Object
12
13
14
15
|
# File 'lib/activerecord_i18n.rb', line 12
def self.get_translation(key, default_value=nil, current_template=nil)
path = (key[0] == '.' and current_template) ? current_template.virtual_path.gsub('/', '.') + key : key
return ActiverecordI18n.get_item(path, default_value || key)
end
|
.setup {|_self| ... } ⇒ Object
8
9
10
|
# File 'lib/activerecord_i18n.rb', line 8
def self.setup
yield self
end
|