Module: FastGettext::TranslationMultidomain

### Home Classes Methods

### In Files

- lib/fast_gettext/translation.rb

### Methods

- #D_
- #Dn_
- #Dns_
- #Ds_
- #_in_domain
- #d_
- #dn_
- #dns_
- #ds_

### 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::TranslationMultidomain

this module should be included for multi-domain support

### Public Instance Methods

D_(key) click to toggle source

gettext functions to translate in the context of any domain (note: if mutiple domains contains key, random translation is returned)

    # File lib/fast_gettext/translation.rb, line 118
    def D_(key)
      FastGettext.translation_repositories.each_key do |domain|
        result = FastGettext::TranslationMultidomain.d_(domain, key) {nil}
        return result unless result.nil?
      end
      key
    end

Dn_(*keys) click to toggle source

    # File lib/fast_gettext/translation.rb, line 126
    def Dn_(*keys)
      FastGettext.translation_repositories.each_key do |domain|
        result = FastGettext::TranslationMultidomain.dn_(domain, *keys) {nil}
        return result unless result.nil?
      end
      keys[-3].split(keys[-2]||NAMESPACE_SEPARATOR).last
    end

Dns_(*keys) click to toggle source

    # File lib/fast_gettext/translation.rb, line 142
    def Dns_(*keys)
      FastGettext.translation_repositories.each_key do |domain|
        result = FastGettext::TranslationMultidomain.dns_(domain, *keys) {nil}
        return result unless result.nil?
      end
      keys[-2].split(NAMESPACE_SEPARATOR).last
    end

Ds_(key, separator=nil) click to toggle source

    # File lib/fast_gettext/translation.rb, line 134
    def Ds_(key, separator=nil)
      FastGettext.translation_repositories.each_key do |domain|
        result = FastGettext::TranslationMultidomain.ds_(domain, key, separator) {nil}
        return result unless result.nil?
      end
      key.split(separator||NAMESPACE_SEPARATOR).last
    end

_in_domain(domain) click to toggle source

helper block for changing domains

    # File lib/fast_gettext/translation.rb, line 83
    def _in_domain domain
      old_domain = FastGettext.text_domain
      FastGettext.text_domain = domain
      yield if block_given?
    ensure
      FastGettext.text_domain = old_domain
    end

d_(domain, key, &block) click to toggle source

gettext functions to translate in the context of given domain

    # File lib/fast_gettext/translation.rb, line 92
    def d_(domain, key, &block)
      _in_domain domain do
        FastGettext::Translation._(key, &block)
      end
    end

dn_(domain, *keys, &block) click to toggle source

    # File lib/fast_gettext/translation.rb, line 98
    def dn_(domain, *keys, &block)
      _in_domain domain do
        FastGettext::Translation.n_(*keys, &block)
      end
    end

dns_(domain, *keys, &block) click to toggle source

    # File lib/fast_gettext/translation.rb, line 110
    def dns_(domain, *keys, &block)
      _in_domain domain do
        FastGettext::Translation.ns_(*keys, &block)
      end
    end

ds_(domain, key, separator=nil, &block) click to toggle source

    # File lib/fast_gettext/translation.rb, line 104
    def ds_(domain, key, separator=nil, &block)
      _in_domain domain do
        FastGettext::Translation.s_(key, separator, &block)
      end
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.