With this method we can translate define and automatically translate columns for the current rails locale.
Defining some columns like these:
m.col :string, :name_it, :name_en, :name_cz m.col :text, :description_it, :description_en, :description_cz
we can call
myinstance.name
or
puts myinstance.description
Lipsiadmin look for name_#{I18n.locale}
Methods
Public Instance methods
Define method missing to intercept calls to non-localized methods (eg. name instead of name_cz)
[ show source ]
# File lib/data_base/translate_attributes.rb, line 23
23: def method_missing(method_name, *arguments)
24: # puts "Trying to send '#{method_name}_#{I18n.locale}' to #{self.class}" # uncomment for easy debugging in script/console
25: return self.send("#{method_name}_#{I18n.locale}""#{method_name}_#{I18n.locale}") if self.respond_to?("#{method_name}_#{I18n.locale}""#{method_name}_#{I18n.locale}")
26: super
27: end