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
35 36 37 |
# File 'app/helpers/tolk/application_helper.rb', line 35 def boolean_warning '<span class="boolean">(Do not translate -- Enter true or false)</span>'.html_safe end |
#format_i18n_text_area_value(value) ⇒ Object
21 22 23 |
# File 'app/helpers/tolk/application_helper.rb', line 21 def format_i18n_text_area_value(value) yaml_value(value).to_s.force_encoding("UTF-8") end |
#format_i18n_value(value) ⇒ Object
7 8 9 10 11 |
# File 'app/helpers/tolk/application_helper.rb', line 7 def format_i18n_value(value) value = h(yaml_value(value)) value = highlight_linebreaks(value) value = highligh_interpolations(value) end |
#highligh_interpolations(value) ⇒ Object
17 18 19 |
# File 'app/helpers/tolk/application_helper.rb', line 17 def highligh_interpolations(value) value.gsub(/%{\w+}/, '<span class="interpolation" title="Leave this word untranslated">\0</span>').html_safe end |
#highlight_linebreaks(value) ⇒ Object
13 14 15 |
# File 'app/helpers/tolk/application_helper.rb', line 13 def highlight_linebreaks(value) value.gsub(/\n/, '<span class="carriage_return" title="Line break"><br /></span>').html_safe end |
#scope_selector_for(locale) ⇒ Object
46 47 48 49 |
# File 'app/helpers/tolk/application_helper.rb', line 46 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
39 40 41 42 43 44 |
# File 'app/helpers/tolk/application_helper.rb', line 39 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 |