module LostInTranslations::Base

Public Class Methods

included(base_class) click to toggle source
# File lib/lost_in_translations/base.rb, line 3
def self.included(base_class)
  LostInTranslations.infected_classes.push(base_class)

  base_class.extend ClassMethods
end

Public Instance Methods

assign_translation(field, value, locale = I18n.locale) click to toggle source
# File lib/lost_in_translations/base.rb, line 19
def assign_translation(field, value, locale = I18n.locale)
  LostInTranslations.assign_translation(self, field, value, locale)
end
fallback_to_default_locale(locale) click to toggle source
# File lib/lost_in_translations/base.rb, line 23
def fallback_to_default_locale(locale)
  LostInTranslations.config.fallback_to_default_locale ||
    locale.to_sym == I18n.default_locale.to_sym
end
translate(field, locale = I18n.locale) click to toggle source
# File lib/lost_in_translations/base.rb, line 9
def translate(field, locale = I18n.locale)
  translation = LostInTranslations.translate(self, field, locale)

  if translation.nil? && fallback_to_default_locale(locale)
    translation = call_original_field(self, field)
  end

  translation
end