Module: Rabbit::GetText

Constant Summary collapse

DOMAIN =
"rabbit"

Class Method Summary collapse

Class Method Details

._(msgid) ⇒ Object



71
72
73
# File 'lib/rabbit/gettext.rb', line 71

def _(msgid)
  ::GetText.gettext(msgid)
end

.bindtextdomain(path = nil, locale = nil, charset = nil) ⇒ Object



52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# File 'lib/rabbit/gettext.rb', line 52

def bindtextdomain(path=nil, locale=nil, charset=nil)
  if Rabbit::Config.const_defined?(:GETTEXT_PATH)
    path ||= Rabbit::Config::GETTEXT_PATH
  end
  charset ||= "UTF-8"
  ::GetText.bindtextdomain(DOMAIN, path, locale, charset)
  if defined?(::GetText::TextDomainManager) and path
    if ::GetText::TextDomainManager.respond_to?(:textdomain)
      # workaround for Ruby-GetText 1.6.0 < 2.0.0
      textdomain = ::GetText::TextDomainManager.textdomain(DOMAIN)
      locale_paths = ["#{path}/%{locale}/LC_MESSAGES/%{name}.mo",
                    "#{path}/%{locale}/%{name}.mo"]
      textdomain.locale_paths.concat(locale_paths)
      locale ||= textdomain.current_locale || Locale.get
      textdomain.set_locale(locale, true)
    end
  end
end

.locale=(locale) ⇒ Object



79
80
81
# File 'lib/rabbit/gettext.rb', line 79

def locale=(locale)
  ::GetText.locale = locale
end

.N_(msgid) ⇒ Object



75
76
77
# File 'lib/rabbit/gettext.rb', line 75

def N_(msgid)
  msgid
end