Sha256: 433c6a89c8b59189653c1fb2dc2aef56b901da3ac5b584dcf1629e17e03e8880

Contents?: true

Size: 1.03 KB

Versions: 7

Compression:

Stored size: 1.03 KB

Contents

require 'fast_gettext/mo_file'
module FastGettext
  # Responsibility:
  #  - abstract po files for Po Repository
  class PoFile < MoFile
    def initialize(file, options={})
      @options = options
      super
    end

    def self.to_mo_file(file, options={})
      MoFile.new(parse_po_file(file, options))
    end

    protected

    def load_data
      @data = if @filename.is_a? FastGettext::GetText::MOFile
        @filename
      else
        FastGettext::PoFile.parse_po_file(@filename, @options)
      end
      make_singular_and_plural_available
    end

    def self.parse_po_file(file, options={})
      require 'fast_gettext/vendor/poparser'
      parser = FastGettext::GetText::PoParser.new

      warn ":ignore_obsolete is no longer supported, use :report_warning" if options.key? :ignore_obsolete
      parser.ignore_fuzzy = options[:ignore_fuzzy]
      parser.report_warning = options.fetch(:report_warning, true)

      mo_file = FastGettext::GetText::MOFile.new
      parser.parse_file(file, mo_file)
      mo_file
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
fast_gettext-1.8.0 lib/fast_gettext/po_file.rb
fast_gettext-1.7.0 lib/fast_gettext/po_file.rb
fast_gettext-1.1.2 lib/fast_gettext/po_file.rb
fast_gettext-1.1.1 lib/fast_gettext/po_file.rb
fast_gettext-1.6.0 lib/fast_gettext/po_file.rb
fast_gettext-1.5.1 lib/fast_gettext/po_file.rb
fast_gettext-1.5.0 lib/fast_gettext/po_file.rb