Opened 7 years ago

Closed 7 years ago

#9109 closed defect (fixed)

Complete BridgeDB UI improvements and deploy to ponticum

Reported by: aagbsn Owned by:
Priority: Medium Milestone:
Component: Circumvention/BridgeDB Version:
Severity: Keywords:
Cc: asn, sysrqb, runa Actual Points:
Parent ID: Points:
Reviewer: Sponsor:

Description

The current work-in-progress is at:

https://gitweb.torproject.org/user/aagbsn/bridgedb.git/shortlog/refs/heads/fix_internationalization

Translations have been updated from https://gitweb.torproject.org/translation.git/shortlog/refs/heads/bridgedb_completed

There is currently a show-stopper bug that breaks translations:

Unhandled Error
Traceback (most recent call last):
  File "/home/bridgedb/.virtualenvs/bridgedb/local/lib/python2.7/site-packages/twisted/protocols/basic.py", line 581, in dataReceived
    why = self.lineReceived(line)
  File "/home/bridgedb/.virtualenvs/bridgedb/local/lib/python2.7/site-packages/twisted/web/http.py", line 1611, in lineReceived
    self.allContentReceived()
  File "/home/bridgedb/.virtualenvs/bridgedb/local/lib/python2.7/site-packages/twisted/web/http.py", line 1686, in allContentReceived
    req.requestReceived(command, path, version)
  File "/home/bridgedb/.virtualenvs/bridgedb/local/lib/python2.7/site-packages/twisted/web/http.py", line 790, in requestReceived
    self.process()
--- <exception caught here> ---
  File "/home/bridgedb/.virtualenvs/bridgedb/local/lib/python2.7/site-packages/twisted/web/server.py", line 192, in process
    self.render(resrc)
  File "/home/bridgedb/.virtualenvs/bridgedb/local/lib/python2.7/site-packages/twisted/web/server.py", line 241, in render
    body = resrc.render(self)
  File "/home/bridgedb/.virtualenvs/bridgedb/local/lib/python2.7/site-packages/BridgeDB-0.1-py2.7.egg/bridgedb/HTTPServer.py", line 132, in render
    return self.getBridgeRequestAnswer(request)
  File "/home/bridgedb/.virtualenvs/bridgedb/local/lib/python2.7/site-packages/BridgeDB-0.1-py2.7.egg/bridgedb/HTTPServer.py", line 219, in getBridgeRequestAnswer
    return lookup.get_template('bridges.html').render(answer=answer)
  File "/home/bridgedb/.virtualenvs/bridgedb/local/lib/python2.7/site-packages/mako/template.py", line 443, in render
    return runtime._render(self, self.callable_, args, data)
  File "/home/bridgedb/.virtualenvs/bridgedb/local/lib/python2.7/site-packages/mako/runtime.py", line 783, in _render
    **_kwargs_for_callable(callable_, data))
  File "/home/bridgedb/.virtualenvs/bridgedb/local/lib/python2.7/site-packages/mako/runtime.py", line 815, in _render_context
    _exec_template(inherit, lclcontext, args=args, kwargs=kwargs)
  File "/home/bridgedb/.virtualenvs/bridgedb/local/lib/python2.7/site-packages/mako/runtime.py", line 841, in _exec_template
    callable_(context, *args, **kwargs)
  File "base_html", line 24, in render_body
    
  File "bridges_html", line 48, in render_body
    
exceptions.UnicodeDecodeError: 'ascii' codec can't decode byte 0xd9 in position 0: ordinal not in range(128)
Unhandled Error
Traceback (most recent call last):
  File "/home/bridgedb/.virtualenvs/bridgedb/local/lib/python2.7/site-packages/twisted/protocols/basic.py", line 581, in dataReceived
    why = self.lineReceived(line)
  File "/home/bridgedb/.virtualenvs/bridgedb/local/lib/python2.7/site-packages/twisted/web/http.py", line 1611, in lineReceived
    self.allContentReceived()
  File "/home/bridgedb/.virtualenvs/bridgedb/local/lib/python2.7/site-packages/twisted/web/http.py", line 1686, in allContentReceived
    req.requestReceived(command, path, version)
  File "/home/bridgedb/.virtualenvs/bridgedb/local/lib/python2.7/site-packages/twisted/web/http.py", line 790, in requestReceived
    self.process()
--- <exception caught here> ---
  File "/home/bridgedb/.virtualenvs/bridgedb/local/lib/python2.7/site-packages/twisted/web/server.py", line 192, in process
    self.render(resrc)
  File "/home/bridgedb/.virtualenvs/bridgedb/local/lib/python2.7/site-packages/twisted/web/server.py", line 241, in render
    body = resrc.render(self)
  File "/home/bridgedb/.virtualenvs/bridgedb/local/lib/python2.7/site-packages/BridgeDB-0.1-py2.7.egg/bridgedb/HTTPServer.py", line 132, in render
    return self.getBridgeRequestAnswer(request)
  File "/home/bridgedb/.virtualenvs/bridgedb/local/lib/python2.7/site-packages/BridgeDB-0.1-py2.7.egg/bridgedb/HTTPServer.py", line 219, in getBridgeRequestAnswer
    return lookup.get_template('bridges.html').render(answer=answer)
  File "/home/bridgedb/.virtualenvs/bridgedb/local/lib/python2.7/site-packages/mako/template.py", line 443, in render
    return runtime._render(self, self.callable_, args, data)
  File "/home/bridgedb/.virtualenvs/bridgedb/local/lib/python2.7/site-packages/mako/runtime.py", line 783, in _render
    **_kwargs_for_callable(callable_, data))
  File "/home/bridgedb/.virtualenvs/bridgedb/local/lib/python2.7/site-packages/mako/runtime.py", line 815, in _render_context
    _exec_template(inherit, lclcontext, args=args, kwargs=kwargs)
  File "/home/bridgedb/.virtualenvs/bridgedb/local/lib/python2.7/site-packages/mako/runtime.py", line 841, in _exec_template
    callable_(context, *args, **kwargs)
  File "base_html", line 24, in render_body
    
  File "bridges_html", line 48, in render_body
    
exceptions.UnicodeDecodeError: 'ascii' codec can't decode byte 0xd9 in position 0: ordinal not in range(128)

I did not get very far trying to fix this bug. I tried playing around with Mako's TemplateLookup input_encoding and output_encoding parameters, set coding-types in the template files, etc.. My guess is that it is has to do with the default encoding in python2 (ascii) and strings returned from gettext's _()... but no love there.

Any clues?

Child Tickets

Change History (5)

comment:1 Changed 7 years ago by sysrqb

Can you try:

diff --git a/lib/bridgedb/HTTPServer.py b/lib/bridgedb/HTTPServer.py
index d49a081..7e62085 100644
--- a/lib/bridgedb/HTTPServer.py
+++ b/lib/bridgedb/HTTPServer.py
@@ -288,4 +288,4 @@ def setLocaleFromRequestHeader(request):
         map(lambda x: x.replace("-","_").lower(),langs)
         lang = gettext.translation("bridgedb", localedir=localedir,
                 languages=langs, fallback=True)
-        lang.install()
+        lang.install(True)

and see if that works?

comment:2 Changed 7 years ago by aagbsn

Resolution: fixed
Status: newclosed

Awesome! This works! The pydocs are a bit weak here -- does this set unicode support for the installed lang?

comment:3 Changed 7 years ago by asn

Resolution: fixed
Status: closedreopened

But is this deployed? bridges.torproject.org doesn't look so.

comment:4 in reply to:  2 Changed 7 years ago by sysrqb

Replying to aagbsn:

Awesome! This works! The pydocs are a bit weak here -- does this set unicode support for the installed lang?

Yeah, pydocs are a bit lackluster. I used the webdocs for this http://docs.python.org/2/library/gettext.html#gettext.NullTranslations.install

comment:5 Changed 7 years ago by asn

Resolution: fixed
Status: reopenedclosed

Deployed.

Note: See TracTickets for help on using tickets.