alejandro-zapeta / django-rosetta

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

Plural-Forms breaks after saving (|| is changed to or) #67

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Create po file for pl language and add in header:
"Plural-Forms: nplurals=3; plural=(n==1 ? 0 : n%10>=2 && n%10<=4 && 
(n%100<10 "
"|| n%100>=20) ? 1 : 2)\n"
2. Open file in rosetta and save.
3. See that the line is changed to:
"Plural-Forms: nplurals=3; plural=(n==1 ? 0 : n%10>=2 && n%10< =4 && 
(n%100<10 or n%100>=20) ? 1 : 2)\n"
Note that || is changed to or.
4. restart webserver
5. open rosetta again you should see exception:
"ValueError: plural forms expression could be dangerous"

This leads to "ValueError: plural forms expression could be dangerous" 
after restarting server and
What is the expected output? What do you see instead?
I expect that mo and po files will not cause exception mentioned above.

What version of the product are you using? On what operating system?
Windows Vista, Python 2.5.2, django-rosetta-0.5.2, django-1.1.1

Please provide any additional information below.

Manually change or to || and compiling file with `manage.py 
compilemessages` work correctly. Compiling with `manage.py compilemessages` 
 file with or instead of || leads to same exception. `manage.py 
makemessages` does not change || to or.

In Lib\gettext.py function c2py tokenizes `Plural-Forms` and it doing it 
differently if `or` is used instead of `||`. [line 8: tokens = 
tokenize.generate_tokens(StringIO(plural).readline)]

Original issue reported on code.google.com by daniel.b...@gmail.com on 31 Jan 2010 at 2:55

GoogleCodeExporter commented 8 years ago
This is quite an interesting error, I'm not sure it is in Rosetta, in polib or 
Python itself, 
though.

Will investigate and escalate higher the bug if need be.

Original comment by mbonetti on 31 Jan 2010 at 4:36

GoogleCodeExporter commented 8 years ago
I've found that I can successfully get around this by removing plurals from 
translations 
before running makemessages for the first time, then running makemessages --all 
after putting them back in. This makes sense if the header is causing the 
trouble.

Original comment by stephene...@gmail.com on 10 Feb 2010 at 12:21

GoogleCodeExporter commented 8 years ago
Hmm, I've tried but couldn't reproduce this behavior. Would you mind uploading 
a po file that will expose this 
problem?

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

GoogleCodeExporter commented 8 years ago
Okay, I just tested this (using the Rosetta's unittests added in the svn 
version)  on Windows 7, both with Python 
2.5.4 and 2.6 and could not reproduce this.

Could I kindly ask you guys to upgrade to Python 2.5.4 and test this on the svn 
version of rosetta?

I'd be interested in the output of 'manage.py test rosetta'.

Thank you.

Original comment by mbonetti on 7 Apr 2010 at 9:32