From: Danilo S. <ds...@gm...> - 2006-03-20 04:02:35
|
Yesterday at 12:46, Martin v. L=C3=B6wis wrote: > Is the format of the PO header specified anywhere? In practice, it seems first msgstr in a MO file is of the form: ([A-Za-z-]+:[^\n]+\n)+ As indicated on=20 http://www.scit.wlv.ac.uk/cgi-bin/mansec?1+msgfmt this seems to be specific to GNU systems: o If the .po file contains a valid GNU header entry (having an empty string for msgid), the msgfmt utility uses the GNU-compatible message catalog file format. o Otherwise, the msgfmt utility uses the Solaris message catalog file format. So, the only place it is specified on is "info gettext", topic "Header Entry". > I'm trying to find out how precisely to determine the content-type > and the plural-forms of a MO file, however, it is not clear how this > thing should be parsed. It appears that it is similar to, but not > identical with, an RFC-822-style header > > 1. Is it true that the key-value pairs must always fit onto a single > line? Yes, except for the "\\\n" continuation lines: even "info gettext", topic on plural forms, lists several plural forms definitions with continuations on next lines. But, this could be due to plural forms being defined as "C expressions", and C expressions allow such continuation lines (or is it a pre-processor feature?). Judging by "info gettext", where no continuation mechanism is otherwise defined, I'd interpret this as "key-value pairs must always fit onto a single line, except where explicitely defined". > Some PO files use multi-line fields, e.g. for Last-translator, see > > http://www.python.org/sf/658233 This seems to be wrong since it's not even using a "continuation" string of "\\\n". > Is that a correct file? Also, the gettext documentation itself > suggests that the plural-forms can be split into multiple lines > using backslashes. Is that supported? Yes, and this seems to be due to C-expressions support, afaics. > 2. Is it true that each field must start with a field name? > Some PO files have other stuff in the header as well, e.g. > > http://www.python.org/sf/1448060 > > Is it valid for a PO file to contain # comment lines in the > header? This is something else: I agree it's an invalid header field. Such files sometimes get created by msgmerge (or some other msg* tool, I am not sure how, but I know they happen from time to time to me), which is why it's important to ignore them: they get inserted there unintentionally. [on the patch in that bug, I obviously misunderstood what's it doing, but I guess you already have plans on reworking that part of code anyway, so I won't submit anything else ;)] Cheers, Danilo |