class TranslationKey

Public Class Methods

available_locales() click to toggle source
# 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) click to toggle source
# 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

Protected Class Methods

newline_normalize(s) click to toggle source
# File lib/fast_gettext/translation_repository/db_models/translation_key.rb, line 31
def self.newline_normalize(s)
  s.to_s.gsub("\r\n", "\n")
end

Protected Instance Methods

normalize_newlines() click to toggle source
# File lib/fast_gettext/translation_repository/db_models/translation_key.rb, line 35
def normalize_newlines
  self.key = self.class.newline_normalize(key)
end