Sha256: c3700939a22f132b3eb6b32eb69174d8df6ed80a17368a051ee887a8629b27ac

Contents?: true

Size: 807 Bytes

Versions: 1

Compression:

Stored size: 807 Bytes

Contents

module Globalize
  module Backend
    class Gettext < Static
      # Gettext like translations
      #
      # == Examples
      #
      #   I18n.backend.gettext(:en, :"key.of.translation") # => Some value of specified key
      #   I18n.backend.gettext(:pl, "Some string to translate") # => Jakis tekst do przetlumaczenia
      #   I18n.backend.gettext(:pl, "Hello {{msg}}!", :msg => 'world') # => Hello world!
      def gettext(locale, key, options={})
        # TODO: hmm, should i check all ancestors?
        if key.is_a? String
          return if key.blank?
          begin
            translate locale, key.to_sym, options
          rescue I18n::MissingTranslationData
            return key
          end
        else
          translate locale, key, options
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
kriss-gettext_i18n-0.2.0 lib/globalize/backend/gettext.rb