smhg / gettext-parser

Parse and compile gettext po and mo files, nothing more, nothing less
MIT License
158 stars 44 forks source link

Support of Obsolete Messages #9

Closed flozz closed 2 years ago

flozz commented 8 years ago

Hello,

have you planned to support obsolete messages in your po parser?

Example of obsolete messages in a po file:

#~ msgid "Obsolete message"
#~ msgstr "Message obsolète"

regards,

smhg commented 7 years ago

Hi! I recently took over this project and I'm trying to follow up on open issues. What do you expect as support? Passing them through while parsing/compiling?

flozz commented 7 years ago

Hello,

Thank you for your interest in this issue!

I mean just keep them in the Object generated after parsing the .po file, and write them down when converting the Object to a .po file.

Of course the obsolete message must not be kept when compiling to .mo

Regards,

KapitanOczywisty commented 2 years ago

I've needed that functionality, so with patch-package I've modified gettext-parser to handle obsolete entries. https://gist.github.com/KapitanOczywisty/eaf5e18570376c6ffbe3aeaf047e0377

After modification obsolete translations are kept in optional obsolete property:

{
  //...
  obsolete: {
    '': {
      'Obsolete message': {
        msgid: 'Obsolete message',
        comments: { translator: 'Obsolete comment' },
        msgstr: [
          'Message obsolete.\nLines are properly handled, even for obsolete translations.'
        ]
      }
    }
  }
}

and properly compiled back into po file:

# Obsolete comment
#~ msgid "Obsolete message"
#~ msgstr ""
#~ "Message obsolete.\n"
#~ "Lines are properly handled, even for obsolete translations."

This might not be a perfect implementation, but works and could be used as place to start. @smhg what do you think?

smhg commented 2 years ago

@KapitanOczywisty thank you! It would be great to add this. Would you be able to create a PR which includes tests for: