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

Loading…
Cancel
Save