Class Index [+]

Quicksearch

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

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.