Sha256: af8038dd0732aba898154e4c2c200070111489432f478a7ffa963cbc3ea742b0

Contents?: true

Size: 793 Bytes

Versions: 1

Compression:

Stored size: 793 Bytes

Contents

module FastGettext::TranslationRepository
  module DbModels
    class TranslationKey < ActiveRecord::Base
      has_many :translations, :class_name=>'TranslationText'
      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

      #this is only for ActiveSupport to get polymorphic_url FastGettext::... namespace free
      def self.model_name
        ActiveSupport::ModelName.new('TranslationKey')
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
grosser-fast_gettext-0.4.5 lib/fast_gettext/translation_repository/db_models/translation_key.rb