Sha256: 1d11bca9bc37428b29560fdb65136a5fbef6372d509629bc374c76428c402204

Contents?: true

Size: 560 Bytes

Versions: 17

Compression:

Stored size: 560 Bytes

Contents

class TranslationKey < ActiveRecord::Base
  has_many :translations, :class_name => 'TranslationText'

  accepts_nested_attributes_for :translations, :allow_destroy => true

  validates_uniqueness_of :key
  validates_presence_of :key

  def self.translation(key, locale)
    return unless translation_key = find_by_key(key)
    return unless translation_text = translation_key.translations.find_by_locale(locale)
    translation_text.text
  end

  def self.available_locales
    @@available_locales ||= TranslationText.count(:group=>:locale).keys.sort
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
fast_gettext-0.6.8 lib/fast_gettext/translation_repository/db_models/translation_key.rb
fast_gettext-0.6.7 lib/fast_gettext/translation_repository/db_models/translation_key.rb
fast_gettext-0.6.6 lib/fast_gettext/translation_repository/db_models/translation_key.rb
fast_gettext-0.6.5 lib/fast_gettext/translation_repository/db_models/translation_key.rb
fast_gettext-0.6.4 lib/fast_gettext/translation_repository/db_models/translation_key.rb
fast_gettext-0.6.3 lib/fast_gettext/translation_repository/db_models/translation_key.rb
fast_gettext-0.6.2 lib/fast_gettext/translation_repository/db_models/translation_key.rb
fast_gettext-0.6.1 lib/fast_gettext/translation_repository/db_models/translation_key.rb
fast_gettext-0.6.0 lib/fast_gettext/translation_repository/db_models/translation_key.rb
fast_gettext-0.5.13 lib/fast_gettext/translation_repository/db_models/translation_key.rb
fast_gettext-0.5.12 lib/fast_gettext/translation_repository/db_models/translation_key.rb
fast_gettext-0.5.11 lib/fast_gettext/translation_repository/db_models/translation_key.rb
fast_gettext-0.5.10 lib/fast_gettext/translation_repository/db_models/translation_key.rb
fast_gettext-0.5.9 lib/fast_gettext/translation_repository/db_models/translation_key.rb
fast_gettext-0.5.8 lib/fast_gettext/translation_repository/db_models/translation_key.rb
fast_gettext-0.5.7 lib/fast_gettext/translation_repository/db_models/translation_key.rb
fast_gettext-0.5.6 lib/fast_gettext/translation_repository/db_models/translation_key.rb