Method: GetText#npgettext
- Defined in:
- lib/gettext.rb
#npgettext(msgctxt, msgids, arg2 = nil, arg3 = nil) ⇒ Object Also known as: np_
call-seq:
npgettext(msgctxt, msgid, msgid_plural, n)
npgettext(msgctxt, msgids, n) # msgids = [msgid, msgid_plural]
np_(msgctxt, msgid, msgid_plural, n)
np_(msgctxt, msgids, n) # msgids = [msgid, msgid_plural]
The npgettext is similar to the nsgettext function.
e.g.) np_("Special", "An apple", "%{num} Apples", num) == ns_("Special|An apple", "%{num} Apples", num)
-
msgctxt: the message context.
-
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.
218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 |
# File 'lib/gettext.rb', line 218 def npgettext(msgctxt, msgids, arg2 = nil, arg3 = nil) if msgids.kind_of?(Array) msgid = msgids[0] msgid_ctxt = "#{msgctxt}\004#{msgid}" msgid_plural = msgids[1] opt1 = arg2 opt2 = arg3 else msgid = msgids msgid_ctxt = "#{msgctxt}\004#{msgid}" msgid_plural = arg2 opt1 = arg3 opt2 = nil end msgstr = TextDomainManager.(self, msgid_ctxt, msgid_plural, opt1, opt2) if msgstr == msgid_ctxt msgid else msgstr end end |