Browse Source

marked pygtk and mitter for translations

master
Julio Biason 15 years ago
parent
commit
31bd1cfec9
  1. 13
      mitter
  2. 143
      mitterlib/ui/ui_pygtk.py

13
mitter

@ -22,6 +22,7 @@ import urllib
import os
import logging
import warnings
import gettext
import mitterlib.network as network
@ -31,6 +32,12 @@ from mitterlib.ui import Interfaces
log = logging.getLogger('mitter')
# ----------------------------------------------------------------------
# i18n stuff
# ----------------------------------------------------------------------
gettext.bindtextdomain('mitter')
gettext.textdomain('mitter')
_ = gettext.gettext
def main():
"""Main function."""
@ -43,7 +50,7 @@ def main():
group='General',
option='debug',
action='store_true',
help='Display debugging information.',
help=_('Display debugging information.'),
default=False,
is_config_option=False)
options.add_option('-i', '--interface',
@ -51,7 +58,7 @@ def main():
option='interface',
default=None,
metavar='INTERFACE',
help='Interface to be used.')
help=_('Interface to be used.'))
# Start the network manager (which will add the network options)
connection = Networks(options)
@ -88,7 +95,7 @@ def main():
# they don't chose anything.)
display = interfaces.load(connection, preferred_interface)
if display is None:
log.error('Sorry, no interface could be found for your system')
log.error(_('Sorry, no interface could be found for your system'))
return
# display the interface (the interface should take care of updating

143
mitterlib/ui/ui_pygtk.py

@ -45,8 +45,8 @@ URL_RE = re.compile(r'(https?://[^\s\n\r]+)', re.I)
# ----------------------------------------------------------------------
# I18n bits
# ----------------------------------------------------------------------
#t = gettext.translation('ui_pygtk')
#_ = t.gettext
t = gettext.translation('ui_pygtk', fallback=True)
_ = t.gettext
# ----------------------------------------------------------------------
# String with the format to the message
@ -381,97 +381,97 @@ class Interface(object):
# Actions related to the UI elements above
# Top-level menu actions
file_action = gtk.Action('File', '_File', 'File', None)
file_action = gtk.Action('File', _('_File'), _('File'), None)
action_group.add_action(file_action)
edit_action = gtk.Action('Edit', '_Edit', 'Edit', None)
edit_action = gtk.Action('Edit', _('_Edit'), _('Edit'), None)
action_group.add_action(edit_action)
message_action = gtk.Action('Message', '_Message',
'Message related options', None)
message_action = gtk.Action('Message', _('_Message'),
_('Message related options'), None)
action_group.add_action(message_action)
view_action = gtk.Action('View', '_View', 'View', None)
view_action = gtk.Action('View', _('_View'), _('View'), None)
action_group.add_action(view_action)
help_action = gtk.Action('Help', '_Help', 'Help', None)
help_action = gtk.Action('Help', _('_Help'), _('Help'), None)
action_group.add_action(help_action)
# File actions
quit_action = gtk.Action('Quit', '_Quit',
'Exit Mitter', gtk.STOCK_QUIT)
quit_action = gtk.Action('Quit', _('_Quit'),
_('Exit Mitter'), gtk.STOCK_QUIT)
quit_action.connect('activate', self._quit_app)
action_group.add_action_with_accel(quit_action, None)
# Edit actions
refresh_action = gtk.Action('Refresh', '_Refresh',
'Update the listing', gtk.STOCK_REFRESH)
refresh_action = gtk.Action('Refresh', _('_Refresh'),
_('Update the listing'), gtk.STOCK_REFRESH)
refresh_action.connect('activate', self._refresh)
action_group.add_action_with_accel(refresh_action, None)
self._update_action = gtk.Action('Update', '_Update',
'Update your status', gtk.STOCK_ADD)
self._update_action = gtk.Action('Update', _('_Update'),
_('Update your status'), gtk.STOCK_ADD)
self._update_action.set_property('sensitive', False)
self._update_action.connect('activate', self._update_status)
action_group.add_action_with_accel(self._update_action,
'Return')
self._cancel_action = gtk.Action('Cancel', '_Cancel',
'Cancel the update', gtk.STOCK_CANCEL)
self._cancel_action = gtk.Action('Cancel', _('_Cancel'),
_('Cancel the update'), gtk.STOCK_CANCEL)
self._cancel_action.connect('activate', self._clear_text)
action_group.add_action_with_accel(self._cancel_action,
'Escape')
clear_action = gtk.Action('Clear', '_Clear',
'Clear the message list', gtk.STOCK_CLEAR)
clear_action = gtk.Action('Clear', _('_Clear'),
_('Clear the message list'), gtk.STOCK_CLEAR)
clear_action.connect('activate', self._clear_posts)
action_group.add_action_with_accel(clear_action, '<Ctrl>l')
settings_action = gtk.Action('Settings', '_Settings',
'Settings', gtk.STOCK_PREFERENCES)
settings_action = gtk.Action('Settings', _('_Settings'),
_('Settings'), gtk.STOCK_PREFERENCES)
settings_action.connect('activate', self._show_settings)
action_group.add_action(settings_action)
# Message actions
self._delete_action = gtk.Action('Delete', '_Delete',
'Delete a post', gtk.STOCK_DELETE)
self._delete_action = gtk.Action('Delete', _('_Delete'),
_('Delete a post'), gtk.STOCK_DELETE)
self._delete_action.set_property('sensitive', False)
self._delete_action.connect('activate', self._delete_message)
action_group.add_action_with_accel(self._delete_action, 'Delete')
self._reply_action = gtk.Action('Reply', '_Reply',
"Send a response to someone's else message", gtk.STOCK_REDO)
self._reply_action = gtk.Action('Reply', _('_Reply'),
_("Send a response to someone's else message"), gtk.STOCK_REDO)
self._reply_action.set_property('sensitive', False)
self._reply_action.connect('activate', self._reply_message)
action_group.add_action_with_accel(self._reply_action, '<Ctrl>r')
self._repost_action = gtk.Action('Repost', 'Re_post',
"Put someone's else message on your timeline",
self._repost_action = gtk.Action('Repost', _('Re_post'),
_("Put someone's else message on your timeline"),
gtk.STOCK_CONVERT)
self._repost_action.set_property('sensitive', False)
self._repost_action.connect('activate', self._repost_message)
action_group.add_action_with_accel(self._repost_action, '<Ctrl>p')
self._favourite_action = gtk.Action('Favourite', '_Favourite',
'Toggle the favourite status of a message',
self._favourite_action = gtk.Action('Favourite', _('_Favourite'),
_('Toggle the favourite status of a message'),
gtk.STOCK_ABOUT)
self._favourite_action.set_property('sensitive', False)
self._favourite_action.connect('activate', self._favourite_message)
action_group.add_action_with_accel(self._favourite_action, '<Ctrl>f')
# view actions
view_messages_action = gtk.Action('Messages', '_Messages',
'Display messages', None)
view_messages_action = gtk.Action('Messages', _('_Messages'),
_('Display messages'), None)
view_messages_action.connect('activate', self._change_tab, 0)
action_group.add_action_with_accel(view_messages_action, '<Alt>1')
view_replies_action = gtk.Action('Replies', '_Replies',
'Display replies', None)
view_replies_action = gtk.Action('Replies', _('_Replies'),
_('Display replies'), None)
view_replies_action.connect('activate', self._change_tab, 1)
action_group.add_action_with_accel(view_replies_action, '<Alt>2')
# Help actions
about_action = gtk.Action('About', '_About', 'About Mitter',
about_action = gtk.Action('About', _('_About'), _('About Mitter'),
gtk.STOCK_ABOUT)
about_action.connect('activate', self._show_about)
action_group.add_action(about_action)
@ -542,10 +542,10 @@ class Interface(object):
about_window = gtk.AboutDialog()
about_window.set_name('Mitter')
about_window.set_version(version)
about_window.set_copyright('2007-2009 Mitter Contributors')
about_window.set_copyright('2007-2010 Mitter Contributors')
about_window.set_license(gpl_3)
about_window.set_website('http://code.google.com/p/mitter')
about_window.set_website_label('Mitter on GoogleCode')
about_window.set_website_label(_('Mitter on GoogleCode'))
about_window.set_authors([
'Main developers:',
'Julio Biason',
@ -618,10 +618,11 @@ class Interface(object):
info = []
if data.reposted_by:
info.append(' &#8212; <i>reposted by %s</i>' % (data.reposted_by))
info.append(_(' &#8212; <i>reposted by %s</i>') %
(data.reposted_by))
if data.parent_owner:
info.append(' &#8212; <i>in reply to %s</i>' %
info.append(_(' &#8212; <i>in reply to %s</i>') %
(data.parent_owner))
message_values['message_type'] = ''.join(info)
@ -666,7 +667,7 @@ class Interface(object):
self._refresh_id = None
# do the refresh
self._update_statusbar('Retrieving messages...')
self._update_statusbar(_('Retrieving messages...'))
self._threads.add_work(self._post_get_messages,
self._exception_get_messages,
self._connection.messages)
@ -689,7 +690,7 @@ class Interface(object):
link = self._connection.link(message)
if link:
network = self._connection.name(message.network)
items.append(('Open on %s' % (network), link))
items.append((_('Open on %s') % (network), link))
urls = URL_RE.findall(message.message)
for url in urls:
@ -718,11 +719,11 @@ class Interface(object):
"""Update the elements in the interface that should change in case of
changes in the message count."""
child = self._main_tabs.get_nth_page(0)
self._main_tabs.set_tab_label_text(child, 'Messages (%d)' %
self._main_tabs.set_tab_label_text(child, _('Messages (%d)') %
(self._new_message_count))
child = self._main_tabs.get_nth_page(1)
self._main_tabs.set_tab_label_text(child, 'Replies (%d)' %
self._main_tabs.set_tab_label_text(child, _('Replies (%d)') %
(self._new_replies_count))
if self._statusicon:
@ -797,12 +798,13 @@ class Interface(object):
count = len(text)
if self._reply_message_id:
suffix = '(replying to %s)' % (self._reply_message_id.username)
suffix = _('(replying to %s)') % (self._reply_message_id.username)
else:
suffix = ''
# TODO: gettext to properly use "characters"/"character"
text = '%d characters %s' % (count, suffix)
text = N_('%d character %s', '%d characters %s', count) % (count,
suffix)
self._statusbar.push(self._remove_count_status(), text)
self._update_sensitivity(not (count == 0))
@ -820,7 +822,7 @@ class Interface(object):
_log.debug('Status: %s', status)
self._remove_count_status()
self._update_statusbar('Sending update...')
self._update_statusbar(_('Sending update...'))
self._update_sensitivity(False)
self._threads.add_work(self._post_update_status,
self._exception_update_status,
@ -930,7 +932,7 @@ class Interface(object):
confirm = gtk.MessageDialog(parent=self._main_window,
type=gtk.MESSAGE_QUESTION,
message_format='Delete this message?',
message_format=_('Delete this message?'),
buttons=gtk.BUTTONS_YES_NO);
option = confirm.run()
confirm.hide()
@ -940,7 +942,7 @@ class Interface(object):
_log.debug("Delete cancelled");
return False
self._update_statusbar('Deleting message...')
self._update_statusbar(_('Deleting message...'))
self._delete_iter = iter
_log.debug('Deleting messing %d', message.id)
self._threads.add_work(self._post_delete_message,
@ -966,7 +968,7 @@ class Interface(object):
grid = self._get_current_grid()
(model, iter) = grid.get_selection().get_selected()
message = model.get_value(iter, 0)
self._update_statusbar('Reposting %s message...' %
self._update_statusbar(_('Reposting %s message...') %
(message.username))
self._threads.add_work(self._post_repost_message,
self._exception_repost_message,
@ -983,9 +985,9 @@ class Interface(object):
self._favourite_iter = iter
if message.favourite:
display = 'Removing message from %s from favourites...'
display = _('Removing message from %s from favourites...')
else:
display = 'Marking message from %s as favourite...'
display = _('Marking message from %s as favourite...')
self._update_status(display % (message.username))
self._threads.add_work(self._post_favourite_message,
@ -996,7 +998,7 @@ class Interface(object):
def _show_settings(self, widget, user_data=None):
"""Display the settings window."""
settings_window = gtk.Dialog(title='Settings',
settings_window = gtk.Dialog(title=_('Settings'),
parent=self._main_window,
flags=gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT,
buttons=(gtk.STOCK_OK, 0))
@ -1013,12 +1015,12 @@ class Interface(object):
self._refresh_interval_field.set_increments(1, 5)
interface_box = gtk.Table(rows=1, columns=2, homogeneous=False)
interface_box.attach(gtk.Label('Refresh interval (minutes):'),
interface_box.attach(gtk.Label(_('Refresh interval (minutes):')),
0, 1, 0, 1)
interface_box.attach(self._refresh_interval_field, 0, 1, 1, 2)
interface_box.show_all()
tabs.insert_page(interface_box, gtk.Label('Interface'))
tabs.insert_page(interface_box, gtk.Label(_('Interface')))
# We store the fields in a dictionary, inside dictionaries for each
# NAMESPACE. To set the values, we just run the dictionaries setting
@ -1176,7 +1178,7 @@ class Interface(object):
self._message_count_updated()
# now get replies
self._update_statusbar('Retrieving replies...')
self._update_statusbar(_('Retrieving replies...'))
self._threads.add_work(self._post_get_replies,
self._exception_get_messages,
self._connection.replies)
@ -1188,13 +1190,13 @@ class Interface(object):
_log.debug(str(exception))
error_win = gtk.MessageDialog(parent=self._main_window,
type=gtk.MESSAGE_ERROR,
message_format='Error retrieving current messages. ' \
message_format=_('Error retrieving current messages. ' \
'Auto-refresh disabled. Use the "Refresh" option ' \
'to re-enable it.',
'to re-enable it.'),
buttons=gtk.BUTTONS_OK)
error_win.run()
error_win.hide()
self._update_statusbar('Auto-update disabled')
self._update_statusbar(_('Auto-update disabled'))
if self._statusicon:
self._statusicon.set_from_pixbuf(self._images['icon-error'])
return
@ -1216,8 +1218,8 @@ class Interface(object):
interval = self._options[self.NAMESPACE]['refresh_interval']
_log.debug('Queueing next refresh in %d minutes', interval)
self._update_statusbar('New messages retrieved. Next update in ' \
'%d minutes.' % (interval))
self._update_statusbar(_('New messages retrieved. Next update in ' \
'%d minutes.') % (interval))
self._refresh_id = gobject.timeout_add(
interval * 60 * 1000,
self._refresh, None)
@ -1260,7 +1262,7 @@ class Interface(object):
### Results for the update status call
def _post_update_status(self, widget, data):
"""Called when the status is updated correctly."""
self._update_statusbar('Your status was updated.')
self._update_statusbar(_('Your status was updated.'))
self._update_sensitivity(False)
self._clear_text(None)
return
@ -1272,8 +1274,8 @@ class Interface(object):
_log.debug(str(exception))
error_win = gtk.MessageDialog(parent=self._main_window,
type=gtk.MESSAGE_ERROR,
message_format='Error updating your status. Please ' \
'try again.',
message_format=_('Error updating your status. Please ' \
'try again.'),
buttons=gtk.BUTTONS_OK)
error_win.run()
error_win.hide()
@ -1286,7 +1288,7 @@ class Interface(object):
if self._delete_iter:
self._grid.get_model().remove(self._delete_iter)
self._delete_iter = None
self._update_statusbar('Message deleted.')
self._update_statusbar(_('Message deleted.'))
return
def _exception_delete_message(self, widget, exception):
@ -1299,7 +1301,7 @@ class Interface(object):
def _post_repost_message(self, widget, data):
"""Called when the message is reposted successfully."""
_log.debug('Repost successful')
self._update_statusbar('Message reposted')
self._update_statusbar(_('Message reposted'))
return
def _exception_repost_message(self, widget, exception):
@ -1309,8 +1311,8 @@ class Interface(object):
error_win = gtk.MessageDialog(parent=self._main_window,
type=gtk.MESSAGE_ERROR,
message_format='Error reposting message. Please ' \
'try again.',
message_format=_('Error reposting message. Please ' \
'try again.'),
buttons=gtk.BUTTONS_OK)
error_win.run()
error_win.hide()
@ -1322,9 +1324,9 @@ class Interface(object):
_log.debug('Favourite status changed.')
message = self._grid.get_model().get_value(self._favourite_iter, 0)
if message.favourite:
display = 'Message unfavourited.'
display = _('Message unfavourited.')
else:
display = 'Message favourited.'
display = _('Message favourited.')
self._update_statusbar(display)
message.favourite = not message.favourite
self._favourite_iter = None
@ -1337,8 +1339,8 @@ class Interface(object):
error_win = gtk.MessageDialog(parent=self._main_window,
type=gtk.MESSAGE_ERROR,
message_format='Error changing favourite status of the ' \
'message. Please, try again.',
message_format=_('Error changing favourite status of the ' \
'message. Please, try again.'),
buttons=gtk.BUTTONS_OK)
error_win.run()
error_win.hide()
@ -1413,7 +1415,7 @@ class Interface(object):
options.add_option('--refresh-interval',
group=self.NAMESPACE,
option='refresh_interval',
help='Refresh interval',
help=_('Refresh interval.'),
type='int',
metavar='MINUTES',
default=5,
@ -1422,6 +1424,7 @@ class Interface(object):
group=self.NAMESPACE,
action='store_false',
option='statusicon',
help=_('Disable the use of the status icon.'),
default=True,
conflict_group='interface')
# Most of the options for non-cmd-options are useless, but I'm keeping

Loading…
Cancel
Save