module I18n::Gettext::Helpers - i18n-0.6.11 Documentation

# module I18n::Gettext::Helpers

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

    include I18n::Gettext::Helpers

### Public Instance Methods

_(msgid, options = {})
Alias for: gettext
gettext(msgid, options = {}) click to toggle source

    # File lib/i18n/gettext/helpers.rb, line 10
    def gettext(msgid, options = {})
      I18n.t(msgid, { :default => msgid, :separator => '|' }.merge(options))
    end

Also aliased as: _
n_(msgid, msgid_plural, n = 1)
Alias for: ngettext
ngettext(msgid, msgid_plural, n = 1) click to toggle source

    # File lib/i18n/gettext/helpers.rb, line 27
    def ngettext(msgid, msgid_plural, n = 1)
      nsgettext(msgid, msgid_plural, n)
    end

Also aliased as: n_
np_(msgctxt, msgid, msgid_plural, n = 1)
Alias for: npgettext
npgettext(msgctxt, msgid, msgid_plural, n = 1) click to toggle source

Method signatures:

    npgettext('Fruits', 'apple', 'apples', 2)
    npgettext('Fruits', ['apple', 'apples'], 2)

    # File lib/i18n/gettext/helpers.rb, line 50
    def npgettext(msgctxt, msgid, msgid_plural, n = 1)
      separator = I18n::Gettext::CONTEXT_SEPARATOR

      if msgid.is_a?(Array)
        msgid_plural, msgid, n = msgid[1], [msgctxt, msgid[0]].join(separator), msgid_plural
      else
        msgid = [msgctxt, msgid].join(separator)
      end

      nsgettext(msgid, msgid_plural, n, separator)
    end

Also aliased as: np_
ns_(msgid, msgid_plural, n = 1, separator = '|')
Alias for: nsgettext
nsgettext(msgid, msgid_plural, n = 1, separator = '|') click to toggle source

Method signatures:

    nsgettext('Fruits|apple', 'apples', 2)
    nsgettext(['Fruits|apple', 'apples'], 2)

    # File lib/i18n/gettext/helpers.rb, line 35
    def nsgettext(msgid, msgid_plural, n = 1, separator = '|')
      if msgid.is_a?(Array)
        msgid, msgid_plural, n, separator = msgid[0], msgid[1], msgid_plural, n
        separator = '|' unless separator.is_a?(::String)
      end

      scope, msgid = I18n::Gettext.extract_scope(msgid, separator)
      default = { :one => msgid, :other => msgid_plural }
      I18n.t(msgid, :default => default, :count => n, :scope => scope, :separator => separator)
    end

Also aliased as: ns_
p_(msgctxt, msgid)
Alias for: pgettext
pgettext(msgctxt, msgid) click to toggle source

    # File lib/i18n/gettext/helpers.rb, line 21
    def pgettext(msgctxt, msgid)
      separator = I18n::Gettext::CONTEXT_SEPARATOR
      sgettext([msgctxt, msgid].join(separator), separator)
    end

Also aliased as: p_
s_(msgid, separator = '|')
Alias for: sgettext
sgettext(msgid, separator = '|') click to toggle source

    # File lib/i18n/gettext/helpers.rb, line 15
    def sgettext(msgid, separator = '|')
      scope, msgid = I18n::Gettext.extract_scope(msgid, separator)
      I18n.t(msgid, :scope => scope, :default => msgid, :separator => separator)
    end

Also aliased as: s_