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::Helpers::Gettext

Public Instance Methods

_(msgid, options = {}) click to toggle source
Alias for: gettext
gettext(msgid, options = {}) click to toggle source
    # File lib/i18n/gettext/helpers.rb, line 11
11:       def gettext(msgid, options = {})
12:         I18n.t(msgid, { :default => msgid, :separator => '|' }.merge(options))
13:       end
Also aliased as: _
n_(msgid, msgid_plural, n = 1) click to toggle source
Alias for: ngettext
ngettext(msgid, msgid_plural, n = 1) click to toggle source
    # File lib/i18n/gettext/helpers.rb, line 28
28:       def ngettext(msgid, msgid_plural, n = 1)
29:         nsgettext(msgid, msgid_plural, n)
30:       end
Also aliased as: n_
np_(msgctxt, msgid, msgid_plural, n = 1) click to toggle source
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 51
51:       def npgettext(msgctxt, msgid, msgid_plural, n = 1)
52:         separator = I18n::Gettext::CONTEXT_SEPARATOR
53: 
54:         if msgid.is_a?(Array)
55:           msgid_plural, msgid, n = msgid[1], [msgctxt, msgid[0]].join(separator), msgid_plural
56:         else
57:           msgid = [msgctxt, msgid].join(separator)
58:         end
59: 
60:         nsgettext(msgid, msgid_plural, n, separator)
61:       end
Also aliased as: np_
ns_(msgid, msgid_plural, n = 1, separator = '|') click to toggle source
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 36
36:       def nsgettext(msgid, msgid_plural, n = 1, separator = '|')
37:         if msgid.is_a?(Array)
38:           msgid, msgid_plural, n, separator = msgid[0], msgid[1], msgid_plural, n
39:           separator = '|' unless separator.is_a?(::String)
40:         end
41: 
42:         scope, msgid = I18n::Gettext.extract_scope(msgid, separator)
43:         default = { :one => msgid, :other => msgid_plural }
44:         I18n.t(msgid, :default => default, :count => n, :scope => scope, :separator => separator)
45:       end
Also aliased as: ns_
p_(msgctxt, msgid) click to toggle source
Alias for: pgettext
pgettext(msgctxt, msgid) click to toggle source
    # File lib/i18n/gettext/helpers.rb, line 22
22:       def pgettext(msgctxt, msgid)
23:         separator = I18n::Gettext::CONTEXT_SEPARATOR
24:         sgettext([msgctxt, msgid].join(separator), separator)
25:       end
Also aliased as: p_
s_(msgid, separator = '|') click to toggle source
Alias for: sgettext
sgettext(msgid, separator = '|') click to toggle source
    # File lib/i18n/gettext/helpers.rb, line 16
16:       def sgettext(msgid, separator = '|')
17:         scope, msgid = I18n::Gettext.extract_scope(msgid, separator)
18:         I18n.t(msgid, :scope => scope, :default => msgid, :separator => separator)
19:       end
Also aliased as: s_

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.