carlxaeron / django-rosetta

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

django chrashes when trying to store with a non ascii user name #38

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
This problem is related somehow with the previous one.

When trying to save and having non ascii charactters in the user name it
raises ''ascii' codec can't encode character python' at line 79 in
rosetta/views.py

Root cause  is that it raises an UnicodeEncodeError and the try: clause go
for UnicodeDecodeError

OS: Win XP 32
Python 2.5

The monkey patch I did was to insert an additional try clause for
UnicodeEncodeError and then simply to store 'See Email <email@x.y>' in the
mo file.

if file_change and rosetta_i18n_write:
                try:
                    rosetta_i18n_pofile.metadata['Last-Translator'] =
str("%s %s <%s>"
%(request.user.first_name,request.user.last_name,request.user.email))
                except UnicodeEncodeError:
                    rosetta_i18n_pofile.metadata['Last-Translator'] =
str("See Email <%s>" %(request.user.email))    
                try:
                    rosetta_i18n_pofile.metadata['X-Translated-Using'] =
str("django-rosetta %s" % rosetta.get_version(False))
                    rosetta_i18n_pofile.metadata['PO-Revision-Date'] =
datetime.datetime.now().strftime('%Y-%m-%d %H:%M%z')
                except UnicodeDecodeError:
                    pass

Original issue reported on code.google.com by guenter....@wanagu.at on 12 Dec 2008 at 9:10

GoogleCodeExporter commented 8 years ago
This is allegedly fixed in r69

Original comment by mbonetti on 28 Jul 2009 at 3:29