Sha256: 67b11b3fb7939a7c003982d667018cf757ee0a13eecdac18133a6d0cada6caa0

Contents?: true

Size: 1.1 KB

Versions: 21

Compression:

Stored size: 1.1 KB

Contents

module Localeapp
  MissingTranslationRecord = Struct.new(:key, :locale, :description, :options)

  class MissingTranslations
    def initialize
      @translations = Hash.new { |h, k| h[k] = {} }
    end

    def add(locale, key, description = nil, options = {})
      record = MissingTranslationRecord.new(key, locale, description, options)
      @translations[locale][key] = record
    end

    def [](locale)
      @translations[locale]
    end

    # This method will get cleverer so we don't resend keys we've
    # already sent, or send multiple times for the same locale etc.
    # For now it's pretty dumb
    def to_send
      data = []
      # need the sort to make specs work under 1.8
      @translations.sort { |a, b| a.to_s <=> b.to_s }.each do |locale, records|
        records.each do |key, record|
          missing_data = {}
          missing_data[:key] = key
          missing_data[:locale] = locale
          missing_data[:description] = record.description if record.description
          missing_data[:options] = record.options
          data << missing_data
        end
      end
      data
    end
  end
end

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
localeapp-0.6.9 lib/localeapp/missing_translations.rb
localeapp-0.6.8 lib/localeapp/missing_translations.rb
localeapp-0.6.7 lib/localeapp/missing_translations.rb
localeapp-0.6.6 lib/localeapp/missing_translations.rb
localeapp-0.6.5 lib/localeapp/missing_translations.rb
localeapp-0.6.4 lib/localeapp/missing_translations.rb
localeapp-0.6.3 lib/localeapp/missing_translations.rb
localeapp-0.6.2 lib/localeapp/missing_translations.rb
localeapp-0.6.1 lib/localeapp/missing_translations.rb
localeapp-0.6.0 lib/localeapp/missing_translations.rb
localeapp-0.5.2 lib/localeapp/missing_translations.rb
localeapp-0.5.1 lib/localeapp/missing_translations.rb
localeapp-0.5.0 lib/localeapp/missing_translations.rb
localeapp-0.4.3 lib/localeapp/missing_translations.rb
localeapp-0.4.2 lib/localeapp/missing_translations.rb
localeapp-0.4.1 lib/localeapp/missing_translations.rb
localeapp-0.4.0 lib/localeapp/missing_translations.rb
localeapp-0.3.2 lib/localeapp/missing_translations.rb
localeapp-0.3.1 lib/localeapp/missing_translations.rb
localeapp-0.3.0 lib/localeapp/missing_translations.rb