Module: TranslatesToFrench::InstanceMethods
- Defined in:
- lib/translates_to_french.rb
Instance Method Summary collapse
- #column_name_translated(name) ⇒ Object
- #column_value(column) ⇒ Object
- #regular_value(column) ⇒ Object
- #translated_value(column) ⇒ Object
- #translated_value_if_available(column) ⇒ Object
Instance Method Details
#column_name_translated(name) ⇒ Object
48 49 50 51 52 53 |
# File 'lib/translates_to_french.rb', line 48 def column_name_translated(name) if I18n.locale == 'fr' || I18n.locale == :fr column_name = "#{name}_fr" end self.class.column_names.include?(column_name) ? column_name.to_sym : "#{name}".to_sym end |
#column_value(column) ⇒ Object
24 25 26 27 28 29 30 |
# File 'lib/translates_to_french.rb', line 24 def column_value column if self[column_name_translated(column)] translated_value_if_available column else regular_value column end end |
#regular_value(column) ⇒ Object
44 45 46 |
# File 'lib/translates_to_french.rb', line 44 def regular_value column self[column] end |
#translated_value(column) ⇒ Object
40 41 42 |
# File 'lib/translates_to_french.rb', line 40 def translated_value column self[column_name_translated(column)] end |
#translated_value_if_available(column) ⇒ Object
32 33 34 35 36 37 38 |
# File 'lib/translates_to_french.rb', line 32 def translated_value_if_available column if self[column_name_translated(column)].length > 0 translated_value column else regular_value column end end |