Class: YARD::I18n::POParser

Inherits:
Object
  • Object
show all
Defined in:
lib/yard/i18n/po_parser.rb

Overview

Locale is a wrapper for gettext’s PO parsing feature. It hides gettext API difference from YARD.

Since:

  • 0.8.8

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.available?Boolean

Returns true if gettext is available, false otherwise.

Returns:

  • (Boolean)

    true if gettext is available, false otherwise.

Since:

  • 0.8.8



37
38
39
# File 'lib/yard/i18n/po_parser.rb', line 37

def available?
  !@@gettext_version.nil?
end

Instance Method Details

#parse(file) ⇒ Hash<String, String>

Parses PO file.

Parameters:

  • file (String)

    path of PO file to be parsed.

Returns:

Since:

  • 0.8.8



46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/yard/i18n/po_parser.rb', line 46

def parse(file)
  case @@gettext_version
  when 2
    parser = GetText::PoParser.new
    data = GetText::MoFile.new
  when 3
    parser = GetText::POParser.new
    data = GetText::MO.new
  end
  parser.report_warning = false
  parser.parse_file(file, data)
  data
end