Module: I18n::Helpers::Gettext

Defined in:
lib/vendor/i18n/lib/i18n/helpers/gettext.rb

Overview

Implements classical Gettext style accessors. To use this include the module to the global namespace or wherever you want to use it.

include I18n::Helpers::Gettext

Instance Method Summary collapse

Instance Method Details

#_(msgid, options = {}) ⇒ Object



10
11
12
# File 'lib/vendor/i18n/lib/i18n/helpers/gettext.rb', line 10

def _(msgid, options = {})
  I18n.t(msgid, { :default => msgid, :separator => '|' }.merge(options))
end

#ngettext(msgid, msgid_plural, n = 1) ⇒ Object



23
24
25
# File 'lib/vendor/i18n/lib/i18n/helpers/gettext.rb', line 23

def ngettext(msgid, msgid_plural, n = 1)
  nsgettext(msgid, msgid_plural, n, nil)
end

#nsgettext(msgid, msgid_plural, n = 1, separator = nil) ⇒ Object



27
28
29
30
31
32
# File 'lib/vendor/i18n/lib/i18n/helpers/gettext.rb', line 27

def nsgettext(msgid, msgid_plural, n = 1, separator = nil)
  scope, msgid = I18n::Gettext.extract_scope(msgid, separator)
  default = { :one => msgid, :other => msgid_plural }
  msgid = [msgid, I18n::Gettext::PLURAL_SEPARATOR, msgid_plural].join
  I18n.t(msgid, :default => default, :count => n, :scope => scope)
end

#pgettext(msgctxt, msgid, separator = I18n::Gettext::CONTEXT_SEPARATOR) ⇒ Object



19
20
21
# File 'lib/vendor/i18n/lib/i18n/helpers/gettext.rb', line 19

def pgettext(msgctxt, msgid, separator = I18n::Gettext::CONTEXT_SEPARATOR)
  sgettext([msgctxt, msgid].join(separator), separator)
end

#sgettext(msgid, separator = '|') ⇒ Object



14
15
16
17
# File 'lib/vendor/i18n/lib/i18n/helpers/gettext.rb', line 14

def sgettext(msgid, separator = '|')
  scope, msgid = I18n::Gettext.extract_scope(msgid, separator)
  I18n.t(msgid, :scope => scope, :default => msgid)
end