Module: Tolk::ApplicationHelper
- Includes:
- Pagination::ViewHelper
- Defined in:
- app/helpers/tolk/application_helper.rb
Instance Method Summary collapse
- #boolean_warning ⇒ Object
- #format_i18n_text_area_value(value) ⇒ Object
- #format_i18n_value(value) ⇒ Object
- #highligh_interpolations(value) ⇒ Object
- #highlight_linebreaks(value) ⇒ Object
- #scope_selector_for(locale) ⇒ Object
- #tolk_locale_selection ⇒ Object
- #yaml_value(value) ⇒ Object
Methods included from Pagination::ViewHelper
Instance Method Details
#boolean_warning ⇒ Object
33 34 35 |
# File 'app/helpers/tolk/application_helper.rb', line 33 def boolean_warning '<span class="boolean">(Do not translate -- Enter true or false)</span>'.html_safe end |
#format_i18n_text_area_value(value) ⇒ Object
19 20 21 |
# File 'app/helpers/tolk/application_helper.rb', line 19 def format_i18n_text_area_value(value) yaml_value(value).to_s.force_encoding("UTF-8") end |
#format_i18n_value(value) ⇒ Object
5 6 7 8 9 |
# File 'app/helpers/tolk/application_helper.rb', line 5 def format_i18n_value(value) value = h(yaml_value(value)) value = highlight_linebreaks(value) value = highligh_interpolations(value) end |
#highligh_interpolations(value) ⇒ Object
15 16 17 |
# File 'app/helpers/tolk/application_helper.rb', line 15 def highligh_interpolations(value) value.gsub(/%{\w+}/, '<span class="interpolation" title="Leave this word untranslated">\0</span>').html_safe end |
#highlight_linebreaks(value) ⇒ Object
11 12 13 |
# File 'app/helpers/tolk/application_helper.rb', line 11 def highlight_linebreaks(value) value.gsub(/\n/, '<span class="carriage_return" title="Line break"><br /></span>').html_safe end |
#scope_selector_for(locale) ⇒ Object
44 45 46 47 |
# File 'app/helpers/tolk/application_helper.rb', line 44 def scope_selector_for(locale) select_tag 'scope', ([[Tolk::Locale.primary_locale.language_name, "origin"], [locale.language_name, "target"]], params[:scope]) end |
#tolk_locale_selection ⇒ Object
37 38 39 40 41 42 |
# File 'app/helpers/tolk/application_helper.rb', line 37 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 |