Closed arekm closed 12 months ago
Extracted comments are already supported via the comment
property of POEntry
.
With your code example:
$ python3 -c "import polib; p = polib.pofile('x.po'); print(p[0].msgid); print(p[0].comment)"
something
TR_MAX_LENGTH: 30
Oh, nice!
(concatenated string of all extracted comments it seems though aka no nice layout but good enough)
You can just split the string, something like that would do the trick:
comments = entry.comment.split("\n") if entry.comment else []
Yeah, just noticed that xgettext concatenates multiline comments when extracting, so that should work reliably even for such comments. Thanks.
There is support for translator comments (tcomments) but I do not see support for extracted comments.
https://www.gnu.org/software/gettext/manual/html_node/PO-Files.html comments starting with "#." are extracted.
Not sure if some nice structure (like list etc) can be provided for these in case of multiple ones in file.
(one usage scenario for extracted comments here is to use polib to validate translations based on values in some extracted comments like max allowed translation length etc)
Example:
Other example