Module: PoParser

Defined in:
lib/poparser.rb,
lib/poparser/po.rb,
lib/poparser/entry.rb,
lib/poparser/header.rb,
lib/poparser/comment.rb,
lib/poparser/message.rb,
lib/poparser/version.rb,
lib/poparser/constants.rb,
lib/poparser/tokenizer.rb

Defined Under Namespace

Classes: Comment, Entry, Header, Message, Po, Tokenizer

Constant Summary collapse

VERSION =
'3.2.6'
COMMENTS_LABELS =
{
  translator_comment: '#',
  extracted_comment: '#.',
  reference: '#:',
  flag: '#,',
  previous_msgctxt: '#| msgctxt',
  previous_msgid: '#| msgid',
  previous_msgid_plural: '#| msgid_plural',
  obsolete: '#~',
}.freeze
ENTRIES_LABELS =
{
  msgctxt: 'msgctxt',
  msgid: 'msgid',
  msgid_plural: 'msgid_plural',
  msgstr: 'msgstr',
}.freeze
LABELS =
COMMENTS_LABELS.merge(ENTRIES_LABELS).keys
HEADER_LABELS =
{
  pot_creation_date: 'POT-Creation-Date',
  po_revision_date: 'PO-Revision-Date',
  project_id: 'Project-Id-Version',
  report_to: 'Project-Id-Version',
  last_translator: 'Last-Translator',
  team: 'Language-Team',
  language: 'Language',
  charset: 'Content-Type',
  encoding: 'Content-Transfer-Encoding',
  plural_forms: 'Plural-Forms',
}.freeze

Class Method Summary collapse

Class Method Details

.parse(payload) ⇒ Object



18
19
20
21
22
23
24
25
26
27
# File 'lib/poparser.rb', line 18

def parse(payload)
  if File.exist?(payload)
    Kernel.warn 'DEPRICATION WARNING: `parse` only accepts content of a '\
      'PO file as a string and this behaviour will be removed on next '\
      'major release. Use `parse_file` instead.'
    parse_file(payload)
  else
    Tokenizer.new.extract(payload)
  end
end

.parse_file(path) ⇒ Object



29
30
31
# File 'lib/poparser.rb', line 29

def parse_file(path)
  Tokenizer.new(true).extract(path)
end