Module: I18n::Gettext::Helpers

### Home Classes Methods

### In Files

- lib/i18n/gettext/helpers.rb

### Methods

- #_
- #gettext
- #n_
- #ngettext
- #np_
- #npgettext
- #ns_
- #nsgettext
- #p_
- #pgettext
- #s_
- #sgettext

### Class/Module Index

Quicksearch

- I18n
- I18n::ArgumentError
- I18n::Backend
- I18n::Backend::Base
- I18n::Backend::Cache
- I18n::Backend::Cascade
- I18n::Backend::Chain
- I18n::Backend::Chain::Implementation
- I18n::Backend::Fallbacks
- I18n::Backend::Flatten
- I18n::Backend::Gettext
- I18n::Backend::Gettext::PoData
- I18n::Backend::InterpolationCompiler
- I18n::Backend::InterpolationCompiler::Compiler
- I18n::Backend::KeyValue
- I18n::Backend::KeyValue::Implementation
- I18n::Backend::Memoize
- I18n::Backend::Metadata
- I18n::Backend::Pluralization
- I18n::Backend::Simple
- I18n::Backend::Simple::Implementation
- I18n::Config
- I18n::ExceptionHandler
- I18n::Gettext
- I18n::Gettext::Helpers
- I18n::InvalidLocale
- I18n::InvalidLocaleData
- I18n::InvalidPluralizationData
- I18n::Locale
- I18n::Locale::Fallbacks
- I18n::Locale::Tag
- I18n::Locale::Tag::Parents
- I18n::Locale::Tag::Rfc4646
- I18n::Locale::Tag::Rfc4646::Parser
- I18n::Locale::Tag::Simple
- I18n::MissingInterpolationArgument
- I18n::MissingTranslation
- I18n::MissingTranslation::Base
- I18n::MissingTranslationData
- I18n::ReservedInterpolationKey
- I18n::Tests
- I18n::Tests::Basics
- I18n::Tests::Defaults
- I18n::Tests::Link
- I18n::Tests::Localization
- I18n::Tests::Lookup
- I18n::Tests::Pluralization
- I18n::Tests::Procs
- I18n::UnknownFileType
- GetText
- GetText::PoParser
- Hash
- Kernel

No matching classes.

# I18n::Gettext::Helpers

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

### Public Instance Methods

_(msgid, options = {}) click to toggle source
Alias for: gettext
gettext(msgid, options = {}) click to toggle source

    # File lib/i18n/gettext/helpers.rb, line 10
    def gettext(msgid, options = {})
      I18n.t(msgid, { :default => msgid, :separator => '|' }.merge(options))
    end

Also aliased as: _
n_(msgid, msgid_plural, n = 1) click to toggle source
Alias for: ngettext
ngettext(msgid, msgid_plural, n = 1) click to toggle source

    # File lib/i18n/gettext/helpers.rb, line 27
    def ngettext(msgid, msgid_plural, n = 1)
      nsgettext(msgid, msgid_plural, n)
    end

Also aliased as: n_
np_(msgctxt, msgid, msgid_plural, n = 1) click to toggle source
Alias for: npgettext
npgettext(msgctxt, msgid, msgid_plural, n = 1) click to toggle source

Method signatures:

    npgettext('Fruits', 'apple', 'apples', 2)
    npgettext('Fruits', ['apple', 'apples'], 2)

    # File lib/i18n/gettext/helpers.rb, line 50
    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

Also aliased as: np_
ns_(msgid, msgid_plural, n = 1, separator = '|') click to toggle source
Alias for: nsgettext
nsgettext(msgid, msgid_plural, n = 1, separator = '|') click to toggle source

Method signatures:

    nsgettext('Fruits|apple', 'apples', 2)
    nsgettext(['Fruits|apple', 'apples'], 2)

    # File lib/i18n/gettext/helpers.rb, line 35
    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

Also aliased as: ns_
p_(msgctxt, msgid) click to toggle source
Alias for: pgettext
pgettext(msgctxt, msgid) click to toggle source

    # File lib/i18n/gettext/helpers.rb, line 21
    def pgettext(msgctxt, msgid)
      separator = I18n::Gettext::CONTEXT_SEPARATOR
      sgettext([msgctxt, msgid].join(separator), separator)
    end

Also aliased as: p_
s_(msgid, separator = '|') click to toggle source
Alias for: sgettext
sgettext(msgid, separator = '|') click to toggle source

    # File lib/i18n/gettext/helpers.rb, line 15
    def sgettext(msgid, separator = '|')
      scope, msgid = I18n::Gettext.extract_scope(msgid, separator)
      I18n.t(msgid, :scope => scope, :default => msgid, :separator => separator)
    end

Also aliased as: s_

[Validate]

Generated with the Darkfish Rdoc Generator 2.