Class: FastGettext::PoFile

Inherits:
MoFile
  • Object
show all
Defined in:
lib/fast_gettext/po_file.rb

Overview

Responsibility:

- abstract po files for Po Repository

Constant Summary

Constants inherited from MoFile

MoFile::CONTEXT_SEPARATOR, MoFile::PLURAL_SEPARATOR

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from MoFile

#[], #data, empty, #plural, #pluralisation_rule

Constructor Details

#initialize(file, options = {}) ⇒ PoFile

Returns a new instance of PoFile.



8
9
10
11
# File 'lib/fast_gettext/po_file.rb', line 8

def initialize(file, options = {})
  @options = options
  super
end

Class Method Details

.parse_po_file(file, options = {}) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/fast_gettext/po_file.rb', line 17

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

.to_mo_file(file, options = {}) ⇒ Object



13
14
15
# File 'lib/fast_gettext/po_file.rb', line 13

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