Sha256: 0fff6919c43cf3f41e74fc6eefce7307282f4bb7785b618633a96cd22986b975

Contents?: true

Size: 829 Bytes

Versions: 2

Compression:

Stored size: 829 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
            interpolate locale, key, options
          end
        else
          translate locale, key, options
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

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