Class: FastGettext::TranslationRepository::Db

### Home Classes Methods

### In Files

- lib/fast_gettext/translation_repository/db.rb

### Parent

Object

### Methods

- ::included
- ::new
- ::require_models
- ::seperator
- ::seperator=
- #[]
- #available_locales
- #plural
- #pluralisation_rule

### Class/Module Index

Quicksearch

- FastGettext
- 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.

# FastGettext::TranslationRepository::Db

Responsibility:

    - provide access to translations in database through a database abstraction

    Options:
     :model => Model that represents your keys
     you can either use the models supplied under db/, extend them or build your own
     only constraints:
       key: find_by_key, translations
       translation: text, locale

### Public Class Methods

included(base) click to toggle source

    # File lib/fast_gettext/translation_repository/db.rb, line 55
    def self.included(base)
      puts "you no longer need to include the result of require_models"
    end

new(name,options={}) click to toggle source

    # File lib/fast_gettext/translation_repository/db.rb, line 14
    def initialize(name,options={})
      @model = options[:model]
    end

require_models() click to toggle source

    # File lib/fast_gettext/translation_repository/db.rb, line 50
    def self.require_models
      folder = "fast_gettext/translation_repository/db_models"
      require "#{folder}/translation_key"
      require "#{folder}/translation_text"
      Module.new do
        def self.included(base)
          puts "you no longer need to include the result of require_models"
        end
      end
    end

seperator() click to toggle source

    # File lib/fast_gettext/translation_repository/db.rb, line 20
    def self.seperator;@@seperator;end

seperator=(sep) click to toggle source

    # File lib/fast_gettext/translation_repository/db.rb, line 19
    def self.seperator=(sep);@@seperator = sep;end

### Public Instance Methods

[](key) click to toggle source

    # File lib/fast_gettext/translation_repository/db.rb, line 38
    def [](key)
      @model.translation(key, FastGettext.locale)
    end

available_locales() click to toggle source

    # File lib/fast_gettext/translation_repository/db.rb, line 22
    def available_locales
      if @model.respond_to? :available_locales
        @model.available_locales || []
      else
        []
      end
    end

plural(*args) click to toggle source

    # File lib/fast_gettext/translation_repository/db.rb, line 42
    def plural(*args)
      if translation = @model.translation(args*self.class.seperator, FastGettext.locale)
        translation.to_s.split(self.class.seperator)
      else
        []
      end
    end

pluralisation_rule() click to toggle source

    # File lib/fast_gettext/translation_repository/db.rb, line 30
    def pluralisation_rule
      if @model.respond_to? :pluralsation_rule
        @model.pluralsation_rule
      else
        nil
      end
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.