Class: FastGettext::TranslationRepository::DbModels::TranslationKey

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
lib/fast_gettext/translation_repository/db_models/translation_key.rb

Class Method Summary collapse

Class Method Details

.available_localesObject



16
17
18
# File 'lib/fast_gettext/translation_repository/db_models/translation_key.rb', line 16

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

.model_nameObject

this is only for ActiveSupport to get polymorphic_url FastGettext::… namespace free



21
22
23
24
25
26
27
# File 'lib/fast_gettext/translation_repository/db_models/translation_key.rb', line 21

def self.model_name
  if defined? ActiveSupport::ModelName
    ActiveSupport::ModelName.new('TranslationKey')
  else
    'TranslationKey'
  end
end

.translation(key, locale) ⇒ Object



10
11
12
13
14
# File 'lib/fast_gettext/translation_repository/db_models/translation_key.rb', line 10

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