Module: Admin::TranslationsHelper

Defined in:
app/helpers/admin/translations_helper.rb

Instance Method Summary collapse

Instance Method Details

#display_available_localesObject



4
5
6
# File 'app/helpers/admin/translations_helper.rb', line 4

def display_available_locales
  I18n.available_locales.map{|locale| t("translations.locales.#{locale}") }.join(", ")
end

#display_translation_if_exist(translation) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'app/helpers/admin/translations_helper.rb', line 8

def display_translation_if_exist(translation)
  other_locales = I18n.available_locales - [translation[:locale].to_sym]
  other_locale = other_locales.first
  if other_locale
    other_translation = Translation.find_by_key_and_locale(translation[:key], other_locale)
    if other_translation
      html = "<p>#{other_translation.value}</p>"
    else
      html = "<p class='no_translation'>#{t('translations.no_translation')}</p>"
    end
  else
    html = "<p class='no_translation'>#{t('translations.no_translation')}</p>"
  end
  raw html
end