Skip to content

Warns on commented out lines in po files #566

Open

Description

@tsdgeos

Babel gives a warning when finding lines like

#~ msgctxt "pref_plugin_mousepad_desc"
#~ msgid "Control your mouse remotely"
#~ msgstr "Controla el vostre ratolí de forma remota"

which are basically commented lines.

It would be nice if it did not do that.

Activity

  1. akx commented on Apr 4, 2018

    @akx
    Member

    Hi!
    What warning are you seeing? Those are entries marked as obsolete – I'm not sure what we should do with them anyway. (I'd just trash them in the general case; PO files are version controlled, right?)

  2. tsdgeos commented on Apr 4, 2018

    @tsdgeos
    Author

    Warning is

    WARNING: Start of line didn't match any expected keyword.

    And no, you should not delete them, even if PO files are versioned in SCM, in settings like ours where there is a daily extraction + merge or pot to po, it can happen that someone screws up and then the po gets empty and then it gets fixed on the next day, and msgmerge will automatically recover the commented lines #~
    If you delete them that means manual intervention and it's horrible

  3. pinotree commented on Jul 7, 2019

    @pinotree

    It seems that obsolete entries like the one mentioned by @tsdgeos are handled fine.
    The problem seems rather on obsolete entries with previous strings, e.g.

    #, fuzzy
    #~| msgctxt "sftp_camera"
    #~| msgid "Camera pictures"
    #~ msgctxt "take_picture"
    #~ msgid "Take picture"
    #~ msgstr "Immagini fotocamera"

    In particular, the #~| lines (previous strings of obsolete entries).

    In this case, PoFileParser will fail because:

    • the loop in parse() finds the line starting with #, then with ~, so it calls _process_message_line() marking the result as obsolete=True
    • _process_message_line() calls _process_keyword_line() as it is not a "continuation" line of a string
    • _process_keyword_line() tries to look for any of the elements in _keywords at the beginning, and since there is none (the first character in line passed to _process_keyword_line() is |), it calls the _invalid_pofile() with the mentioned error message

    In general, it seems like PoFileParser does not handle previous strings in entries at all, like:

    #: main.cpp:47
    #, fuzzy, kde-format
    #| msgid "(c) 2003-2005, Ralf Hoelzer"
    msgid "© 2003-2005, Ralf Hoelzer"
    msgstr "© 2003-2005, Ralf Hoelzer"

    So I see two options here:

    • make PoFileParser handle previous strings in entries, both valid and obsolete ones
    • rewrite PoFileParser, and possibly also write_po() in the same module, to use polib: https://bitbucket.org/izi/polib (which already handles everything just fine)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions