Sha256: 98181618bf94486657af62657c03e518f2d6840442bbbd368d34b4faaabf953d

Contents?: true

Size: 943 Bytes

Versions: 4

Compression:

Stored size: 943 Bytes

Contents

module I18n
  class << self
    # Returns translation for current string
    def gettext(key, options={})
      I18n.backend.gettext(locale, key, options)
    end

    # Shortcut for gettext method
    alias :_ :gettext
  end

  # Extension for other modules and classess, especially for Ruby on Rails 
  # ActionController and ActionView helpers
  #
  # == Usage
  #
  #   class Foo < Bar
  #     include I18n::Gettext
  #
  #     def bar
  #       return _("Translate!")
  #     end
  #   end
  #
  #   module Hello
  #     extend I18n::Gettext
  #   end
  module Gettext
    # Gettext translation method
    def gettext(key, options={})
      I18n.gettext(key, options)
    end
    
    # Shortcut for #translate method
    alias :_ :gettext 
    
    # Extend singleton with Gettext methods
    module Singleton
      def self.included(base)
        base.class_eval do
          extend I18n::Gettext
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
kriss-gettext_i18n-0.2.0 lib/globalize/i18n.rb
kriss-gettext_i18n-0.2.1 lib/globalize/i18n.rb
kriss-gettext_i18n-0.2.2 lib/globalize/i18n.rb
kriss-gettext_i18n-0.2.3 lib/globalize/i18n.rb