carlxaeron / django-rosetta

Automatically exported from code.google.com/p/django-rosetta
MIT License
0 stars 0 forks source link

Escaped special characters in strings are treated literally when saving #66

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
For example, the localized date-format string "d.m.Y \a\t H:i" will get 
converted into "d.m.Y \a\[tab 
character] H:i" after saving. A similar problem occurs with "\n".

It appears that escaped characters with special meanings are getting treated 
literally when writing 
strings back to the translation catalog - except that the escaping backslash is 
preserved.
Adding additional escapes (e.g. "\\t") does not help: the backslashes remain in 
the saved string, but 
the escaped character itself vanishes.

Original issue reported on code.google.com by alun.bes...@gmail.com on 16 Dec 2009 at 12:34

GoogleCodeExporter commented 8 years ago
I see, thank you for spotting this, I'll take a look.

Original comment by mbonetti on 16 Dec 2009 at 12:40

GoogleCodeExporter commented 8 years ago
I'm trying to reproduce this, but am having a hard time to come up with a test 
case that exposes this problem.

These strings...

    a = _(r'this is \t a test')
    b = _(r'this is \n a test, too')

Will be picked up by makemessages and added as

msgid "this is \\t a test"

msgid "this is \\n a test, too"

Saving the catalog will not alter the original string in this case, am I 
missing something?

Original comment by mbonetti on 6 Mar 2010 at 4:55

GoogleCodeExporter commented 8 years ago
I'm not able to test at present unfortunately (am on holiday for 3 weeks), but 
I can confirm at least that the 
problem is not with makemessages or compilemessages - the strings are correctly 
added to the translation 
catalog, and subsequent manual alterations to the translation catalog do not 
manifest the problem after 
running compilemessages. The problem only manifests when saving changes to the 
translation catalog 
through Rosetta's admin interface.

Perhaps this could be caught by a testcase which tests form submission through 
the admin interface? This 
would accurately replicate the situation that triggers it, and may catch any 
issues from "round-tripping" values 
through the form.

Original comment by alun.bes...@gmail.com on 10 Mar 2010 at 3:10