123456789_123456789_123456789_123456789_123456789_

Class: YARD::I18n::POParser

Relationships & Source Files
Inherits: Object
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 Attribute Summary

Instance Method Summary

Class Attribute Details

.available?Boolean (readonly)

Returns:

  • (Boolean)

    true if gettext is available, false otherwise.

Since:

  • 0.8.8

[ GitHub ]

  
# 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

[ GitHub ]

  
# 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