Module: Fortitude::Widget::Localization::ClassMethods

Defined in:
lib/fortitude/widget/localization.rb

Instance Method Summary collapse

Instance Method Details

#_fortitude_ensure_translation_base_supported_if_needed!Object

INTERNAL USE ONLY



56
57
58
59
60
61
62
63
64
65
66
# File 'lib/fortitude/widget/localization.rb', line 56

def _fortitude_ensure_translation_base_supported_if_needed!
  unless equal?(::Fortitude::Widget)
    raise ArgumentError, "You must only ever call this on Fortitude::Widget, not #{self}"
  end

  if _fortitude_translation_base_support_needed?
    alias_method :t, :_fortitude_t_with_translation_base
  else
    alias_method :t, :_fortitude_t_without_translation_base
  end
end

#_fortitude_translation_base_support_needed?Boolean

INTERNAL USE ONLY

Returns:

  • (Boolean)


69
70
71
72
# File 'lib/fortitude/widget/localization.rb', line 69

def _fortitude_translation_base_support_needed?
  _fortitude_translation_base_support_needed_for_this_class? ||
    (direct_subclasses.any?(&:_fortitude_translation_base_support_needed?))
end

#_fortitude_translation_base_support_needed_for_this_class?Boolean

INTERNAL USE ONLY

Returns:

  • (Boolean)


75
76
77
# File 'lib/fortitude/widget/localization.rb', line 75

def _fortitude_translation_base_support_needed_for_this_class?
  translation_base && translation_base.to_s.strip.length > 0
end