def format
if @entry.obsolete?
return format_obsolete_comment(@entry.comment)
end
str = format_comments
if @entry.msgctxt?
if @entry.msgctxt.nil?
no_msgctxt_message = "This POEntry is a kind of msgctxt " +
"but the msgctxt property is nil. " +
"msgid: #{@entry.msgid}"
raise(NoMsgctxtError, no_msgctxt_message)
end
str << "msgctxt " << format_message(@entry.msgctxt)
end
str << "msgid " << format_message(@entry.msgid)
if @entry.plural?
if @entry.msgid_plural.nil?
no_plural_message = "This POEntry is a kind of plural " +
"but the msgid_plural property is nil. " +
"msgid: #{@entry.msgid}"
raise(NoMsgidPluralError, no_plural_message)
end
str << "msgid_plural " << format_message(@entry.msgid_plural)
if @entry.msgstr.nil?
str << "msgstr[0] \"\"\n"
str << "msgstr[1] \"\"\n"
else
msgstrs = @entry.msgstr.split("\000", -1)
msgstrs.each_with_index do |msgstr, index|
str << "msgstr[#{index}] " << format_message(msgstr)
end
end
else
str << "msgstr "
str << format_message(@entry.msgstr)
end
encode(str)
end