Sha256: 32e730a41990e785f33b699cbd18715d1c6634262233f5fc9ad7e0d8d9d3a69c

Contents?: true

Size: 1.03 KB

Versions: 34

Compression:

Stored size: 1.03 KB

Contents

require 'gettext/utils'
begin
  require 'gettext/tools/rgettext'
rescue LoadError #version prior to 2.0
  require 'gettext/rgettext'
end

module GettextI18nRails
  module HamlParser
    module_function

    def target?(file)
      File.extname(file) == '.haml'
    end

    def parse(file, msgids = [])
      return msgids unless load_haml
      require 'gettext_i18n_rails/ruby_gettext_extractor'

      text = IO.readlines(file).join

      haml = Haml::Engine.new(text)
      code = haml.precompiled
      return RubyGettextExtractor.parse_string(code, file, msgids)
    end

    def load_haml
      return true if @haml_loaded
      begin
        require "#{RAILS_ROOT}/vendor/plugins/haml/lib/haml"
      rescue LoadError
        begin
          require 'haml'  # From gem
        rescue LoadError
          puts "A haml file was found, but haml library could not be found, so nothing will be parsed..."
          return false
        end
      end
      @haml_loaded = true
    end
  end
end
GetText::RGetText.add_parser(GettextI18nRails::HamlParser)

Version data entries

34 entries across 34 versions & 2 rubygems

Version Path
zena-1.0.0.rc2 vendor/plugins/gettext_i18n_rails/lib/gettext_i18n_rails/haml_parser.rb
zena-1.0.0.rc1 vendor/plugins/gettext_i18n_rails/lib/gettext_i18n_rails/haml_parser.rb
gettext_i18n_rails-0.2.9 lib/gettext_i18n_rails/haml_parser.rb
gettext_i18n_rails-0.2.8 lib/gettext_i18n_rails/haml_parser.rb
gettext_i18n_rails-0.2.7 lib/gettext_i18n_rails/haml_parser.rb
gettext_i18n_rails-0.2.6 lib/gettext_i18n_rails/haml_parser.rb
gettext_i18n_rails-0.2.5 lib/gettext_i18n_rails/haml_parser.rb
gettext_i18n_rails-0.2.4 lib/gettext_i18n_rails/haml_parser.rb
zena-0.16.9 vendor/plugins/gettext_i18n_rails/lib/gettext_i18n_rails/haml_parser.rb
zena-1.0.0.beta3 vendor/plugins/gettext_i18n_rails/lib/gettext_i18n_rails/haml_parser.rb
zena-0.16.8 vendor/plugins/gettext_i18n_rails/lib/gettext_i18n_rails/haml_parser.rb
gettext_i18n_rails-0.2.3 lib/gettext_i18n_rails/haml_parser.rb
gettext_i18n_rails-0.2.2 lib/gettext_i18n_rails/haml_parser.rb
zena-1.0.0.beta2 vendor/plugins/gettext_i18n_rails/lib/gettext_i18n_rails/haml_parser.rb
zena-1.0.0.beta1 vendor/plugins/gettext_i18n_rails/lib/gettext_i18n_rails/haml_parser.rb
gettext_i18n_rails-0.2.1 lib/gettext_i18n_rails/haml_parser.rb
zena-0.16.7 vendor/plugins/gettext_i18n_rails/lib/gettext_i18n_rails/haml_parser.rb
gettext_i18n_rails-0.2.0 lib/gettext_i18n_rails/haml_parser.rb
gettext_i18n_rails-0.1.5 lib/gettext_i18n_rails/haml_parser.rb
gettext_i18n_rails-0.1.4 lib/gettext_i18n_rails/haml_parser.rb