carlxaeron / django-rosetta

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

cannot download translated .po file #75

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
Trying to download file by clicking "download" link and get UnicodeDecodeError

at line 214 of views.py  - str(rosetta_i18n_pofile)

it works fine on empty .po files - with no translations, but once translations 
are added in 
unicode - I get that error.

Is this something that I can fix in my configuration or a real bug?

Thanks!!! We've almost translated askbot forum to German and Turkish, Russian 
and Serbian are 
in process.

Cheers.

Evgeny.

Original issue reported on code.google.com by evgeny.f...@gmail.com on 6 May 2010 at 8:16

GoogleCodeExporter commented 8 years ago
Evgeny, sorry for the late feedback, would you please share the pofile that 
generates the error when you try to 
generate the zip file?

Original comment by mbonetti on 5 Jun 2010 at 11:24

GoogleCodeExporter commented 8 years ago
Hello,

I have this problem too. I tracked it to a bug in polib, which I raised here:
http://bitbucket.org/izi/polib/issue/6/__str__-methods-are-returning-unicode-ins
tead-of

Rick S

Original comment by alass...@gmail.com on 15 Jun 2010 at 12:01

GoogleCodeExporter commented 8 years ago
Before polib is updated, this should fix it on Rosetta's side, and should also 
work with David's proposed changes in polib.

--- views.py.old        2010-06-14 15:16:07.000000000 +0100
+++ views.py    2010-06-15 15:50:17.000000000 +0100
@@ -211,7 +211,7 @@
         mo_fn = str(po_fn.replace('.po','.mo')) # not so smart, huh
         zipdata = StringIO()
         zipf = zipfile.ZipFile(zipdata, mode="w")
-        zipf.writestr(po_fn, str(rosetta_i18n_pofile))
+        zipf.writestr(po_fn, unicode(rosetta_i18n_pofile).encode("utf8"))
         zipf.writestr(mo_fn, rosetta_i18n_pofile.to_binary())
         zipf.close()
         zipdata.seek(0)

Original comment by alass...@gmail.com on 15 Jun 2010 at 2:56

GoogleCodeExporter commented 8 years ago
Thank you, Rick. 
This is fixed as of r96.

Original comment by mbonetti on 15 Jun 2010 at 3:12