class RDoc::Generator::POT::PO
def add entry
def add entry existing_entry = @entries[entry.msgid] if existing_entry entry = existing_entry.merge(entry) end @entries[entry.msgid] = entry end
def add_header
def add_header add(header_entry) end
def header_entry
def header_entry comment = <<-COMMENT ME DESCRIPTIVE TITLE. pyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER is file is distributed under the same license as the PACKAGE package. RST AUTHOR <EMAIL@ADDRESS>, YEAR. COMMENT content = <<-CONTENT oject-Id-Version: PACKAGE VERSEION port-Msgid-Bugs-To: -Revision-Date: YEAR-MO_DA HO:MI+ZONE st-Translator: FULL NAME <EMAIL@ADDRESS> nguage-Team: LANGUAGE <LL@li.org> nguage: ME-Version: 1.0 ntent-Type: text/plain; charset=CHARSET ntent-Transfer-Encoding: 8bit ural-Forms: nplurals=INTEGER; plural=EXPRESSION; CONTENT options = { :msgstr => content, :translator_comment => comment, :flags => ['fuzzy'], } RDoc::Generator::POT::POEntry.new('', options) end
def initialize
def initialize @entries = {} add_header end
def sort_entries
def sort_entries headers, messages = @entries.values.partition do |entry| entry.msgid.empty? end # TODO: sort by location sorted_messages = messages.sort_by do |entry| entry.msgid end headers + sorted_messages end
def to_s
def to_s po = '' sort_entries.each do |entry| po << "\n" unless po.empty? po << entry.to_s end po end