module 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 126 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 134 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 150 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 142 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 91 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 100 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 106 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 118 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 112 def ds_(domain, key, separator=nil, &block) _in_domain domain do FastGettext::Translation.s_(key, separator, &block) end end