module I18n::Gettext::Helpers
def N_(msgsid)
* msgid: the message id.
you can add fruit = N_("Apple") which does not translate, but tells the parser: "Apple" needs translation.
_(fruit) cannot be understood by the gettext parser. To help the parser find all your translations,
Makes dynamic translation messages readable for the gettext parser.
def N_(msgsid) msgsid end
def gettext(msgid, options = EMPTY_HASH)
def gettext(msgid, options = EMPTY_HASH) I18n.t(msgid, **{:default => msgid, :separator => '|'}.merge(options)) end
def ngettext(msgid, msgid_plural, n = 1)
def ngettext(msgid, msgid_plural, n = 1) nsgettext(msgid, msgid_plural, n) end
def npgettext(msgctxt, msgid, msgid_plural, n = 1)
npgettext('Fruits', 'apple', 'apples', 2)
Method signatures:
def npgettext(msgctxt, msgid, msgid_plural, n = 1) separator = I18n::Gettext::CONTEXT_SEPARATOR if msgid.is_a?(Array) msgid_plural, msgid, n = msgid[1], [msgctxt, msgid[0]].join(separator), msgid_plural else msgid = [msgctxt, msgid].join(separator) end nsgettext(msgid, msgid_plural, n, separator) end
def nsgettext(msgid, msgid_plural, n = 1, separator = '|')
nsgettext('Fruits|apple', 'apples', 2)
Method signatures:
def nsgettext(msgid, msgid_plural, n = 1, separator = '|') if msgid.is_a?(Array) msgid, msgid_plural, n, separator = msgid[0], msgid[1], msgid_plural, n separator = '|' unless separator.is_a?(::String) end scope, msgid = I18n::Gettext.extract_scope(msgid, separator) default = { :one => msgid, :other => msgid_plural } I18n.t(msgid, :default => default, :count => n, :scope => scope, :separator => separator) end
def pgettext(msgctxt, msgid)
def pgettext(msgctxt, msgid) separator = I18n::Gettext::CONTEXT_SEPARATOR sgettext([msgctxt, msgid].join(separator), separator) end
def sgettext(msgid, separator = '|')
def sgettext(msgid, separator = '|') scope, msgid = I18n::Gettext.extract_scope(msgid, separator) I18n.t(msgid, :scope => scope, :default => msgid, :separator => separator) end