Class: TranslationKey

### Home Classes Methods

### In Files

- lib/fast_gettext/translation_repository/db_models/translation_key.rb

### Parent

ActiveRecord::Base

### Methods

- ::available_locales
- ::newline_normalize
- ::translation
- #normalize_newlines

### Class/Module Index

Quicksearch

- FastGettext
- FastGettext::Cache
- FastGettext::GetText
- FastGettext::GetText::MOFile
- FastGettext::GetText::MOFile::HeaderRev1
- FastGettext::GetText::MOFile::InvalidFormat
- FastGettext::GetText::PoParser
- FastGettext::MoFile
- FastGettext::PoFile
- FastGettext::Storage
- FastGettext::Storage::NoTextDomainConfigured
- FastGettext::Translation
- FastGettext::TranslationMultidomain
- FastGettext::TranslationRepository
- FastGettext::TranslationRepository::Base
- FastGettext::TranslationRepository::Chain
- FastGettext::TranslationRepository::Db
- FastGettext::TranslationRepository::Logger
- FastGettext::TranslationRepository::Mo
- FastGettext::TranslationRepository::Po
- FastGettext::TranslationRepository::Yaml
- String
- TranslationKey
- TranslationText

No matching classes.

# TranslationKey

### Public Class Methods

available_locales() click to toggle source

    # File lib/fast_gettext/translation_repository/db_models/translation_key.rb, line 21
    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 15
    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 33
    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 37
    def normalize_newlines
      self.key = self.class.newline_normalize(key)
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.