def nsgettext(arg1, arg2, arg3 = "|", arg4 = "|")
if arg1.kind_of?(Array)
msgid = arg1[0]
msgid_plural = arg1[1]
n = arg2
if arg3 and arg3.kind_of? Numeric
raise ArgumentError, _("3rd parmeter is wrong: value = %{number}") % {:number => arg3}
end
div = arg3
else
msgid = arg1
msgid_plural = arg2
n = arg3
div = arg4
end
cached_key = [bound_target, Locale.current, msgid + "\000" + msgid_plural]
msgs = nil
if @@__cached
if @@__cache_nmsgids.has_key?(cached_key)
msgs = @@__cache_nmsgids[cached_key]
end
end
unless msgs
for target in bound_targets(self)
manager = @@__textdomainmanagers[target]
for textdomain in manager.textdomains
msgs = textdomain[1].ngettext_data(msgid, msgid_plural)
break if msgs
end
break if msgs
end
msgs = [[msgid, msgid_plural], "n != 1"] unless msgs
@@__cache_nmsgids[cached_key] = msgs
end
msgstrs = msgs[0]
if div and msgstrs[0] == msgid
if index = msgstrs[0].rindex(div)
msgstrs[0] = msgstrs[0][(index + 1)..-1]
end
end
plural = eval(msgs[1])
if plural.kind_of?(Numeric)
ret = msgstrs[plural]
else
ret = plural ? msgstrs[1] : msgstrs[0]
end
ret
end