Issue #4 wontfix

Necessity of escape / unescape

created an issue


the longer I think about it the more I get the feeling I would like to have polib leave the entry strings unchanged, i.e. not apply unescape (on reads) and escape (on writes) to them. The main use case for gettext (and polib, for that matter) is handling strings that come from files - either source files or .po files. In those cases it would be easiest if the strings were left untouched, as they are. You read strings in and write them out, but you usually never need them in a "parsed" representation; they are just raw data, and that's fine. For example, the current implementation forces me to apply a polib.unescape() to a string collected from a source file, in order to use it properly as a POEntry.msgid.

The only exception from the general use case I can think of is when you want to bring Python string listerals into the game (ie. strings not read from files); and as polib is a Python module there might be occasions where you want to use it in this way. But then all you have to do is to use Python raw strings r'...' to populate POEntries. That would be the only concession for this use case, and an easy one at this, as it matches the po file format description (s. gettext) which mandates C-style escapes.

What do you think?

Comments (9)

  1. David Jean Louis repo owner

    Hmm, I wouldn't say that the string literals usecase is not frequent. In fact most of the projects that use polib (transifex, django-rosetta...) gather input from text fields and write po entries with it, in this case the escape() method is required.

    I'm -1 on changing the current behavior, maybe an option to disable it would be ok ? and it would have the benefit of preserving backward compatibility.

    -- David

  2. Anonymous

    I'll try to. It's on my todo list, but may take a while. Will you accept a patch, or do I have to create a bitbucket fork?

    Cheers, Thomas

  3. Log in to comment