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
# File lib/i18n/gettext/helpers.rb, line 10 10: def gettext(msgid, options = {}) 11: I18n.t(msgid, { :default => msgid, :separator => '|' }.merge(options)) 12: end
# File lib/i18n/gettext/helpers.rb, line 27 27: def ngettext(msgid, msgid_plural, n = 1) 28: nsgettext(msgid, msgid_plural, n) 29: end
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
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
# 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
# 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
Disabled; run with --debug to generate this.
Generated with the Darkfish Rdoc Generator 1.1.6.