Module: Tolk::ApplicationHelper

Defined in:
app/helpers/tolk/application_helper.rb

Instance Method Summary collapse

Instance Method Details

#format_i18n_text_area_value(value) ⇒ Object



7
8
9
# File 'app/helpers/tolk/application_helper.rb', line 7

def format_i18n_text_area_value(value)
  yaml_value(value)
end

#format_i18n_value(value) ⇒ Object



3
4
5
# File 'app/helpers/tolk/application_helper.rb', line 3

def format_i18n_value(value)
  h(yaml_value(value)).gsub(/\n/, '<br />')
end

#scope_selector_for(locale) ⇒ Object



28
29
30
31
# File 'app/helpers/tolk/application_helper.rb', line 28

def scope_selector_for(locale)
  select_tag 'scope', options_for_select([[Tolk::Locale.primary_locale.language_name, "origin"],
                                          [locale.language_name, "target"]], params[:scope])
end

#tolk_locale_selectionObject



21
22
23
24
25
26
# File 'app/helpers/tolk/application_helper.rb', line 21

def tolk_locale_selection
  existing_locale_names = Tolk::Locale.all.map(&:name)

  pairs = Tolk.config.mapping.to_a.map(&:reverse).sort_by(&:first)
  pairs.reject {|pair| existing_locale_names.include?(pair.last) }
end

#yaml_value(value) ⇒ Object



11
12
13
14
15
16
17
18
19
# File 'app/helpers/tolk/application_helper.rb', line 11

def yaml_value(value)
  if value.present?
    unless value.is_a?(String)
      value = value.respond_to?(:ya2yaml) ? value.ya2yaml(:syck_compatible => true) : value.to_yaml
    end
  end
  
  value
end