Sha256: fa43b0502b5bfd5227dbe65295389b66aa3a7d7a3c048f1d2245a9755b9799b3

Contents?: true

Size: 1.46 KB

Versions: 1

Compression:

Stored size: 1.46 KB

Contents

module I18nAdminUtils
  module ApplicationHelper

    #Show the number of translation missing with colorization
    def translation_missing_icon(translation)
      missing_translations = translation.missing_translations
      color_id = (missing_translations.size.to_f/translation.translations.size.to_f*5).ceil-1
      if missing_translations.size == 0
        content_tag 'span', '', :class => 'glyphicon glyphicon-ok greentext',
                    :title => 'This key has been translated in all languages', :rel => 'tooltip'
      else
        content_tag 'span', "(#{missing_translations.size})", :class => "color-range-#{color_id} bold",
                    :title => missing_translations.keys.join(','), :rel => 'tooltip'
      end
    end

    def translation_locations_compact_list(translation)
      if translation.locations.size == 0

        content_tag 'div', '', :class => 'translation_filename'
      elsif translation.locations.size == 1
        content_tag 'div', translation.locations.first[:filename].reverse, :class => 'translation_filename'
      else
        content = "#{translation.locations.first[:filename]} and #{translation.locations.size-1} more"
        title= translation.locations[1..-1].map { |x| "<div class='translation_filename'> #{x[:filename].reverse} </div>" }.join('')
        content_tag 'div', content.reverse, :class => 'translation_filename', :title => title, :rel => 'tooltip',
                    'data-html' => true
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
i18n_admin_utils-1.1.0 app/helpers/i18n_admin_utils/application_helper.rb