Module: Babylonia::HelperMethods

Defined in:
lib/babylonia/class_methods.rb

Overview

Helper Methods for locales

Author:

  • Beat Richartz

Since:

  • 0.0.1

Version:

  • 0.0.2

Instance Method Summary collapse

Instance Method Details

#available_localesArray

Return all the available locales

Returns:

  • (Array)

    An array of symbols of all available locales

Since:

  • 0.0.1



55
56
57
# File 'lib/babylonia/class_methods.rb', line 55

def available_locales
  evaluate_localization_option!(:available_locales)
end

#default_localeSymbol

Return the default locale for the object

Returns:

  • (Symbol)

    The currently active locale

Since:

  • 0.0.1



27
28
29
# File 'lib/babylonia/class_methods.rb', line 27

def default_locale
  evaluate_localization_option!(:default_locale)
end

#has_available_locale?(locale) ⇒ Boolean

Return if a locale is theoretically available in all translated fields

Returns:

  • (Boolean)

    True if the language is available

Since:

  • 0.0.1



62
63
64
# File 'lib/babylonia/class_methods.rb', line 62

def has_available_locale? locale
  available_locales.include?(locale.to_sym)
end

#has_locale?(locale) ⇒ Boolean

Return if a translation in the language is stored in all translated fields

Returns:

  • (Boolean)

    True if a translation is stored

Since:

  • 0.0.1



48
49
50
# File 'lib/babylonia/class_methods.rb', line 48

def has_locale? locale
  locales.include?(locale.to_sym)
end

#localeSymbol

Return the currently active locale for the object

Returns:

  • (Symbol)

    The currently active locale

Since:

  • 0.0.1



20
21
22
# File 'lib/babylonia/class_methods.rb', line 20

def locale
  evaluate_localization_option!(:locale)
end

#locale_fallback?Boolean

Return if the object falls back on translations

Returns:

  • (Boolean)

    if the translations fall back to the default locale

Since:

  • 0.0.1



34
35
36
# File 'lib/babylonia/class_methods.rb', line 34

def locale_fallback?
  evaluate_localization_option!(:fallback)
end

#missing_translation_placeholder(field) ⇒ String

Return the missing translation placeholder

Returns:

  • (String)

    The missing translation placeholder

Since:

  • 0.0.1



41
42
43
# File 'lib/babylonia/class_methods.rb', line 41

def missing_translation_placeholder field
  evaluate_localization_option!(:placeholder, field)
end