Sha256: 60815154e30d5ec94c20ed2e7e147bc650a30965c33c1a9a2871fb5ce6b200a5
Contents?: true
Size: 1.46 KB
Versions: 2
Compression:
Stored size: 1.46 KB
Contents
module Tolk module ApplicationHelper include Tolk::Pagination::ViewHelper def format_i18n_value(value) value = h(yaml_value(value)) value = highlight_linebreaks(value) value = highligh_interpolations(value) end def highlight_linebreaks(value) value.gsub(/\n/, '<span class="carriage_return" title="Line break"><br /></span>').html_safe end def highligh_interpolations(value) value.gsub(/%{\w+}/, '<span class="interpolation" title="Leave this word untranslated">\0</span>').html_safe end def format_i18n_text_area_value(value) yaml_value(value).to_s.dup.force_encoding("UTF-8") end def yaml_value(value) if value.present? unless value.is_a?(String) || value.is_a?(TrueClass) || value.is_a?(FalseClass) value = YAML.dump(value) end end value end def boolean_warning '<span class="boolean">(Do not translate -- Enter true or false)</span>'.html_safe end 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 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 end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
tolk-6.0.0 | app/helpers/tolk/application_helper.rb |
tolk-6.0.0.alpha1 | app/helpers/tolk/application_helper.rb |