pythonpython-3.xinternationalizationgettextpoedit

Is there a way to make gettext comment extractor look for the inline comments of a string rather than the line before?


This is a small snippet of my code:

#SUBTRACTION
       elif _("sub") in calc: #FOR TRANSLATORS: This is a translated if statement. Dont add accents. Use a key part of the word e.g. sub instead of subtract instead of the full word if possible.
           misc.showUserWhatIThink(_("subtract a number from a number"))
           TheBasics.subtraction()

Poedit (gettext) would assign the comment FOR TRANSLATORS: This is a translated if statement. [...] to subtract a number from a number rather than sub. I want the comment for "sub" to be on the "notes for translators" section.

Is there any way to circumvent this? I've already added the same comment over and over again inline; I don't want to redo all that.


Solution

  • It is not possible.

    And since it would require a major change to the extractor logic to make the comment placement more flexible, it is highly unlikely that this will ever change.

    If it is mission-critical for you: Preparse your sources with a little script, and if you find #TRANSLATORS comments, extract them into a line above the invocation of _().