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