Sha256: 67d96c7420b72442c85ec9acf0fcea9ebd96093b86a9e4edd00b69619dda4f74

Contents?: true

Size: 1.08 KB

Versions: 10

Compression:

Stored size: 1.08 KB

Contents

# frozen_string_literal: true

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

    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

    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
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
fast_gettext-4.1.0 lib/fast_gettext/po_file.rb
fast_gettext-4.0.0 lib/fast_gettext/po_file.rb
fast_gettext-3.1.0 lib/fast_gettext/po_file.rb
fast_gettext-2.3.0 lib/fast_gettext/po_file.rb
fast_gettext-2.2.0 lib/fast_gettext/po_file.rb
fast_gettext-2.1.0 lib/fast_gettext/po_file.rb
fast_gettext-2.0.3 lib/fast_gettext/po_file.rb
fast_gettext-2.0.2 lib/fast_gettext/po_file.rb
fast_gettext-2.0.1 lib/fast_gettext/po_file.rb
fast_gettext-2.0.0 lib/fast_gettext/po_file.rb