Method: GetText#ngettext

Defined in:
lib/gettext.rb

#ngettext(msgid, msgid_plural, n = nil) ⇒ Object Also known as: n_

call-seq:

ngettext(msgid, msgid_plural, n)
ngettext(msgids, n)  # msgids = [msgid, msgid_plural]
n_(msgid, msgid_plural, n)
n_(msgids, n)  # msgids = [msgid, msgid_plural]

The ngettext is similar to the gettext function as it finds the message catalogs in the same way. But it takes two extra arguments for plural form.

  • msgid: the singular form.

  • msgid_plural: the plural form.

  • n: a number used to determine the plural form.

  • Returns: the localized text which key is msgid_plural if n is plural(follow plural-rule) or msgid. “plural-rule” is defined in po-file.



179
180
181
# File 'lib/gettext.rb', line 179

def ngettext(msgid, msgid_plural, n = nil)
  TextDomainManager.translate_plural_message(self, msgid, msgid_plural, n)
end