Module: HammerCLI::I18n::Debug

Defined in:
lib/hammer_cli/i18n.rb

Overview

include this module to see translations highlighted

Constant Summary collapse

DL =
'>'
DR =
'<'

Instance Method Summary collapse

Instance Method Details

#_(key) ⇒ Object

slightly modified copy of fast_gettext D_* method



31
32
33
34
35
36
37
# File 'lib/hammer_cli/i18n.rb', line 31

def _(key)
  FastGettext.translation_repositories.each_key do |domain|
    result = FastGettext::TranslationMultidomain.d_(domain, key) {nil}
    return DL + result + DR unless result.nil?
  end
  DL + key + DR
end

#n_(*keys) ⇒ Object

slightly modified copy of fast_gettext D_* method



40
41
42
43
44
45
46
# File 'lib/hammer_cli/i18n.rb', line 40

def n_(*keys)
  FastGettext.translation_repositories.each_key do |domain|
    result = FastGettext::TranslationMultidomain.dn_(domain, *keys) {nil}
    return DL + result + DR unless result.nil?
  end
  DL + keys[-3].split(keys[-2]||FastGettext::NAMESPACE_SEPARATOR).last + DR
end

#ns_(*keys) ⇒ Object

slightly modified copy of fast_gettext D_* method



58
59
60
61
62
63
64
# File 'lib/hammer_cli/i18n.rb', line 58

def ns_(*keys)
  FastGettext.translation_repositories.each_key do |domain|
    result = FastGettext::TranslationMultidomain.dns_(domain, *keys) {nil}
    return DL + result + DR unless result.nil?
  end
  DL + keys[-2].split(FastGettext::NAMESPACE_SEPARATOR).last + DR
end

#s_(key, separator = nil) ⇒ Object

slightly modified copy of fast_gettext D_* method



49
50
51
52
53
54
55
# File 'lib/hammer_cli/i18n.rb', line 49

def s_(key, separator=nil)
  FastGettext.translation_repositories.each_key do |domain|
    result = FastGettext::TranslationMultidomain.ds_(domain, key, separator) {nil}
    return DL + result + DR unless result.nil?
  end
  DL + key.split(separator||FastGettext::NAMESPACE_SEPARATOR).last + DR
end