Browse Source

first steps into i18n

master
Julio Biason 15 years ago
parent
commit
1fea4df513
  1. 50
      mitterlib/ui/ui_pygtk.py

50
mitterlib/ui/ui_pygtk.py

@ -28,6 +28,7 @@ import Queue
import re
import urllib2
import webbrowser
import gettext
from cgi import escape as html_escape
@ -41,14 +42,23 @@ _log = logging.getLogger('ui.pygtk')
URL_RE = re.compile(r'(https?://[^\s\n\r]+)', re.I)
MESSAGE_FORMAT = '%s' \
'<b>%s</b> ' \
'<small>(%s' \
'%s' \
# ----------------------------------------------------------------------
# I18n bits
# ----------------------------------------------------------------------
#t = gettext.translation('ui_pygtk')
#_ = t.gettext
# ----------------------------------------------------------------------
# String with the format to the message
# ----------------------------------------------------------------------
MESSAGE_FORMAT = '%(favourite_star)s' \
'<b>%(full_name)s</b> ' \
'<small>(%(username)s' \
'%(message_type)s' \
')</small>:' \
'%s\n' \
'%s\n' \
'<small>%s</small>'
'%(read_status)s\n' \
'%(message)s\n' \
'<small>%(message_age)s</small>'
# ----------------------------------------------------------------------
@ -576,15 +586,19 @@ class Interface(object):
data = store.get_value(position, 0)
time = timesince.timesince(data.message_time)
message_values = {}
# unescape escaped entities that pango is not okay with
message = html_escape(data.message)
username = html_escape(data.username)
full_name = html_escape(data.name)
message_values['message'] = html_escape(data.message)
message_values['username'] = html_escape(data.username)
message_values['full_name'] = html_escape(data.name)
message_values['message_age'] = time
# highlight URLs
mask = r'<span foreground="%s">\1</span>' % (
self._options[self.NAMESPACE]['link_colour'])
message = URL_RE.sub(mask, message)
message_values['message'] = URL_RE.sub(mask,
message_values['message'])
# use a different highlight for the current user
# TODO: How to handle this with several networks?
@ -593,14 +607,14 @@ class Interface(object):
# message)
if not data.read:
read_status = ' &#9679;'
message_values['read_status'] = ' &#9679;'
else:
read_status = ''
message_values['read_status'] = ''
if data.favourite:
favourite = '&#9733;'
message_values['favourite_star'] = '&#9733;'
else:
favourite = '&#9734;'
message_values['favourite_star'] = '&#9734;'
info = []
if data.reposted_by:
@ -610,10 +624,8 @@ class Interface(object):
info.append(' &#8212; <i>in reply to %s</i>' %
(data.parent_owner))
info_message = ''.join(info)
markup = MESSAGE_FORMAT % (favourite, full_name, username,
info_message, read_status, message, time)
message_values['message_type'] = ''.join(info)
markup = MESSAGE_FORMAT % (message_values)
cell.set_property('markup', markup)

Loading…
Cancel
Save