Sha256: eecbe2277e763a99b13f88be028b81dbb9ed78fe7e0a92c850cf1232d30e0b32

Contents?: true

Size: 1.3 KB

Versions: 20

Compression:

Stored size: 1.3 KB

Contents

class AwesomeTranslations::CacheDatabaseGenerator::HandlerTranslation < BazaModels::Model
  belongs_to :group, foreign_key: "group_id", class_name: "AwesomeTranslations::CacheDatabaseGenerator::Group"
  belongs_to :handler, foreign_key: "handler_id", class_name: "AwesomeTranslations::CacheDatabaseGenerator::Handler"
  belongs_to :translation_key, foreign_key: "translation_key_id", class_name: "AwesomeTranslations::CacheDatabaseGenerator::TranslationKey"

  validates_presence_of :handler, :translation_key

  delegate :key, :last_key, to: :translation_key
  delegate :value, to: :translation, prefix: true
  delegate :array_translation?, :file_line_content, :file_line_content?, :translated_value_for_locale, to: :translation

  def key_show_with_fallback
    key_show.presence || last_key
  end

  def translation
    @translation ||= AwesomeTranslations::Translation.new(
      key: key,
      dir: dir,
      full_path: full_path,
      file_path: file_path,
      line_no: line_no
    )
  end

  def finished?
    @_finished = translation.finished? if @finished.nil?
    @_finished
  end

  def unfinished?
    !finished?
  end

  def array_key
    return unless (match = key.match(/\A(.+)\[(\d+)\]\Z/))
    match[1]
  end

  def array_no
    return unless (match = key.match(/\A(.+)\[(\d+)\]\Z/))
    match[2].to_i
  end
end

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
awesome_translations-0.0.58 lib/awesome_translations/cache_database_generator/handler_translation.rb
awesome_translations-0.0.57 lib/awesome_translations/cache_database_generator/handler_translation.rb
awesome_translations-0.0.56 lib/awesome_translations/cache_database_generator/handler_translation.rb
awesome_translations-0.0.55 lib/awesome_translations/cache_database_generator/handler_translation.rb
awesome_translations-0.0.54 lib/awesome_translations/cache_database_generator/handler_translation.rb
awesome_translations-0.0.53 lib/awesome_translations/cache_database_generator/handler_translation.rb
awesome_translations-0.0.52 lib/awesome_translations/cache_database_generator/handler_translation.rb
awesome_translations-0.0.51 lib/awesome_translations/cache_database_generator/handler_translation.rb
awesome_translations-0.0.50 lib/awesome_translations/cache_database_generator/handler_translation.rb
awesome_translations-0.0.49 lib/awesome_translations/cache_database_generator/handler_translation.rb
awesome_translations-0.0.48 lib/awesome_translations/cache_database_generator/handler_translation.rb
awesome_translations-0.0.47 lib/awesome_translations/cache_database_generator/handler_translation.rb
awesome_translations-0.0.46 lib/awesome_translations/cache_database_generator/handler_translation.rb
awesome_translations-0.0.45 lib/awesome_translations/cache_database_generator/handler_translation.rb
awesome_translations-0.0.44 lib/awesome_translations/cache_database_generator/handler_translation.rb
awesome_translations-0.0.43 lib/awesome_translations/cache_database_generator/handler_translation.rb
awesome_translations-0.0.42 lib/awesome_translations/cache_database_generator/handler_translation.rb
awesome_translations-0.0.41 lib/awesome_translations/cache_database_generator/handler_translation.rb
awesome_translations-0.0.40 lib/awesome_translations/cache_database_generator/handler_translation.rb
awesome_translations-0.0.39 lib/awesome_translations/cache_database_generator/handler_translation.rb