Class: 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



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

def self.available_locales
  @@available_locales ||= begin
    if ActiveRecord::VERSION::MAJOR >= 3
      TranslationText.group(:locale).count
    else
      TranslationText.count(:group=>:locale)
    end.keys.sort
  end
end

.translation(key, locale) ⇒ Object



13
14
15
16
17
# File 'lib/fast_gettext/translation_repository/db_models/translation_key.rb', line 13

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