Sha256: ea8d71557bc6e8cbb1f2906e2f1c83442bb18561f2dd006fe5e9818798725422

Contents?: true

Size: 1.3 KB

Versions: 1

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

1 entries across 1 versions & 1 rubygems

Version Path
awesome_translations-0.0.59 lib/awesome_translations/cache_database_generator/handler_translation.rb