Sha256: b26fa88d46757921541ee95c6bb3ba56b5ea628f540f2b69756d6cfddce83619

Contents?: true

Size: 1.05 KB

Versions: 16

Compression:

Stored size: 1.05 KB

Contents

require 'gettext_i18n_rails/gettext_hooks'

module GettextI18nRails
  class BaseParser
    def self.target?(file)
      File.extname(file) == ".#{extension}"
    end

    def self.parse(file, msgids = [])
      return msgids unless load_library
      code = convert_to_code(File.read(file))
      RubyGettextExtractor.parse_string(code, file, msgids)
    rescue Racc::ParseError => e
      $stderr.puts "file ignored: ruby_parser cannot read #{extension} files with 1.9 syntax --- #{file}: (#{e.message.strip})"
      return msgids
    end

    def self.load_library
      return true if @library_loaded

      begin
        require "#{::Rails.root.to_s}/vendor/plugins/#{extension}/lib/#{extension}"
      rescue LoadError
        begin
          require extension # From gem
        rescue LoadError
          puts "A #{extension} file was found, but #{extension} library could not be found, so nothing will be parsed..."
          return false
        end
      end

      require 'gettext_i18n_rails/ruby_gettext_extractor'
      @library_loaded = true
    end
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
gettext_i18n_rails-1.0.5 lib/gettext_i18n_rails/base_parser.rb
gettext_i18n_rails-1.0.4 lib/gettext_i18n_rails/base_parser.rb
gettext_i18n_rails-1.0.3 lib/gettext_i18n_rails/base_parser.rb
gettext_i18n_rails-1.0.2 lib/gettext_i18n_rails/base_parser.rb
gettext_i18n_rails-1.0.1 lib/gettext_i18n_rails/base_parser.rb
gettext_i18n_rails-1.0.0 lib/gettext_i18n_rails/base_parser.rb
gettext_i18n_rails-0.10.1 lib/gettext_i18n_rails/base_parser.rb
gettext_i18n_rails-0.10.0 lib/gettext_i18n_rails/base_parser.rb
gettext_i18n_rails-0.9.4 lib/gettext_i18n_rails/base_parser.rb
gettext_i18n_rails-0.9.3 lib/gettext_i18n_rails/base_parser.rb
gettext_i18n_rails-0.9.2 lib/gettext_i18n_rails/base_parser.rb
gettext_i18n_rails-0.9.1 lib/gettext_i18n_rails/base_parser.rb
gettext_i18n_rails-0.9.0 lib/gettext_i18n_rails/base_parser.rb
gettext_i18n_rails-0.8.0 lib/gettext_i18n_rails/base_parser.rb
gettext_i18n_rails-0.7.2 lib/gettext_i18n_rails/base_parser.rb
gettext_i18n_rails-0.7.1 lib/gettext_i18n_rails/base_parser.rb