#2183: i18n collect on non-ascii characters in Javascript files
------------------------+---------------------------------------------------
 Reporter:  zafy        |       Owner:  faide               
     Type:  defect      |      Status:  new                 
 Priority:  normal      |   Milestone:  1.1                 
Component:  TurboGears  |     Version:  1.0.8               
 Severity:  normal      |    Keywords:  internationalization
------------------------+---------------------------------------------------
 Javascript file in turbogears accept the _() to wrap the strings and
 translate them using the i18n module. However if these strings contain
 non-ascii characters, the following error occurs when trying to run tg-
 admin i18n collect on the javascript file :


 {{{
 Traceback (most recent call last):
   File "/usr/bin/tg-admin", line 8, in <module>
     load_entry_point('TurboGears==1.0.8', 'console_scripts', 'tg-
 admin')()
   File "/usr/lib/python2.5/site-packages/TurboGears-1.0.8-py2.5.egg/
 turbogears/command/base.py", line 400, in main
     command.run()
   File "/usr/lib/python2.5/site-packages/TurboGears-1.0.8-py2.5.egg/
 turbogears/command/i18n.py", line 137, in run
     self.scan_source_files()
   File "/usr/lib/python2.5/site-packages/TurboGears-1.0.8-py2.5.egg/
 turbogears/command/i18n.py", line 310, in scan_source_files
     self.scan_js_files(tmp_potfile, js_files)
   File "/usr/lib/python2.5/site-packages/TurboGears-1.0.8-py2.5.egg/
 turbogears/command/i18n.py", line 414, in scan_js_files
     text = normalize(text.decode().encode('utf-8'))
 UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position
 12: ordinal not in range(128)

 }}}

 I solved the problem by changing the code in /usr/lib/python2.5/site-
 packages/TurboGears-1.0.8-py2.5.egg/turbogears/command/i18n.py :

 the code was :
 {{{
 line 182 in create_js_messages : key = unicode(key)
 line 414 in scan_js_files : text = normalize(text.encode('utf-8'))
 }}}

 so I changed it to :
 {{{
 line 182 in create_js_messages : key = unicode(key.decode('utf-8'))
 line 414 in scan_js_files : text = normalize(text)
 }}}


 This way, the strings are being collected as they are and they are
 converted back to utf-8 when creating the message-xx.js.

 I am attaching my resulting patch just in case.

 issue is described here as well :
 http://groups.google.com/group/turbogears/browse_thread/thread/a1b482fd2c406ade

-- 
Ticket URL: <http://trac.turbogears.org/ticket/2183>
TurboGears <http://www.turbogears.org/>
TurboGears front-to-back web development

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "TurboGears Tickets" group.
This group is read-only. No posting by normal members allowed.
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/turbogears-tickets?hl=en?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to