Sha256: 5f2de53c74e6c6efee80bd34d8c8837c7a2866d72ee0202e5ecb15c07977a1b5

Contents?: true

Size: 993 Bytes

Versions: 2

Compression:

Stored size: 993 Bytes

Contents

module FastGettext
  module Translation
    extend self
    
    def _(translate)
      FastGettext.current_translations[translate] || translate
    end

    #translate pluralized
    def n_(singular,plural,count)
      if translation = FastGettext.current_translations.plural(singular,plural,count)
        translation
      else
        count == 1 ? singular : plural
      end
    end

    #translate, but discard namespace if nothing was found
    # Car|Tire -> Tire if no translation could be found
    def s_(translate,seperator=nil)
      if translation = FastGettext.current_translations[translate]
        translation
      else
        translate.split(seperator||NAMESPACE_SEPERATOR).last
      end
    end

    #tell gettext: this string need translation (will be found during parsing)
    def N_(translate)
      translate
    end

    #tell gettext: this string need translation (will be found during parsing)
    def Nn_(singular,plural)
      [singular,plural]
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
grosser-fast_gettext-0.2.6 lib/fast_gettext/translation.rb
grosser-fast_gettext-0.2.7 lib/fast_gettext/translation.rb