diff options
author | Emmanuel Gil Peyrot <linkmauve@linkmauve.fr> | 2015-05-10 10:37:00 +0200 |
---|---|---|
committer | mathieui <mathieui@mathieui.net> | 2015-05-11 22:31:12 +0200 |
commit | dd98aa44a5084f0590645f5ee9565ab962e6c844 (patch) | |
tree | 8e16fbb20e969eadfea5ba2689e1de4539ffcf94 /src | |
parent | 861f5c4bbd775b091362766ecafeb7d1955aab2f (diff) | |
download | poezio-dd98aa44a5084f0590645f5ee9565ab962e6c844.tar.gz poezio-dd98aa44a5084f0590645f5ee9565ab962e6c844.tar.bz2 poezio-dd98aa44a5084f0590645f5ee9565ab962e6c844.tar.xz poezio-dd98aa44a5084f0590645f5ee9565ab962e6c844.zip |
Remove gettext support, as we don’t want to translate poezio, and it takes more than 1ms per call.
Diffstat (limited to 'src')
-rw-r--r-- | src/args.py | 7 | ||||
-rw-r--r-- | src/bookmarks.py | 5 | ||||
-rw-r--r-- | src/config.py | 13 | ||||
-rw-r--r-- | src/core/commands.py | 69 | ||||
-rw-r--r-- | src/core/core.py | 321 | ||||
-rw-r--r-- | src/core/handlers.py | 57 | ||||
-rw-r--r-- | src/core/structs.py | 51 | ||||
-rw-r--r-- | src/multiuserchat.py | 7 | ||||
-rw-r--r-- | src/pep.py | 356 | ||||
-rw-r--r-- | src/plugin_manager.py | 15 | ||||
-rw-r--r-- | src/tabs/adhoc_commands_list.py | 6 | ||||
-rw-r--r-- | src/tabs/basetabs.py | 56 | ||||
-rw-r--r-- | src/tabs/bookmarkstab.py | 18 | ||||
-rw-r--r-- | src/tabs/conversationtab.py | 38 | ||||
-rw-r--r-- | src/tabs/listtab.py | 6 | ||||
-rw-r--r-- | src/tabs/muclisttab.py | 6 | ||||
-rw-r--r-- | src/tabs/muctab.py | 388 | ||||
-rw-r--r-- | src/tabs/privatetab.py | 26 | ||||
-rw-r--r-- | src/tabs/rostertab.py | 206 | ||||
-rw-r--r-- | src/tabs/xmltab.py | 42 |
20 files changed, 831 insertions, 862 deletions
diff --git a/src/args.py b/src/args.py index a67a0142..8b1ebbbd 100644 --- a/src/args.py +++ b/src/args.py @@ -3,7 +3,6 @@ Module related to the argument parsing There is a fallback to the deprecated optparse if argparse is not found """ -from gettext import gettext as _ from os import path from argparse import ArgumentParser, SUPPRESS @@ -14,13 +13,13 @@ def parse_args(CONFIG_PATH=''): parser = ArgumentParser('poezio') parser.add_argument("-c", "--check-config", dest="check_config", action='store_true', - help=_('Check the config file')) + help='Check the config file') parser.add_argument("-d", "--debug", dest="debug", - help=_("The file where debug will be written"), + help="The file where debug will be written", metavar="DEBUG_FILE") parser.add_argument("-f", "--file", dest="filename", default=path.join(CONFIG_PATH, 'poezio.cfg'), - help=_("The config file you want to use"), + help="The config file you want to use", metavar="CONFIG_FILE") parser.add_argument("-v", "--version", dest="version", help=SUPPRESS, metavar="VERSION", diff --git a/src/bookmarks.py b/src/bookmarks.py index 9a875217..c7d26a51 100644 --- a/src/bookmarks.py +++ b/src/bookmarks.py @@ -30,7 +30,6 @@ Adding a remote bookmark: import functools import logging -from gettext import gettext as _ from slixmpp.plugins.xep_0048 import Bookmarks, Conference, URL from slixmpp import JID @@ -245,7 +244,7 @@ class BookmarkList(object): """Add the remotely stored bookmarks to the list.""" force = config.get('force_remote_bookmarks') if xmpp.anon or not (any(self.available_storage.values()) or force): - information(_('No remote bookmark storage available'), 'Warning') + information('No remote bookmark storage available', 'Warning') return if force and not any(self.available_storage.values()): @@ -256,7 +255,7 @@ class BookmarkList(object): self.available_storage[method] = True old_callback(result) else: - information(_('No remote bookmark storage available'), 'Warning') + information('No remote bookmark storage available', 'Warning') callback = new_callback if self.preferred == 'pep': diff --git a/src/config.py b/src/config.py index 3a693be8..3ca53dd2 100644 --- a/src/config.py +++ b/src/config.py @@ -16,7 +16,6 @@ import logging.config import os import sys import pkg_resources -from gettext import gettext as _ from configparser import RawConfigParser, NoOptionError, NoSectionError from os import environ, makedirs, path, remove @@ -410,9 +409,9 @@ class Config(RawConfigParser): elif current.lower() == "true": value = "false" else: - return (_('Could not toggle option: %s.' - ' Current value is %s.') % - (option, current or _("empty")), + return ('Could not toggle option: %s.' + ' Current value is %s.' % + (option, current or "empty"), 'Warning') if self.has_section(section): RawConfigParser.set(self, section, option, value) @@ -420,7 +419,7 @@ class Config(RawConfigParser): self.add_section(section) RawConfigParser.set(self, section, option, value) if not self.write_in_file(section, option, value): - return (_('Unable to write in the config file'), 'Error') + return ('Unable to write in the config file', 'Error') return ("%s=%s" % (option, value), 'Info') def remove_and_save(self, option, section=DEFSECTION): @@ -430,8 +429,8 @@ class Config(RawConfigParser): if self.has_section(section): RawConfigParser.remove_option(self, section, option) if not self.remove_in_file(section, option): - return (_('Unable to save the config file'), 'Error') - return (_('Option %s deleted') % option, 'Info') + return ('Unable to save the config file', 'Error') + return ('Option %s deleted' % option, 'Info') def silent_set(self, option, value, section=DEFSECTION): """ diff --git a/src/core/commands.py b/src/core/commands.py index d3bf8023..3830d72a 100644 --- a/src/core/commands.py +++ b/src/core/commands.py @@ -8,7 +8,6 @@ log = logging.getLogger(__name__) import os from datetime import datetime -from gettext import gettext as _ from xml.etree import cElementTree as ET from slixmpp.xmlstream.stanzabase import StanzaBase @@ -65,7 +64,7 @@ def command_help(self, args): buff.extend(acc) msg = '\n'.join(buff) - msg += _("\nType /help <command_name> to know what each command does") + msg += "\nType /help <command_name> to know what each command does" else: command = args[0].lstrip('/').strip() @@ -74,10 +73,10 @@ def command_help(self, args): elif command in self.commands: tup = self.commands[command] else: - self.information(_('Unknown command: %s') % command, 'Error') + self.information('Unknown command: %s' % command, 'Error') return if isinstance(tup, Command): - msg = _('Usage: /%s %s\n' % (command, tup.usage)) + msg = 'Usage: /%s %s\n' % (command, tup.usage) msg += tup.desc else: msg = tup[1] @@ -155,7 +154,7 @@ def command_presence(self, args): self.events.trigger('send_normal_presence', pres) pres.send() except: - self.information(_('Could not send directed presence'), 'Error') + self.information('Could not send directed presence', 'Error') log.debug('Could not send directed presence to %s', jid, exc_info=True) return tab = self.get_tab_by_name(jid) @@ -286,14 +285,14 @@ def command_version(self, args): def callback(res): "Callback for /version" if not res: - return self.information(_('Could not get the software' - ' version from %s') % jid, - _('Warning')) - version = _('%s is running %s version %s on %s') % ( + return self.information('Could not get the software' + ' version from %s' % jid, + 'Warning') + version = '%s is running %s version %s on %s' % ( jid, - res.get('name') or _('an unknown software'), - res.get('version') or _('unknown'), - res.get('os') or _('an unknown platform')) + res.get('name') or 'an unknown software', + res.get('version') or 'unknown', + res.get('os') or 'an unknown platform') self.information(version, 'Info') if args is None: @@ -522,9 +521,9 @@ def command_remove_bookmark(self, args): def cb(success): if success: - self.information(_('Bookmark deleted'), 'Info') + self.information('Bookmark deleted', 'Info') else: - self.information(_('Error while deleting the bookmark'), 'Error') + self.information('Error while deleting the bookmark', 'Error') if not args: tab = self.current_tab() @@ -532,13 +531,13 @@ def command_remove_bookmark(self, args): self.bookmarks.remove(tab.name) self.bookmarks.save(self.xmpp, callback=cb) else: - self.information(_('No bookmark to remove'), 'Info') + self.information('No bookmark to remove', 'Info') else: if self.bookmarks[args[0]]: self.bookmarks.remove(args[0]) self.bookmarks.save(self.xmpp, callback=cb) else: - self.information(_('No bookmark to remove'), 'Info') + self.information('No bookmark to remove', 'Info') @command_args_parser.quoted(0, 3) def command_set(self, args): @@ -610,8 +609,8 @@ def command_set(self, args): if args[0] == '.': name = safeJID(self.current_tab().name).bare if not name: - self.information(_('Invalid tab to use the "." argument.'), - _('Error')) + self.information('Invalid tab to use the "." argument.', + 'Error') return section = name else: @@ -672,7 +671,7 @@ def command_server_cycle(self, args): if isinstance(tab, tabs.MucTab): domain = safeJID(tab.name).domain else: - return self.information(_("No server specified"), "Error") + return self.information("No server specified", "Error") for tab in self.get_tabs(tabs.MucTab): if tab.name.endswith(domain): if tab.joined: @@ -695,11 +694,11 @@ def command_last_activity(self, args): "Callback for the last activity" if iq['type'] != 'result': if iq['error']['type'] == 'auth': - self.information(_('You are not allowed to see the ' - 'activity of this contact.'), - _('Error')) + self.information('You are not allowed to see the ' + 'activity of this contact.', + 'Error') else: - self.information(_('Error retrieving the activity'), 'Error') + self.information('Error retrieving the activity', 'Error') return seconds = iq['last_activity']['seconds'] status = iq['last_activity']['status'] @@ -731,9 +730,9 @@ def command_mood(self, args): mood = args[0] if mood not in pep.MOODS: - return self.information(_('%s is not a correct value for a mood.') + return self.information('%s is not a correct value for a mood.' % mood, - _('Error')) + 'Error') if len(args) == 2: text = args[1] else: @@ -752,9 +751,9 @@ def command_activity(self, args): general = args[0] if general not in pep.ACTIVITIES: - return self.information(_('%s is not a correct value for an activity') + return self.information('%s is not a correct value for an activity' % general, - _('Error')) + 'Error') specific = None text = None if length == 2: @@ -766,9 +765,9 @@ def command_activity(self, args): specific = args[1] text = args[2] if specific and specific not in pep.ACTIVITIES[general]: - return self.information(_('%s is not a correct value ' - 'for an activity') % specific, - _('Error')) + return self.information('%s is not a correct value ' + 'for an activity' % specific, + 'Error') self.xmpp.plugin['xep_0108'].publish_activity(general, specific, text, callback=dumb_callback) @@ -862,7 +861,7 @@ def command_destroy_room(self, args): elif isinstance(self.current_tab(), tabs.MucTab) and not args[0]: muc.destroy_room(self.xmpp, self.current_tab().general_jid) else: - self.information(_('Invalid JID: "%s"') % args[0], _('Error')) + self.information('Invalid JID: "%s"' % args[0], 'Error') @command_args_parser.quoted(1, 1, ['']) def command_bind(self, args): @@ -873,7 +872,7 @@ def command_bind(self, args): return self.command_help('bind') if not config.silent_set(args[0], args[1], section='bindings'): - self.information(_('Unable to write in the config file'), 'Error') + self.information('Unable to write in the config file', 'Error') if args[1]: self.information('%s is now bound to %s' % (args[0], args[1]), 'Info') @@ -913,7 +912,7 @@ def command_rawxml(self, args): stanza.send() except: - self.information(_('Could not send custom stanza'), 'Error') + self.information('Could not send custom stanza', 'Error') log.debug('/rawxml: Could not send custom stanza (%s)', repr(stanza), exc_info=True) @@ -941,9 +940,9 @@ def command_plugins(self): """ /plugins """ - self.information(_("Plugins currently in use: %s") % + self.information("Plugins currently in use: %s" % repr(list(self.plugin_manager.plugins.keys())), - _('Info')) + 'Info') @command_args_parser.quoted(1, 1) def command_message(self, args): diff --git a/src/core/core.py b/src/core/core.py index e5a6a970..92c9f987 100644 --- a/src/core/core.py +++ b/src/core/core.py @@ -17,7 +17,6 @@ import pipes import sys import time from threading import Event -from gettext import gettext as _ from slixmpp.xmlstream.handler import Callback @@ -509,15 +508,15 @@ class Core(object): default_tab = tabs.RosterInfoTab() default_tab.on_gain_focus() self.tabs.append(default_tab) - self.information(_('Welcome to poezio!'), _('Info')) + self.information('Welcome to poezio!', 'Info') if firstrun: - self.information(_( + self.information( 'It seems that it is the first time you start poezio.\n' 'The online help is here http://doc.poez.io/\n' 'No room is joined by default, but you can join poezio’s' 'chatroom (with /join poezio@muc.poez.io), where you can' - ' ask for help or tell us how great it is.'), - _('Help')) + ' ask for help or tell us how great it is.', + 'Help') self.refresh_window() self.xmpp.plugin['xep_0012'].begin_idle(jid=self.xmpp.boundjid) @@ -650,9 +649,9 @@ class Core(object): self.information_win_size, 'var') if not ok: - self.information(_('Unable to save runtime preferences' - ' in the config file'), - _('Error')) + self.information('Unable to save runtime preferences' + ' in the config file', + 'Error') def on_roster_enter_key(self, roster_row): """ @@ -708,8 +707,8 @@ class Core(object): func(arg) return else: - self.information(_("Unknown command (%s)") % (command), - _('Error')) + self.information("Unknown command (%s)" % (command), + 'Error') def exec_command(self, command): """ @@ -842,8 +841,8 @@ class Core(object): msg = msg.replace('\n', '|') if msg else '' ok = ok and config.silent_set('status_message', msg) if not ok: - self.information(_('Unable to save the status in ' - 'the config file'), 'Error') + self.information('Unable to save the status in ' + 'the config file', 'Error') def get_bookmark_nickname(self, room_name): """ @@ -917,18 +916,18 @@ class Core(object): if code in DEPRECATED_ERRORS: body = DEPRECATED_ERRORS[code] else: - body = condition or _('Unknown error') + body = condition or 'Unknown error' else: if code in ERROR_AND_STATUS_CODES: body = ERROR_AND_STATUS_CODES[code] else: - body = condition or _('Unknown error') + body = condition or 'Unknown error' if code: - message = _('%(from)s: %(code)s - %(msg)s: %(body)s') % { - 'from': sender, 'msg': msg, 'body': body, 'code': code} + message = '%(from)s: %(code)s - %(msg)s: %(body)s' % { + 'from': sender, 'msg': msg, 'body': body, 'code': code} else: - message = _('%(from)s: %(msg)s: %(body)s') % { - 'from': sender, 'msg': msg, 'body': body} + message = '%(from)s: %(msg)s: %(body)s' % { + 'from': sender, 'msg': msg, 'body': body} return message @@ -1295,7 +1294,7 @@ class Core(object): Disable private tabs when leaving a room """ if reason is None: - reason = _('\x195}You left the chatroom\x193}') + reason = '\x195}You left the chatroom\x193}' for tab in self.get_tabs(tabs.PrivateTab): if tab.name.startswith(room_name): tab.deactivate(reason=reason) @@ -1305,7 +1304,7 @@ class Core(object): Enable private tabs when joining a room """ if reason is None: - reason = _('\x195}You joined the chatroom\x193}') + reason = '\x195}You joined the chatroom\x193}' for tab in self.get_tabs(tabs.PrivateTab): if tab.name.startswith(room_name): tab.activate(reason=reason) @@ -1594,7 +1593,7 @@ class Core(object): """ enabled = config.get('enable_vertical_tab_list') if not config.silent_set('enable_vertical_tab_list', str(not enabled)): - self.information(_('Unable to write in the config file'), 'Error') + self.information('Unable to write in the config file', 'Error') self.call_for_resize() def resize_global_information_win(self): @@ -1719,225 +1718,225 @@ class Core(object): Register the commands when poezio starts """ self.register_command('help', self.command_help, - usage=_('[command]'), + usage='[command]', shortdesc='\\_o< KOIN KOIN KOIN', completion=self.completion_help) self.register_command('join', self.command_join, - usage=_("[room_name][@server][/nick] [password]"), - desc=_("Join the specified room. You can specify a nickname " - "after a slash (/). If no nickname is specified, you will" - " use the default_nick in the configuration file. You can" - " omit the room name: you will then join the room you\'re" - " looking at (useful if you were kicked). You can also " - "provide a room_name without specifying a server, the " - "server of the room you're currently in will be used. You" - " can also provide a password to join the room.\nExamples" - ":\n/join room@server.tld\n/join room@server.tld/John\n" - "/join room2\n/join /me_again\n/join\n/join room@server" - ".tld/my_nick password\n/join / password"), - shortdesc=_('Join a room'), + usage="[room_name][@server][/nick] [password]", + desc="Join the specified room. You can specify a nickname " + "after a slash (/). If no nickname is specified, you will" + " use the default_nick in the configuration file. You can" + " omit the room name: you will then join the room you\'re" + " looking at (useful if you were kicked). You can also " + "provide a room_name without specifying a server, the " + "server of the room you're currently in will be used. You" + " can also provide a password to join the room.\nExamples" + ":\n/join room@server.tld\n/join room@server.tld/John\n" + "/join room2\n/join /me_again\n/join\n/join room@server" + ".tld/my_nick password\n/join / password", + shortdesc='Join a room', completion=self.completion_join) self.register_command('exit', self.command_quit, - desc=_('Just disconnect from the server and exit poezio.'), - shortdesc=_('Exit poezio.')) + desc='Just disconnect from the server and exit poezio.', + shortdesc='Exit poezio.') self.register_command('quit', self.command_quit, - desc=_('Just disconnect from the server and exit poezio.'), - shortdesc=_('Exit poezio.')) + desc='Just disconnect from the server and exit poezio.', + shortdesc='Exit poezio.') self.register_command('next', self.rotate_rooms_right, - shortdesc=_('Go to the next room.')) + shortdesc='Go to the next room.') self.register_command('prev', self.rotate_rooms_left, - shortdesc=_('Go to the previous room.')) + shortdesc='Go to the previous room.') self.register_command('win', self.command_win, - usage=_('<number or name>'), - shortdesc=_('Go to the specified room'), + usage='<number or name>', + shortdesc='Go to the specified room', completion=self.completion_win) self.commands['w'] = self.commands['win'] self.register_command('move_tab', self.command_move_tab, - usage=_('<source> <destination>'), - desc=_("Insert the <source> tab at the position of " - "<destination>. This will make the following tabs shift in" - " some cases (refer to the documentation). A tab can be " - "designated by its number or by the beginning of its " - "address. You can use \".\" as a shortcut for the current " - "tab."), - shortdesc=_('Move a tab.'), + usage='<source> <destination>', + desc="Insert the <source> tab at the position of " + "<destination>. This will make the following tabs shift in" + " some cases (refer to the documentation). A tab can be " + "designated by its number or by the beginning of its " + "address. You can use \".\" as a shortcut for the current " + "tab.", + shortdesc='Move a tab.', completion=self.completion_move_tab) self.register_command('destroy_room', self.command_destroy_room, - usage=_('[room JID]'), - desc=_('Try to destroy the room [room JID], or the current' - ' tab if it is a multi-user chat and [room JID] is ' - 'not given.'), - shortdesc=_('Destroy a room.'), + usage='[room JID]', + desc='Try to destroy the room [room JID], or the current' + ' tab if it is a multi-user chat and [room JID] is ' + 'not given.', + shortdesc='Destroy a room.', completion=None) self.register_command('show', self.command_status, - usage=_('<availability> [status message]'), - desc=_("Sets your availability and (optionally) your status " - "message. The <availability> argument is one of \"available" - ", chat, away, afk, dnd, busy, xa\" and the optional " - "[status message] argument will be your status message."), - shortdesc=_('Change your availability.'), + usage='<availability> [status message]', + desc="Sets your availability and (optionally) your status " + "message. The <availability> argument is one of \"available" + ", chat, away, afk, dnd, busy, xa\" and the optional " + "[status message] argument will be your status message.", + shortdesc='Change your availability.', completion=self.completion_status) self.commands['status'] = self.commands['show'] self.register_command('bookmark_local', self.command_bookmark_local, - usage=_("[roomname][/nick] [password]"), - desc=_("Bookmark Local: Bookmark locally the specified room " - "(you will then auto-join it on each poezio start). This" - " commands uses almost the same syntaxe as /join. Type " - "/help join for syntax examples. Note that when typing " - "\"/bookmark\" on its own, the room will be bookmarked " - "with the nickname you\'re currently using in this room " - "(instead of default_nick)"), - shortdesc=_('Bookmark a room locally.'), + usage="[roomname][/nick] [password]", + desc="Bookmark Local: Bookmark locally the specified room " + "(you will then auto-join it on each poezio start). This" + " commands uses almost the same syntaxe as /join. Type " + "/help join for syntax examples. Note that when typing " + "\"/bookmark\" on its own, the room will be bookmarked " + "with the nickname you\'re currently using in this room " + "(instead of default_nick)", + shortdesc='Bookmark a room locally.', completion=self.completion_bookmark_local) self.register_command('bookmark', self.command_bookmark, - usage=_("[roomname][/nick] [autojoin] [password]"), - desc=_("Bookmark: Bookmark online the specified room (you " - "will then auto-join it on each poezio start if autojoin" - " is specified and is 'true'). This commands uses almost" - " the same syntax as /join. Type /help join for syntax " - "examples. Note that when typing \"/bookmark\" alone, the" - " room will be bookmarked with the nickname you\'re " - "currently using in this room (instead of default_nick)."), - shortdesc=_("Bookmark a room online."), + usage="[roomname][/nick] [autojoin] [password]", + desc="Bookmark: Bookmark online the specified room (you " + "will then auto-join it on each poezio start if autojoin" + " is specified and is 'true'). This commands uses almost" + " the same syntax as /join. Type /help join for syntax " + "examples. Note that when typing \"/bookmark\" alone, the" + " room will be bookmarked with the nickname you\'re " + "currently using in this room (instead of default_nick).", + shortdesc="Bookmark a room online.", completion=self.completion_bookmark) self.register_command('set', self.command_set, - usage=_("[plugin|][section] <option> [value]"), - desc=_("Set the value of an option in your configuration file." - " You can, for example, change your default nickname by " - "doing `/set default_nick toto` or your resource with `/set" - " resource blabla`. You can also set options in specific " - "sections with `/set bindings M-i ^i` or in specific plugin" - " with `/set mpd_client| host 127.0.0.1`. `toggle` can be " - "used as a special value to toggle a boolean option."), - shortdesc=_("Set the value of an option"), + usage="[plugin|][section] <option> [value]", + desc="Set the value of an option in your configuration file." + " You can, for example, change your default nickname by " + "doing `/set default_nick toto` or your resource with `/set" + " resource blabla`. You can also set options in specific " + "sections with `/set bindings M-i ^i` or in specific plugin" + " with `/set mpd_client| host 127.0.0.1`. `toggle` can be " + "used as a special value to toggle a boolean option.", + shortdesc="Set the value of an option", completion=self.completion_set) self.register_command('set_default', self.command_set_default, - usage=_("[section] <option>"), - desc=_("Set the default value of an option. For example, " - "`/set_default resource` will reset the resource " - "option. You can also reset options in specific " - "sections by doing `/set_default section option`."), - shortdesc=_("Set the default value of an option"), + usage="[section] <option>", + desc="Set the default value of an option. For example, " + "`/set_default resource` will reset the resource " + "option. You can also reset options in specific " + "sections by doing `/set_default section option`.", + shortdesc="Set the default value of an option", completion=self.completion_set_default) self.register_command('toggle', self.command_toggle, - usage=_('<option>'), - desc=_('Shortcut for /set <option> toggle'), - shortdesc=_('Toggle an option'), + usage='<option>', + desc='Shortcut for /set <option> toggle', + shortdesc='Toggle an option', completion=self.completion_toggle) self.register_command('theme', self.command_theme, - usage=_('[theme name]'), - desc=_("Reload the theme defined in the config file. If theme" - "_name is provided, set that theme before reloading it."), - shortdesc=_('Load a theme'), + usage='[theme name]', + desc="Reload the theme defined in the config file. If theme" + "_name is provided, set that theme before reloading it.", + shortdesc='Load a theme', completion=self.completion_theme) self.register_command('list', self.command_list, - usage=_('[server]'), - desc=_("Get the list of public chatrooms" - " on the specified server."), - shortdesc=_('List the rooms.'), + usage='[server]', + desc="Get the list of public chatrooms" + " on the specified server.", + shortdesc='List the rooms.', completion=self.completion_list) self.register_command('message', self.command_message, - usage=_('<jid> [optional message]'), - desc=_("Open a conversation with the specified JID (even if it" - " is not in our roster), and send a message to it, if the " - "message is specified."), - shortdesc=_('Send a message'), + usage='<jid> [optional message]', + desc="Open a conversation with the specified JID (even if it" + " is not in our roster), and send a message to it, if the " + "message is specified.", + shortdesc='Send a message', completion=self.completion_message) self.register_command('version', self.command_version, usage='<jid>', - desc=_("Get the software version of the given JID (usually its" - " XMPP client and Operating System)."), - shortdesc=_('Get the software version of a JID.'), + desc="Get the software version of the given JID (usually its" + " XMPP client and Operating System).", + shortdesc='Get the software version of a JID.', completion=self.completion_version) self.register_command('server_cycle', self.command_server_cycle, - usage=_('[domain] [message]'), - desc=_('Disconnect and reconnect in all the rooms in domain.'), - shortdesc=_('Cycle a range of rooms'), + usage='[domain] [message]', + desc='Disconnect and reconnect in all the rooms in domain.', + shortdesc='Cycle a range of rooms', completion=self.completion_server_cycle) self.register_command('bind', self.command_bind, - usage=_('<key> <equ>'), - desc=_("Bind a key to another key or to a “command”. For " - "example \"/bind ^H KEY_UP\" makes Control + h do the" - " same same as the Up key."), + usage='<key> <equ>', + desc="Bind a key to another key or to a “command”. For " + "example \"/bind ^H KEY_UP\" makes Control + h do the" + " same same as the Up key.", completion=self.completion_bind, - shortdesc=_('Bind a key to another key.')) + shortdesc='Bind a key to another key.') self.register_command('load', self.command_load, - usage=_('<plugin> [<otherplugin> …]'), - shortdesc=_('Load the specified plugin(s)'), + usage='<plugin> [<otherplugin> …]', + shortdesc='Load the specified plugin(s)', completion=self.plugin_manager.completion_load) self.register_command('unload', self.command_unload, - usage=_('<plugin> [<otherplugin> …]'), - shortdesc=_('Unload the specified plugin(s)'), + usage='<plugin> [<otherplugin> …]', + shortdesc='Unload the specified plugin(s)', completion=self.plugin_manager.completion_unload) self.register_command('plugins', self.command_plugins, - shortdesc=_('Show the plugins in use.')) + shortdesc='Show the plugins in use.') self.register_command('presence', self.command_presence, - usage=_('<JID> [type] [status]'), - desc=_("Send a directed presence to <JID> and using" - " [type] and [status] if provided."), - shortdesc=_('Send a directed presence.'), + usage='<JID> [type] [status]', + desc="Send a directed presence to <JID> and using" + " [type] and [status] if provided.", + shortdesc='Send a directed presence.', completion=self.completion_presence) self.register_command('rawxml', self.command_rawxml, usage='<xml>', - shortdesc=_('Send a custom xml stanza.')) + shortdesc='Send a custom xml stanza.') self.register_command('invite', self.command_invite, - usage=_('<jid> <room> [reason]'), - desc=_('Invite jid in room with reason.'), - shortdesc=_('Invite someone in a room.'), + usage='<jid> <room> [reason]', + desc='Invite jid in room with reason.', + shortdesc='Invite someone in a room.', completion=self.completion_invite) self.register_command('invitations', self.command_invitations, - shortdesc=_('Show the pending invitations.')) + shortdesc='Show the pending invitations.') self.register_command('bookmarks', self.command_bookmarks, - shortdesc=_('Show the current bookmarks.')) + shortdesc='Show the current bookmarks.') self.register_command('remove_bookmark', self.command_remove_bookmark, usage='[jid]', - desc=_("Remove the specified bookmark, or the " - "bookmark on the current tab, if any."), - shortdesc=_('Remove a bookmark'), + desc="Remove the specified bookmark, or the " + "bookmark on the current tab, if any.", + shortdesc='Remove a bookmark', completion=self.completion_remove_bookmark) self.register_command('xml_tab', self.command_xml_tab, - shortdesc=_('Open an XML tab.')) + shortdesc='Open an XML tab.') self.register_command('runkey', self.command_runkey, - usage=_('<key>'), - shortdesc=_('Execute the action defined for <key>.'), + usage='<key>', + shortdesc='Execute the action defined for <key>.', completion=self.completion_runkey) self.register_command('self', self.command_self, - shortdesc=_('Remind you of who you are.')) + shortdesc='Remind you of who you are.') self.register_command('last_activity', self.command_last_activity, usage='<jid>', - desc=_('Informs you of the last activity of a JID.'), - shortdesc=_('Get the activity of someone.'), + desc='Informs you of the last activity of a JID.', + shortdesc='Get the activity of someone.', completion=self.completion_last_activity) self.register_command('ad-hoc', self.command_adhoc, usage='<jid>', - shortdesc=_('List available ad-hoc commands on the given jid')) + shortdesc='List available ad-hoc commands on the given jid') self.register_command('reload', self.command_reload, - shortdesc=_('Reload the config. You can achieve the same by ' - 'sending SIGUSR1 to poezio.')) + shortdesc='Reload the config. You can achieve the same by ' + 'sending SIGUSR1 to poezio.') if config.get('enable_user_activity'): self.register_command('activity', self.command_activity, usage='[<general> [specific] [text]]', - desc=_('Send your current activity to your contacts ' - '(use the completion). Nothing means ' - '"stop broadcasting an activity".'), - shortdesc=_('Send your activity.'), + desc='Send your current activity to your contacts ' + '(use the completion). Nothing means ' + '"stop broadcasting an activity".', + shortdesc='Send your activity.', completion=self.completion_activity) if config.get('enable_user_mood'): self.register_command('mood', self.command_mood, usage='[<mood> [text]]', - desc=_('Send your current mood to your contacts ' - '(use the completion). Nothing means ' - '"stop broadcasting a mood".'), - shortdesc=_('Send your mood.'), + desc='Send your current mood to your contacts ' + '(use the completion). Nothing means ' + '"stop broadcasting a mood".', + shortdesc='Send your mood.', completion=self.completion_mood) if config.get('enable_user_gaming'): self.register_command('gaming', self.command_gaming, usage='[<game name> [server address]]', - desc=_('Send your current gaming activity to ' - 'your contacts. Nothing means "stop ' - 'broadcasting a gaming activity".'), - shortdesc=_('Send your gaming activity.'), + desc='Send your current gaming activity to ' + 'your contacts. Nothing means "stop ' + 'broadcasting a gaming activity".', + shortdesc='Send your gaming activity.', completion=None) ####################### XMPP Event Handlers ################################## diff --git a/src/core/handlers.py b/src/core/handlers.py index 720a0977..828c39d1 100644 --- a/src/core/handlers.py +++ b/src/core/handlers.py @@ -12,7 +12,6 @@ import ssl import sys import time from hashlib import sha1, sha512 -from gettext import gettext as _ from os import path from slixmpp import InvalidJID @@ -80,8 +79,8 @@ def check_bookmark_storage(self, features): type_ = iq['error']['type'] condition = iq['error']['condition'] if not (type_ == 'cancel' and condition == 'item-not-found'): - self.information(_('Unable to fetch the remote' - ' bookmarks; %s: %s') % (type_, condition), + self.information('Unable to fetch the remote' + ' bookmarks; %s: %s' % (type_, condition), 'Error') return remote_bookmarks = self.bookmarks.remote() @@ -245,7 +244,7 @@ def on_error_message(self, message): tab = self.get_conversation_by_jid(message['from'], create=False) error_msg = self.get_error_message(message, deprecated=True) if not tab: - return self.information(error_msg, _('Error')) + return self.information(error_msg, 'Error') error = '\x19%s}%s\x19o' % (dump_tuple(get_theme().COLOR_CHAR_NACK), error_msg) if not tab.nack_message('\n' + error, message['id'], message['to']): @@ -522,7 +521,7 @@ def on_groupchat_message(self, message): tab = self.get_tab_by_name(room_from, tabs.MucTab) if not tab: - self.information(_("message received for a non-existing room: %s") % (room_from)) + self.information("message received for a non-existing room: %s" % (room_from)) muc.leave_groupchat(self.xmpp, room_from, self.own_nick, msg='') return @@ -763,10 +762,10 @@ def on_subscription_request(self, presence): contact = roster.get_and_set(jid) roster.update_contact_groups(contact) contact.pending_in = True - self.information(_('%s wants to subscribe to your presence, ' - 'use /accept <jid> or /deny <jid> to accept ' - 'or reject the query.') % jid, - 'Roster') + self.information('%s wants to subscribe to your presence, ' + 'use /accept <jid> or /deny <jid> to accept ' + 'or reject the query.' % jid, + 'Roster') self.get_tab_by_number(0).state = 'highlight' roster.modified() if isinstance(self.current_tab(), tabs.RosterInfoTab): @@ -859,7 +858,7 @@ def on_got_offline(self, presence): return jid = presence['from'] if not logger.log_roster_change(jid.bare, 'got offline'): - self.information(_('Unable to write in the log file'), 'Error') + self.information('Unable to write in the log file', 'Error') # If a resource got offline, display the message in the conversation with this # precise resource. if jid.resource: @@ -883,7 +882,7 @@ def on_got_online(self, presence): return roster.modified() if not logger.log_roster_change(jid.bare, 'got online'): - self.information(_('Unable to write in the log file'), 'Error') + self.information('Unable to write in the log file', 'Error') resource = Resource(jid.full, { 'priority': presence.get_priority() or 0, 'status': presence['status'], @@ -920,7 +919,7 @@ def on_failed_connection(self, error): """ We cannot contact the remote server """ - self.information(_("Connection to remote server failed: %s" % (error,)), _('Error')) + self.information("Connection to remote server failed: %s" % (error,), 'Error') def on_disconnected(self, event): """ @@ -931,10 +930,10 @@ def on_disconnected(self, event): roster.modified() for tab in self.get_tabs(tabs.MucTab): tab.disconnect() - msg_typ = _('Error') if not self.legitimate_disconnect else _('Info') - self.information(_("Disconnected from server."), msg_typ) + msg_typ = 'Error' if not self.legitimate_disconnect else 'Info' + self.information("Disconnected from server.", msg_typ) if not self.legitimate_disconnect and config.get('auto_reconnect', True): - self.information(_("Auto-reconnecting."), _('Info')) + self.information("Auto-reconnecting.", 'Info') self.xmpp.connect() def on_stream_error(self, event): @@ -942,29 +941,29 @@ def on_stream_error(self, event): When we receive a stream error """ if event and event['text']: - self.information(_('Stream error: %s') % event['text'], _('Error')) + self.information('Stream error: %s' % event['text'], 'Error') def on_failed_all_auth(self, event): """ Authentication failed """ - self.information(_("Authentication failed (bad credentials?)."), - _('Error')) + self.information("Authentication failed (bad credentials?).", + 'Error') self.legitimate_disconnect = True def on_no_auth(self, event): """ Authentication failed (no mech) """ - self.information(_("Authentication failed, no login method available."), - _('Error')) + self.information("Authentication failed, no login method available.", + 'Error') self.legitimate_disconnect = True def on_connected(self, event): """ Remote host responded, but we are not yet authenticated """ - self.information(_("Connected to server."), 'Info') + self.information("Connected to server.", 'Info') def on_connecting(self, event): """ @@ -979,8 +978,8 @@ def on_session_start(self, event): self.connection_time = time.time() if not self.plugins_autoloaded: # Do not reload plugins on reconnection self.autoload_plugins() - self.information(_("Authentication success."), 'Info') - self.information(_("Your JID is %s") % self.xmpp.boundjid.full, 'Info') + self.information("Authentication success.", 'Info') + self.information("Your JID is %s" % self.xmpp.boundjid.full, 'Info') if not self.xmpp.anon: # request the roster self.xmpp.get_roster() @@ -1075,12 +1074,12 @@ def on_groupchat_subject(self, message): # Do not display the message if the subject did not change or if we # receive an empty topic when joining the room. if nick_from: - tab.add_message(_("\x19%(info_col)s}%(nick)s set the subject to: %(subject)s") % + tab.add_message("\x19%(info_col)s}%(nick)s set the subject to: %(subject)s" % {'info_col': dump_tuple(get_theme().COLOR_INFORMATION_TEXT), 'nick':nick_from, 'subject':subject}, time=None, typ=2) else: - tab.add_message(_("\x19%(info_col)s}The subject is: %(subject)s") % + tab.add_message("\x19%(info_col)s}The subject is: %(subject)s" % {'subject':subject, 'info_col': dump_tuple(get_theme().COLOR_INFORMATION_TEXT)}, time=None, typ=2) @@ -1144,14 +1143,14 @@ def room_error(self, error, room_name): nick_color=get_theme().COLOR_ERROR_MSG, typ=2) code = error['error']['code'] if code == '401': - msg = _('To provide a password in order to join the room, type "/join / password" (replace "password" by the real password)') + msg = 'To provide a password in order to join the room, type "/join / password" (replace "password" by the real password)' tab.add_message(msg, typ=2) if code == '409': if config.get('alternative_nickname') != '': self.command_join('%s/%s'% (tab.name, tab.own_nick+config.get('alternative_nickname'))) else: if not tab.joined: - tab.add_message(_('You can join the room with an other nick, by typing "/join /other_nick"'), typ=2) + tab.add_message('You can join the room with an other nick, by typing "/join /other_nick"', typ=2) self.refresh_window() def outgoing_stanza(self, stanza): @@ -1243,7 +1242,7 @@ def validate_ssl(self, pem): self.information('Setting new certificate: old: %s, new: %s' % (cert, sha2_found_cert), 'Info') log.debug('Setting certificate to %s', sha2_found_cert) if not config.silent_set('certificate', sha2_found_cert): - self.information(_('Unable to write in the config file'), 'Error') + self.information('Unable to write in the config file', 'Error') else: self.information('You refused to validate the certificate. You are now disconnected', 'Info') self.disconnect() @@ -1263,7 +1262,7 @@ def validate_ssl(self, pem): else: log.debug('First time. Setting certificate to %s', sha2_found_cert) if not config.silent_set('certificate', sha2_found_cert): - self.information(_('Unable to write in the config file'), 'Error') + self.information('Unable to write in the config file', 'Error') def _composing_tab_state(tab, state): """ diff --git a/src/core/structs.py b/src/core/structs.py index d97acd9f..4ce0ef43 100644 --- a/src/core/structs.py +++ b/src/core/structs.py @@ -2,39 +2,38 @@ Module defining structures useful to the core class and related methods """ import collections -from gettext import gettext as _ # http://xmpp.org/extensions/xep-0045.html#errorstatus ERROR_AND_STATUS_CODES = { - '401': _('A password is required'), - '403': _('Permission denied'), - '404': _('The room doesn’t exist'), - '405': _('Your are not allowed to create a new room'), - '406': _('A reserved nick must be used'), - '407': _('You are not in the member list'), - '409': _('This nickname is already in use or has been reserved'), - '503': _('The maximum number of users has been reached'), + '401': 'A password is required', + '403': 'Permission denied', + '404': 'The room doesn’t exist', + '405': 'Your are not allowed to create a new room', + '406': 'A reserved nick must be used', + '407': 'You are not in the member list', + '409': 'This nickname is already in use or has been reserved', + '503': 'The maximum number of users has been reached', } # http://xmpp.org/extensions/xep-0086.html DEPRECATED_ERRORS = { - '302': _('Redirect'), - '400': _('Bad request'), - '401': _('Not authorized'), - '402': _('Payment required'), - '403': _('Forbidden'), - '404': _('Not found'), - '405': _('Not allowed'), - '406': _('Not acceptable'), - '407': _('Registration required'), - '408': _('Request timeout'), - '409': _('Conflict'), - '500': _('Internal server error'), - '501': _('Feature not implemented'), - '502': _('Remote server error'), - '503': _('Service unavailable'), - '504': _('Remote server timeout'), - '510': _('Disconnected'), + '302': 'Redirect', + '400': 'Bad request', + '401': 'Not authorized', + '402': 'Payment required', + '403': 'Forbidden', + '404': 'Not found', + '405': 'Not allowed', + '406': 'Not acceptable', + '407': 'Registration required', + '408': 'Request timeout', + '409': 'Conflict', + '500': 'Internal server error', + '501': 'Feature not implemented', + '502': 'Remote server error', + '503': 'Service unavailable', + '504': 'Remote server timeout', + '510': 'Disconnected', } possible_show = {'available':None, diff --git a/src/multiuserchat.py b/src/multiuserchat.py index 92d09a60..80e2c706 100644 --- a/src/multiuserchat.py +++ b/src/multiuserchat.py @@ -11,7 +11,6 @@ Add some facilities that are not available on the XEP_0045 slix plugin """ -from gettext import gettext as _ from xml.etree import cElementTree as ET from common import safeJID @@ -43,10 +42,10 @@ def destroy_room(xmpp, room, reason='', altroom=''): iq.append(query) def callback(iq): if not iq or iq['type'] == 'error': - xmpp.core.information(_('Unable to destroy room %s') % room, - _('Info')) + xmpp.core.information('Unable to destroy room %s' % room, + 'Info') else: - xmpp.core.information(_('Room %s destroyed') % room, _('Info')) + xmpp.core.information('Room %s destroyed' % room, 'Info') iq.send(callback=callback) return True @@ -3,89 +3,87 @@ Collection of mappings for PEP moods/activities extracted directly from the XEP """ -from gettext import gettext as _ - MOODS = { - 'afraid': _('Afraid'), - 'amazed': _('Amazed'), - 'angry': _('Angry'), - 'amorous': _('Amorous'), - 'annoyed': _('Annoyed'), - 'anxious': _('Anxious'), - 'aroused': _('Aroused'), - 'ashamed': _('Ashamed'), - 'bored': _('Bored'), - 'brave': _('Brave'), - 'calm': _('Calm'), - 'cautious': _('Cautious'), - 'cold': _('Cold'), - 'confident': _('Confident'), - 'confused': _('Confused'), - 'contemplative': _('Contemplative'), - 'contented': _('Contented'), - 'cranky': _('Cranky'), - 'crazy': _('Crazy'), - 'creative': _('Creative'), - 'curious': _('Curious'), - 'dejected': _('Dejected'), - 'depressed': _('Depressed'), - 'disappointed': _('Disappointed'), - 'disgusted': _('Disgusted'), - 'dismayed': _('Dismayed'), - 'distracted': _('Distracted'), - 'embarrassed': _('Embarrassed'), - 'envious': _('Envious'), - 'excited': _('Excited'), - 'flirtatious': _('Flirtatious'), - 'frustrated': _('Frustrated'), - 'grumpy': _('Grumpy'), - 'guilty': _('Guilty'), - 'happy': _('Happy'), - 'hopeful': _('Hopeful'), - 'hot': _('Hot'), - 'humbled': _('Humbled'), - 'humiliated': _('Humiliated'), - 'hungry': _('Hungry'), - 'hurt': _('Hurt'), - 'impressed': _('Impressed'), - 'in_awe': _('In awe'), - 'in_love': _('In love'), - 'indignant': _('Indignant'), - 'interested': _('Interested'), - 'intoxicated': _('Intoxicated'), - 'invincible': _('Invincible'), - 'jealous': _('Jealous'), - 'lonely': _('Lonely'), - 'lucky': _('Lucky'), - 'mean': _('Mean'), - 'moody': _('Moody'), - 'nervous': _('Nervous'), - 'neutral': _('Neutral'), - 'offended': _('Offended'), - 'outraged': _('Outraged'), - 'playful': _('Playful'), - 'proud': _('Proud'), - 'relaxed': _('Relaxed'), - 'relieved': _('Relieved'), - 'remorseful': _('Remorseful'), - 'restless': _('Restless'), - 'sad': _('Sad'), - 'sarcastic': _('Sarcastic'), - 'serious': _('Serious'), - 'shocked': _('Shocked'), - 'shy': _('Shy'), - 'sick': _('Sick'), - 'sleepy': _('Sleepy'), - 'spontaneous': _('Spontaneous'), - 'stressed': _('Stressed'), - 'strong': _('Strong'), - 'surprised': _('Surprised'), - 'thankful': _('Thankful'), - 'thirsty': _('Thirsty'), - 'tired': _('Tired'), - 'undefined': _('Undefined'), - 'weak': _('Weak'), - 'worried': _('Worried') + 'afraid': 'Afraid', + 'amazed': 'Amazed', + 'angry': 'Angry', + 'amorous': 'Amorous', + 'annoyed': 'Annoyed', + 'anxious': 'Anxious', + 'aroused': 'Aroused', + 'ashamed': 'Ashamed', + 'bored': 'Bored', + 'brave': 'Brave', + 'calm': 'Calm', + 'cautious': 'Cautious', + 'cold': 'Cold', + 'confident': 'Confident', + 'confused': 'Confused', + 'contemplative': 'Contemplative', + 'contented': 'Contented', + 'cranky': 'Cranky', + 'crazy': 'Crazy', + 'creative': 'Creative', + 'curious': 'Curious', + 'dejected': 'Dejected', + 'depressed': 'Depressed', + 'disappointed': 'Disappointed', + 'disgusted': 'Disgusted', + 'dismayed': 'Dismayed', + 'distracted': 'Distracted', + 'embarrassed': 'Embarrassed', + 'envious': 'Envious', + 'excited': 'Excited', + 'flirtatious': 'Flirtatious', + 'frustrated': 'Frustrated', + 'grumpy': 'Grumpy', + 'guilty': 'Guilty', + 'happy': 'Happy', + 'hopeful': 'Hopeful', + 'hot': 'Hot', + 'humbled': 'Humbled', + 'humiliated': 'Humiliated', + 'hungry': 'Hungry', + 'hurt': 'Hurt', + 'impressed': 'Impressed', + 'in_awe': 'In awe', + 'in_love': 'In love', + 'indignant': 'Indignant', + 'interested': 'Interested', + 'intoxicated': 'Intoxicated', + 'invincible': 'Invincible', + 'jealous': 'Jealous', + 'lonely': 'Lonely', + 'lucky': 'Lucky', + 'mean': 'Mean', + 'moody': 'Moody', + 'nervous': 'Nervous', + 'neutral': 'Neutral', + 'offended': 'Offended', + 'outraged': 'Outraged', + 'playful': 'Playful', + 'proud': 'Proud', + 'relaxed': 'Relaxed', + 'relieved': 'Relieved', + 'remorseful': 'Remorseful', + 'restless': 'Restless', + 'sad': 'Sad', + 'sarcastic': 'Sarcastic', + 'serious': 'Serious', + 'shocked': 'Shocked', + 'shy': 'Shy', + 'sick': 'Sick', + 'sleepy': 'Sleepy', + 'spontaneous': 'Spontaneous', + 'stressed': 'Stressed', + 'strong': 'Strong', + 'surprised': 'Surprised', + 'thankful': 'Thankful', + 'thirsty': 'Thirsty', + 'tired': 'Tired', + 'undefined': 'Undefined', + 'weak': 'Weak', + 'worried': 'Worried' } @@ -93,131 +91,131 @@ MOODS = { ACTIVITIES = { 'doing_chores': { - 'category': _('Doing_chores'), - - 'buying_groceries': _('Buying groceries'), - 'cleaning': _('Cleaning'), - 'cooking': _('Cooking'), - 'doing_maintenance': _('Doing maintenance'), - 'doing_the_dishes': _('Doing the dishes'), - 'doing_the_laundry': _('Doing the laundry'), - 'gardening': _('Gardening'), - 'running_an_errand': _('Running an errand'), - 'walking_the_dog': _('Walking the dog'), - 'other': _('Other'), + 'category': 'Doing_chores', + + 'buying_groceries': 'Buying groceries', + 'cleaning': 'Cleaning', + 'cooking': 'Cooking', + 'doing_maintenance': 'Doing maintenance', + 'doing_the_dishes': 'Doing the dishes', + 'doing_the_laundry': 'Doing the laundry', + 'gardening': 'Gardening', + 'running_an_errand': 'Running an errand', + 'walking_the_dog': 'Walking the dog', + 'other': 'Other', }, 'drinking': { - 'category': _('Drinking'), + 'category': 'Drinking', - 'having_a_beer': _('Having a beer'), - 'having_coffee': _('Having coffee'), - 'having_tea': _('Having tea'), - 'other': _('Other'), + 'having_a_beer': 'Having a beer', + 'having_coffee': 'Having coffee', + 'having_tea': 'Having tea', + 'other': 'Other', }, 'eating': { - 'category':_('Eating'), + 'category':'Eating', - 'having_breakfast': _('Having breakfast'), - 'having_a_snack': _('Having a snack'), - 'having_dinner': _('Having dinner'), - 'having_lunch': _('Having lunch'), - 'other': _('Other'), + 'having_breakfast': 'Having breakfast', + 'having_a_snack': 'Having a snack', + 'having_dinner': 'Having dinner', + 'having_lunch': 'Having lunch', + 'other': 'Other', }, 'exercising': { - 'category': _('Exercising'), - - 'cycling': _('Cycling'), - 'dancing': _('Dancing'), - 'hiking': _('Hiking'), - 'jogging': _('Jogging'), - 'playing_sports': _('Playing sports'), - 'running': _('Running'), - 'skiing': _('Skiing'), - 'swimming': _('Swimming'), - 'working_out': _('Working out'), - 'other': _('Other'), + 'category': 'Exercising', + + 'cycling': 'Cycling', + 'dancing': 'Dancing', + 'hiking': 'Hiking', + 'jogging': 'Jogging', + 'playing_sports': 'Playing sports', + 'running': 'Running', + 'skiing': 'Skiing', + 'swimming': 'Swimming', + 'working_out': 'Working out', + 'other': 'Other', }, 'grooming': { - 'category': _('Grooming'), - - 'at_the_spa': _('At the spa'), - 'brushing_teeth': _('Brushing teeth'), - 'getting_a_haircut': _('Getting a haircut'), - 'shaving': _('Shaving'), - 'taking_a_bath': _('Taking a bath'), - 'taking_a_shower': _('Taking a shower'), - 'other': _('Other'), + 'category': 'Grooming', + + 'at_the_spa': 'At the spa', + 'brushing_teeth': 'Brushing teeth', + 'getting_a_haircut': 'Getting a haircut', + 'shaving': 'Shaving', + 'taking_a_bath': 'Taking a bath', + 'taking_a_shower': 'Taking a shower', + 'other': 'Other', }, 'having_appointment': { - 'category': _('Having appointment'), + 'category': 'Having appointment', - 'other': _('Other'), + 'other': 'Other', }, 'inactive': { - 'category': _('Inactive'), - - 'day_off': _('Day_off'), - 'hanging_out': _('Hanging out'), - 'hiding': _('Hiding'), - 'on_vacation': _('On vacation'), - 'praying': _('Praying'), - 'scheduled_holiday': _('Scheduled holiday'), - 'sleeping': _('Sleeping'), - 'thinking': _('Thinking'), - 'other': _('Other'), + 'category': 'Inactive', + + 'day_off': 'Day_off', + 'hanging_out': 'Hanging out', + 'hiding': 'Hiding', + 'on_vacation': 'On vacation', + 'praying': 'Praying', + 'scheduled_holiday': 'Scheduled holiday', + 'sleeping': 'Sleeping', + 'thinking': 'Thinking', + 'other': 'Other', }, 'relaxing': { - 'category': _('Relaxing'), - - 'fishing': _('Fishing'), - 'gaming': _('Gaming'), - 'going_out': _('Going out'), - 'partying': _('Partying'), - 'reading': _('Reading'), - 'rehearsing': _('Rehearsing'), - 'shopping': _('Shopping'), - 'smoking': _('Smoking'), - 'socializing': _('Socializing'), - 'sunbathing': _('Sunbathing'), - 'watching_a_movie': _('Watching a movie'), - 'watching_tv': _('Watching tv'), - 'other': _('Other'), + 'category': 'Relaxing', + + 'fishing': 'Fishing', + 'gaming': 'Gaming', + 'going_out': 'Going out', + 'partying': 'Partying', + 'reading': 'Reading', + 'rehearsing': 'Rehearsing', + 'shopping': 'Shopping', + 'smoking': 'Smoking', + 'socializing': 'Socializing', + 'sunbathing': 'Sunbathing', + 'watching_a_movie': 'Watching a movie', + 'watching_tv': 'Watching tv', + 'other': 'Other', }, 'talking': { - 'category': _('Talking'), + 'category': 'Talking', - 'in_real_life': _('In real life'), - 'on_the_phone': _('On the phone'), - 'on_video_phone': _('On video phone'), - 'other': _('Other'), + 'in_real_life': 'In real life', + 'on_the_phone': 'On the phone', + 'on_video_phone': 'On video phone', + 'other': 'Other', }, 'traveling': { - 'category': _('Traveling'), - - 'commuting': _('Commuting'), - 'driving': _('Driving'), - 'in_a_car': _('In a car'), - 'on_a_bus': _('On a bus'), - 'on_a_plane': _('On a plane'), - 'on_a_train': _('On a train'), - 'on_a_trip': _('On a trip'), - 'walking': _('Walking'), - 'cycling': _('Cycling'), - 'other': _('Other'), + 'category': 'Traveling', + + 'commuting': 'Commuting', + 'driving': 'Driving', + 'in_a_car': 'In a car', + 'on_a_bus': 'On a bus', + 'on_a_plane': 'On a plane', + 'on_a_train': 'On a train', + 'on_a_trip': 'On a trip', + 'walking': 'Walking', + 'cycling': 'Cycling', + 'other': 'Other', }, 'undefined': { - 'category': _('Undefined'), + 'category': 'Undefined', - 'other': _('Other'), + 'other': 'Other', }, 'working': { - 'category': _('Working'), + 'category': 'Working', - 'coding': _('Coding'), - 'in_a_meeting': _('In a meeting'), - 'writing': _('Writing'), - 'studying': _('Studying'), - 'other': _('Other'), + 'coding': 'Coding', + 'in_a_meeting': 'In a meeting', + 'writing': 'Writing', + 'studying': 'Studying', + 'other': 'Other', } } diff --git a/src/plugin_manager.py b/src/plugin_manager.py index 7e3659e4..549753a9 100644 --- a/src/plugin_manager.py +++ b/src/plugin_manager.py @@ -8,7 +8,6 @@ plugin env. import os from os import path import logging -from gettext import gettext as _ import core import tabs @@ -93,8 +92,8 @@ class PluginManager(object): except Exception as e: log.error('Error while loading the plugin %s', name, exc_info=True) if notify: - self.core.information(_('Unable to load the plugin %s: %s') % - (name, e), + self.core.information('Unable to load the plugin %s: %s' % + (name, e), 'Error') self.unload(name, notify=False) else: @@ -131,8 +130,8 @@ class PluginManager(object): self.core.information('Plugin %s unloaded' % name, 'Info') except Exception as e: log.debug("Could not unload plugin %s", name, exc_info=True) - self.core.information(_("Could not unload plugin %s: %s") % - (name, e), + self.core.information("Could not unload plugin %s: %s" % + (name, e), 'Error') def add_command(self, module_name, name, handler, help, @@ -141,7 +140,7 @@ class PluginManager(object): Add a global command. """ if name in self.core.commands: - raise Exception(_("Command '%s' already exists") % (name,)) + raise Exception("Command '%s' already exists" % (name,)) commands = self.commands[module_name] commands[name] = core.Command(handler, help, completion, short, usage) @@ -228,7 +227,7 @@ class PluginManager(object): already exists. """ if key in self.core.key_func: - raise Exception(_("Key '%s' already exists") % (key,)) + raise Exception("Key '%s' already exists" % (key,)) keys = self.keys[module_name] keys[key] = handler self.core.key_func[key] = handler @@ -279,7 +278,7 @@ class PluginManager(object): except: pass except OSError as e: - self.core.information(_('Completion failed: %s' % e), 'Error') + self.core.information('Completion failed: %s' % e, 'Error') return plugins_files = [name[:-3] for name in names if name.endswith('.py') and name != '__init__.py' and not name.startswith('.')] diff --git a/src/tabs/adhoc_commands_list.py b/src/tabs/adhoc_commands_list.py index 7f5abf6a..10ebf22b 100644 --- a/src/tabs/adhoc_commands_list.py +++ b/src/tabs/adhoc_commands_list.py @@ -4,8 +4,6 @@ select one of them and start executing it, or just close the tab and do nothing. """ -from gettext import gettext as _ - import logging log = logging.getLogger(__name__) @@ -20,7 +18,7 @@ class AdhocCommandsListTab(ListTab): def __init__(self, jid): ListTab.__init__(self, jid.full, "“Enter”: execute selected command.", - _('Ad-hoc commands of JID %s (Loading)') % jid, + 'Ad-hoc commands of JID %s (Loading)' % jid, (('Node', 0), ('Description', 1))) self.key_func['^M'] = self.execute_selected_command @@ -50,7 +48,7 @@ class AdhocCommandsListTab(ListTab): yield item items = [(item['node'], item['name'] or '', item['jid']) for item in get_items()] self.listview.set_lines(items) - self.info_header.message = _('Ad-hoc commands of JID %s') % self.name + self.info_header.message = 'Ad-hoc commands of JID %s' % self.name if self.core.current_tab() is self: self.refresh() else: diff --git a/src/tabs/basetabs.py b/src/tabs/basetabs.py index 1938cb65..30ddf239 100644 --- a/src/tabs/basetabs.py +++ b/src/tabs/basetabs.py @@ -13,8 +13,6 @@ This module also defines ChatTabs, the parent class for all tabs revolving around chats. """ -from gettext import gettext as _ - import logging log = logging.getLogger(__name__) @@ -281,9 +279,9 @@ class Tab(object): if self.missing_command_callback is not None: error_handled = self.missing_command_callback(low) if not error_handled: - self.core.information(_("Unknown command (%s)") % - (command), - _('Error')) + self.core.information("Unknown command (%s)" % + (command), + 'Error') if command in ('correct', 'say'): # hack arg = xhtml.convert_simple_to_full_colors(arg) else: @@ -455,16 +453,16 @@ class ChatTab(Tab): self.key_func['M-/'] = self.last_words_completion self.key_func['^M'] = self.on_enter self.register_command('say', self.command_say, - usage=_('<message>'), - shortdesc=_('Send the message.')) + usage='<message>', + shortdesc='Send the message.') self.register_command('xhtml', self.command_xhtml, - usage=_('<custom xhtml>'), - shortdesc=_('Send custom XHTML.')) + usage='<custom xhtml>', + shortdesc='Send custom XHTML.') self.register_command('clear', self.command_clear, - shortdesc=_('Clear the current buffer.')) + shortdesc='Clear the current buffer.') self.register_command('correct', self.command_correct, - desc=_('Fix the last message with whatever you want.'), - shortdesc=_('Correct the last message.'), + desc='Fix the last message with whatever you want.', + shortdesc='Correct the last message.', completion=self.completion_correct) self.chat_state = None self.update_commands() @@ -492,7 +490,7 @@ class ChatTab(Tab): """ name = safeJID(self.name).bare if not logger.log_message(name, nickname, txt, date=time, typ=typ): - self.core.information(_('Unable to write in the log file'), 'Error') + self.core.information('Unable to write in the log file', 'Error') def add_message(self, txt, time=None, nickname=None, forced_user=None, nick_color=None, identifier=None, jid=None, history=None, @@ -647,7 +645,7 @@ class ChatTab(Tab): self.core.command_help('correct') return if not self.last_sent_message: - self.core.information(_('There is no message to correct.')) + self.core.information('There is no message to correct.') return self.command_say(line, correct=True) @@ -729,9 +727,9 @@ class OneToOneTab(ChatTab): nope = get_theme().CHAR_EMPTY support = ok if value else nope if value: - msg = _('\x19%s}Contact supports chat states [%s].') + msg = '\x19%s}Contact supports chat states [%s].' else: - msg = _('\x19%s}Contact does not support chat states [%s].') + msg = '\x19%s}Contact does not support chat states [%s].' color = dump_tuple(get_theme().COLOR_INFORMATION_TEXT) msg = msg % (color, support) self.add_message(msg, typ=0) @@ -798,11 +796,11 @@ class OneToOneTab(ChatTab): return False if command_name == 'correct': - feature = _('message correction') + feature = 'message correction' elif command_name == 'attention': - feature = _('attention requests') - msg = _('%s does not support %s, therefore the /%s ' - 'command is currently disabled in this tab.') + feature = 'attention requests' + msg = ('%s does not support %s, therefore the /%s ' + 'command is currently disabled in this tab.') msg = msg % (self.name, feature, command_name) self.core.information(msg, 'Info') return True @@ -812,11 +810,11 @@ class OneToOneTab(ChatTab): if 'urn:xmpp:attention:0' in features: self.remote_supports_attention = True self.register_command('attention', self.command_attention, - usage=_('[message]'), - shortdesc=_('Request the attention.'), - desc=_('Attention: Request the attention of ' - 'the contact. Can also send a message' - ' along with the attention.')) + usage='[message]', + shortdesc='Request the attention.', + desc='Attention: Request the attention of ' + 'the contact. Can also send a message' + ' along with the attention.') else: self.remote_supports_attention = False return self.remote_supports_attention @@ -828,8 +826,8 @@ class OneToOneTab(ChatTab): del self.commands['correct'] elif not 'correct' in self.commands: self.register_command('correct', self.command_correct, - desc=_('Fix the last message with whatever you want.'), - shortdesc=_('Correct the last message.'), + desc='Fix the last message with whatever you want.', + shortdesc='Correct the last message.', completion=self.completion_correct) return 'correct' in self.commands @@ -866,8 +864,8 @@ class OneToOneTab(ChatTab): attention = ok if attention else nope receipts = ok if receipts else nope - msg = _('\x19%s}Contact supports: correction [%s], ' - 'attention [%s], receipts [%s].') + msg = ('\x19%s}Contact supports: correction [%s], ' + 'attention [%s], receipts [%s].') color = dump_tuple(get_theme().COLOR_INFORMATION_TEXT) msg = msg % (color, correct, attention, receipts) self.add_message(msg, typ=0) diff --git a/src/tabs/bookmarkstab.py b/src/tabs/bookmarkstab.py index 68cbbf40..7f5069ea 100644 --- a/src/tabs/bookmarkstab.py +++ b/src/tabs/bookmarkstab.py @@ -10,8 +10,6 @@ from bookmarks import Bookmark, BookmarkList, stanza_storage from tabs import Tab from common import safeJID -from gettext import gettext as _ - class BookmarksTab(Tab): """ @@ -32,10 +30,10 @@ class BookmarksTab(Tab): self.bookmarks_win = windows.BookmarksWin(self.bookmarks, self.height-4, self.width, 1, 0) - self.help_win = windows.HelpText(_('Ctrl+Y: save, Ctrl+G: cancel, ' - '↑↓: change lines, tab: change ' - 'column, M-a: add bookmark, C-k' - ': delete bookmark')) + self.help_win = windows.HelpText('Ctrl+Y: save, Ctrl+G: cancel, ' + '↑↓: change lines, tab: change ' + 'column, M-a: add bookmark, C-k' + ': delete bookmark') self.info_header = windows.BookmarksInfoWin() self.key_func['KEY_UP'] = self.bookmarks_win.go_to_previous_line_input self.key_func['KEY_DOWN'] = self.bookmarks_win.go_to_next_line_input @@ -66,14 +64,14 @@ class BookmarksTab(Tab): def on_save(self): self.bookmarks_win.save() if find_duplicates(self.new_bookmarks): - self.core.information(_('Duplicate bookmarks in list (saving aborted)'), 'Error') + self.core.information('Duplicate bookmarks in list (saving aborted)', 'Error') return for bm in self.new_bookmarks: if safeJID(bm.jid): if not self.bookmarks[bm.jid]: self.bookmarks.append(bm) else: - self.core.information(_('Invalid JID for bookmark: %s/%s') % (bm.jid, bm.nick), 'Error') + self.core.information('Invalid JID for bookmark: %s/%s' % (bm.jid, bm.nick), 'Error') return for bm in self.removed_bookmarks: @@ -82,9 +80,9 @@ class BookmarksTab(Tab): def send_cb(success): if success: - self.core.information(_('Bookmarks saved.'), 'Info') + self.core.information('Bookmarks saved.', 'Info') else: - self.core.information(_('Remote bookmarks not saved.'), 'Error') + self.core.information('Remote bookmarks not saved.', 'Error') log.debug('alerte %s', str(stanza_storage(self.bookmarks.bookmarks))) self.bookmarks.save(self.core.xmpp, callback=send_cb) self.core.close_tab() diff --git a/src/tabs/conversationtab.py b/src/tabs/conversationtab.py index f9c0f07c..1d8c60a4 100644 --- a/src/tabs/conversationtab.py +++ b/src/tabs/conversationtab.py @@ -11,8 +11,6 @@ There are two different instances of a ConversationTab: the time. """ -from gettext import gettext as _ - import logging log = logging.getLogger(__name__) @@ -54,18 +52,18 @@ class ConversationTab(OneToOneTab): self.key_func['^I'] = self.completion # commands self.register_command('unquery', self.command_unquery, - shortdesc=_('Close the tab.')) + shortdesc='Close the tab.') self.register_command('close', self.command_unquery, - shortdesc=_('Close the tab.')) + shortdesc='Close the tab.') self.register_command('version', self.command_version, - desc=_('Get the software version of the current interlocutor (usually its XMPP client and Operating System).'), - shortdesc=_('Get the software version of the user.')) + desc='Get the software version of the current interlocutor (usually its XMPP client and Operating System).', + shortdesc='Get the software version of the user.') self.register_command('info', self.command_info, - shortdesc=_('Get the status of the contact.')) + shortdesc='Get the status of the contact.') self.register_command('last_activity', self.command_last_activity, - usage=_('[jid]'), - desc=_('Get the last activity of the given or the current contact.'), - shortdesc=_('Get the activity.'), + usage='[jid]', + desc='Get the last activity of the given or the current contact.', + shortdesc='Get the activity.', completion=self.core.completion_last_activity) self.resize() self.update_commands() @@ -199,7 +197,7 @@ class ConversationTab(OneToOneTab): else: resource = None if resource: - status = (_('Status: %s') % resource.status) if resource.status else '' + status = ('Status: %s' % resource.status) if resource.status else '' self._text_buffer.add_message("\x19%(info_col)s}Show: %(show)s, %(status)s\x19o" % { 'show': resource.show or 'available', 'status': status, 'info_col': dump_tuple(get_theme().COLOR_INFORMATION_TEXT)}) return True @@ -220,9 +218,9 @@ class ConversationTab(OneToOneTab): if not res: return self.core.information('Could not get the software version from %s' % (jid,), 'Warning') version = '%s is running %s version %s on %s' % (jid, - res.get('name') or _('an unknown software'), - res.get('version') or _('unknown'), - res.get('os') or _('an unknown platform')) + res.get('name') or 'an unknown software', + res.get('version') or 'unknown', + res.get('os') or 'an unknown platform') self.core.information(version, 'Info') if args: return self.core.command_version(args[0]) @@ -380,7 +378,7 @@ class DynamicConversationTab(ConversationTab): self.info_header = windows.DynamicConversationInfoWin() ConversationTab.__init__(self, jid) self.register_command('unlock', self.unlock_command, - shortdesc=_('Unlock the conversation from a particular resource.')) + shortdesc='Unlock the conversation from a particular resource.') def lock(self, resource): """ @@ -392,8 +390,8 @@ class DynamicConversationTab(ConversationTab): info = '\x19%s}' % dump_tuple(get_theme().COLOR_INFORMATION_TEXT) jid_c = '\x19%s}' % dump_tuple(get_theme().COLOR_MUC_JID) - message = _('%(info)sConversation locked to ' - '%(jid_c)s%(jid)s/%(resource)s%(info)s.') % { + message = ('%(info)sConversation locked to ' + '%(jid_c)s%(jid)s/%(resource)s%(info)s.') % { 'info': info, 'jid_c': jid_c, 'jid': self.name, @@ -417,14 +415,14 @@ class DynamicConversationTab(ConversationTab): jid_c = '\x19%s}' % dump_tuple(get_theme().COLOR_MUC_JID) if from_: - message = _('%(info)sConversation unlocked (received activity' - ' from %(jid_c)s%(jid)s%(info)s).') % { + message = ('%(info)sConversation unlocked (received activity' + ' from %(jid_c)s%(jid)s%(info)s).') % { 'info': info, 'jid_c': jid_c, 'jid': from_} self.add_message(message, typ=0) else: - message = _('%sConversation unlocked.') % info + message = '%sConversation unlocked.' % info self.add_message(message, typ=0) def get_dest_jid(self): diff --git a/src/tabs/listtab.py b/src/tabs/listtab.py index c5aab5eb..7021c8e3 100644 --- a/src/tabs/listtab.py +++ b/src/tabs/listtab.py @@ -4,8 +4,6 @@ sortable list. It should be inherited, to actually provide methods that insert items in the list, and that lets the user interact with them. """ -from gettext import gettext as _ - import logging log = logging.getLogger(__name__) @@ -52,7 +50,7 @@ class ListTab(Tab): self.key_func['KEY_RIGHT'] = self.list_header.sel_column_right self.key_func[' '] = self.sort_by self.register_command('close', self.close, - shortdesc=_('Close this tab.')) + shortdesc='Close this tab.') self.resize() self.update_keys() self.update_commands() @@ -121,7 +119,7 @@ class ListTab(Tab): """ If there's an error (retrieving the values etc) """ - self._error_message = _('Error: %(code)s - %(msg)s: %(body)s') % {'msg':msg, 'body':body, 'code':code} + self._error_message = 'Error: %(code)s - %(msg)s: %(body)s' % {'msg':msg, 'body':body, 'code':code} self.info_header.message = self._error_message self.info_header.refresh() curses.doupdate() diff --git a/src/tabs/muclisttab.py b/src/tabs/muclisttab.py index 53586fcd..c26fb268 100644 --- a/src/tabs/muclisttab.py +++ b/src/tabs/muclisttab.py @@ -4,8 +4,6 @@ A MucListTab is a tab listing the rooms on a conference server. It has no functionnality except scrolling the list, and allowing the user to join the rooms. """ -from gettext import gettext as _ - import logging log = logging.getLogger(__name__) @@ -24,7 +22,7 @@ class MucListTab(ListTab): def __init__(self, server): ListTab.__init__(self, server.full, "“j”: join room.", - _('Chatroom list on server %s (Loading)') % server, + 'Chatroom list on server %s (Loading)' % server, (('node-part', 0), ('name', 2), ('users', 3))) self.key_func['j'] = self.join_selected self.key_func['J'] = self.join_selected_no_focus @@ -56,7 +54,7 @@ class MucListTab(ListTab): item[0], item[2] or '', '') for item in get_items()] self.listview.set_lines(items) - self.info_header.message = _('Chatroom list on server %s') % self.name + self.info_header.message = 'Chatroom list on server %s' % self.name if self.core.current_tab() is self: self.refresh() else: diff --git a/src/tabs/muctab.py b/src/tabs/muctab.py index c84c92cc..1d82ec3a 100644 --- a/src/tabs/muctab.py +++ b/src/tabs/muctab.py @@ -7,8 +7,6 @@ It keeps track of many things such as part/joins, maintains an user list, and updates private tabs when necessary. """ -from gettext import gettext as _ - import logging log = logging.getLogger(__name__) @@ -37,11 +35,11 @@ from user import User SHOW_NAME = { - 'dnd': _('busy'), - 'away': _('away'), - 'xa': _('not available'), - 'chat': _('chatty'), - '': _('available') + 'dnd': 'busy', + 'away': 'away', + 'xa': 'not available', + 'chat': 'chatty', + '': 'available' } NS_MUC_USER = 'http://jabber.org/protocol/muc#user' @@ -87,112 +85,112 @@ class MucTab(ChatTab): self.key_func['M-p'] = self.go_to_prev_hl # commands self.register_command('ignore', self.command_ignore, - usage=_('<nickname>'), - desc=_('Ignore a specified nickname.'), - shortdesc=_('Ignore someone'), + usage='<nickname>', + desc='Ignore a specified nickname.', + shortdesc='Ignore someone', completion=self.completion_ignore) self.register_command('unignore', self.command_unignore, - usage=_('<nickname>'), - desc=_('Remove the specified nickname from the ignore list.'), - shortdesc=_('Unignore someone.'), + usage='<nickname>', + desc='Remove the specified nickname from the ignore list.', + shortdesc='Unignore someone.', completion=self.completion_unignore) self.register_command('kick', self.command_kick, - usage=_('<nick> [reason]'), - desc=_('Kick the user with the specified nickname.' - ' You also can give an optional reason.'), - shortdesc=_('Kick someone.'), + usage='<nick> [reason]', + desc='Kick the user with the specified nickname.' + ' You also can give an optional reason.', + shortdesc='Kick someone.', completion=self.completion_quoted) self.register_command('ban', self.command_ban, - usage=_('<nick> [reason]'), - desc=_('Ban the user with the specified nickname.' - ' You also can give an optional reason.'), + usage='<nick> [reason]', + desc='Ban the user with the specified nickname.' + ' You also can give an optional reason.', shortdesc='Ban someone', completion=self.completion_quoted) self.register_command('role', self.command_role, - usage=_('<nick> <role> [reason]'), - desc=_('Set the role of an user. Roles can be:' - ' none, visitor, participant, moderator.' - ' You also can give an optional reason.'), - shortdesc=_('Set the role of an user.'), + usage='<nick> <role> [reason]', + desc='Set the role of an user. Roles can be:' + ' none, visitor, participant, moderator.' + ' You also can give an optional reason.', + shortdesc='Set the role of an user.', completion=self.completion_role) self.register_command('affiliation', self.command_affiliation, - usage=_('<nick or jid> <affiliation>'), - desc=_('Set the affiliation of an user. Affiliations can be:' - ' outcast, none, member, admin, owner.'), - shortdesc=_('Set the affiliation of an user.'), + usage='<nick or jid> <affiliation>', + desc='Set the affiliation of an user. Affiliations can be:' + ' outcast, none, member, admin, owner.', + shortdesc='Set the affiliation of an user.', completion=self.completion_affiliation) self.register_command('topic', self.command_topic, - usage=_('<subject>'), - desc=_('Change the subject of the room.'), - shortdesc=_('Change the subject.'), + usage='<subject>', + desc='Change the subject of the room.', + shortdesc='Change the subject.', completion=self.completion_topic) self.register_command('query', self.command_query, - usage=_('<nick> [message]'), - desc=_('Open a private conversation with <nick>. This nick' - ' has to be present in the room you\'re currently in.' - ' If you specified a message after the nickname, it ' - 'will immediately be sent to this user.'), - shortdesc=_('Query an user.'), + usage='<nick> [message]', + desc='Open a private conversation with <nick>. This nick' + ' has to be present in the room you\'re currently in.' + ' If you specified a message after the nickname, it ' + 'will immediately be sent to this user.', + shortdesc='Query an user.', completion=self.completion_quoted) self.register_command('part', self.command_part, - usage=_('[message]'), - desc=_('Disconnect from a room. You can' - ' specify an optional message.'), - shortdesc=_('Leave the room.')) + usage='[message]', + desc='Disconnect from a room. You can' + ' specify an optional message.', + shortdesc='Leave the room.') self.register_command('close', self.command_close, - usage=_('[message]'), - desc=_('Disconnect from a room and close the tab.' - ' You can specify an optional message if ' - 'you are still connected.'), - shortdesc=_('Close the tab.')) + usage='[message]', + desc='Disconnect from a room and close the tab.' + ' You can specify an optional message if ' + 'you are still connected.', + shortdesc='Close the tab.') self.register_command('nick', self.command_nick, - usage=_('<nickname>'), - desc=_('Change your nickname in the current room.'), - shortdesc=_('Change your nickname.'), + usage='<nickname>', + desc='Change your nickname in the current room.', + shortdesc='Change your nickname.', completion=self.completion_nick) self.register_command('recolor', self.command_recolor, - usage=_('[random]'), - desc=_('Re-assign a color to all participants of the' - ' current room, based on the last time they talked.' - ' Use this if the participants currently talking ' - 'have too many identical colors. Use /recolor random' - ' for a non-deterministic result.'), - shortdesc=_('Change the nicks colors.'), + usage='[random]', + desc='Re-assign a color to all participants of the' + ' current room, based on the last time they talked.' + ' Use this if the participants currently talking ' + 'have too many identical colors. Use /recolor random' + ' for a non-deterministic result.', + shortdesc='Change the nicks colors.', completion=self.completion_recolor) self.register_command('color', self.command_color, - usage=_('<nick> <color>'), - desc=_('Fix a color for a nick. Use "unset" instead of a color' - ' to remove the attribution'), - shortdesc=_('Fix a color for a nick.'), + usage='<nick> <color>', + desc='Fix a color for a nick. Use "unset" instead of a color' + ' to remove the attribution', + shortdesc='Fix a color for a nick.', completion=self.completion_color) self.register_command('cycle', self.command_cycle, - usage=_('[message]'), - desc=_('Leave the current room and rejoin it immediately.'), - shortdesc=_('Leave and re-join the room.')) + usage='[message]', + desc='Leave the current room and rejoin it immediately.', + shortdesc='Leave and re-join the room.') self.register_command('info', self.command_info, - usage=_('<nickname>'), - desc=_('Display some information about the user ' - 'in the MUC: its/his/her role, affiliation,' - ' status and status message.'), - shortdesc=_('Show an user\'s infos.'), + usage='<nickname>', + desc='Display some information about the user ' + 'in the MUC: its/his/her role, affiliation,' + ' status and status message.', + shortdesc='Show an user\'s infos.', completion=self.completion_info) self.register_command('configure', self.command_configure, - desc=_('Configure the current room, through a form.'), - shortdesc=_('Configure the room.')) + desc='Configure the current room, through a form.', + shortdesc='Configure the room.') self.register_command('version', self.command_version, - usage=_('<jid or nick>'), - desc=_('Get the software version of the given JID' - ' or nick in room (usually its XMPP client' - ' and Operating System).'), - shortdesc=_('Get the software version of a jid.'), + usage='<jid or nick>', + desc='Get the software version of the given JID' + ' or nick in room (usually its XMPP client' + ' and Operating System).', + shortdesc='Get the software version of a jid.', completion=self.completion_version) self.register_command('names', self.command_names, - desc=_('Get the users in the room with their roles.'), - shortdesc=_('List the users.')) + desc='Get the users in the room with their roles.', + shortdesc='List the users.') self.register_command('invite', self.command_invite, - desc=_('Invite a contact to this room'), - usage=_('<jid> [reason]'), - shortdesc=_('Invite a contact to this room'), + desc='Invite a contact to this room', + usage='<jid> [reason]', + shortdesc='Invite a contact to this room', completion=self.completion_invite) if self.core.xmpp.boundjid.server == "gmail.com": #gmail sucks @@ -356,7 +354,7 @@ class MucTab(ChatTab): nick = args[0] user = self.get_user_by_name(nick) if not user: - return self.core.information(_("Unknown user: %s") % nick) + return self.core.information("Unknown user: %s" % nick) theme = get_theme() if user.jid: user_jid = ' (\x19%s}%s\x19o)' % ( @@ -364,8 +362,8 @@ class MucTab(ChatTab): user.jid) else: user_jid = '' - info = _('\x19%s}%s\x19o%s: show: \x19%s}%s\x19o, affiliation:' - ' \x19%s}%s\x19o, role: \x19%s}%s\x19o%s') % ( + info = ('\x19%s}%s\x19o%s: show: \x19%s}%s\x19o, affiliation:' + ' \x19%s}%s\x19o, role: \x19%s}%s\x19o%s') % ( dump_tuple(user.color), nick, user_jid, @@ -387,8 +385,8 @@ class MucTab(ChatTab): def on_form_received(form): if not form: self.core.information( - _('Could not retrieve the configuration form'), - _('Error')) + 'Could not retrieve the configuration form', + 'Error') return self.core.open_new_form(form, self.cancel_config, self.send_config) @@ -433,9 +431,9 @@ class MucTab(ChatTab): continue user.set_deterministic_color() if args[0] == 'random': - self.core.information(_('"random" was provided, but poezio is ' - 'configured to use deterministic colors'), - 'Warning') + self.core.information('"random" was provided, but poezio is ' + 'configured to use deterministic colors', + 'Warning') self.user_win.refresh(self.users) self.input.refresh() return @@ -477,13 +475,13 @@ class MucTab(ChatTab): color = args[1].lower() user = self.get_user_by_name(nick) if not color in xhtml.colors and color not in ('unset', 'random'): - return self.core.information(_("Unknown color: %s") % color, 'Error') + return self.core.information("Unknown color: %s" % color, 'Error') if user and user.nick == self.own_nick: - return self.core.information(_("You cannot change the color of your" - " own nick.", 'Error')) + return self.core.information("You cannot change the color of your" + " own nick.", 'Error') if color == 'unset': if config.remove_and_save(nick, 'muc_colors'): - self.core.information(_('Color for nick %s unset') % (nick)) + self.core.information('Color for nick %s unset' % (nick)) else: if color == 'random': color = random.choice(list(xhtml.colors)) @@ -512,14 +510,14 @@ class MucTab(ChatTab): """ def callback(res): if not res: - return self.core.information(_('Could not get the software ' - 'version from %s') % (jid,), - _('Warning')) - version = _('%s is running %s version %s on %s') % ( + return self.core.information('Could not get the software ' + 'version from %s' % (jid,), + 'Warning') + version = '%s is running %s version %s on %s' % ( jid, - res.get('name') or _('an unknown software'), - res.get('version') or _('unknown'), - res.get('os') or _('an unknown platform')) + res.get('name') or 'an unknown software', + res.get('version') or 'unknown', + res.get('os') or 'an unknown platform') self.core.information(version, 'Info') if args is None: return self.core.command_help('version') @@ -541,8 +539,8 @@ class MucTab(ChatTab): return self.core.command_help('nick') nick = args[0] if not self.joined: - return self.core.information(_('/nick only works in joined rooms'), - _('Info')) + return self.core.information('/nick only works in joined rooms', + 'Info') current_status = self.core.get_status() if not safeJID(self.name + '/' + nick): return self.core.information('Invalid nick', 'Info') @@ -569,24 +567,24 @@ class MucTab(ChatTab): color = 3 if arg: - msg = _('\x19%(color_spec)s}%(spec)s\x19%(info_col)s} ' - 'You (\x19%(color)s}%(nick)s\x19%(info_col)s})' - ' left the chatroom' - ' (\x19o%(reason)s\x19%(info_col)s})') % { - 'info_col': info_col, 'reason': arg, - 'spec': char_quit, 'color': color, - 'color_spec': spec_col, - 'nick': self.own_nick, - } + msg = ('\x19%(color_spec)s}%(spec)s\x19%(info_col)s} ' + 'You (\x19%(color)s}%(nick)s\x19%(info_col)s})' + ' left the chatroom' + ' (\x19o%(reason)s\x19%(info_col)s})') % { + 'info_col': info_col, 'reason': arg, + 'spec': char_quit, 'color': color, + 'color_spec': spec_col, + 'nick': self.own_nick, + } else: - msg = _('\x19%(color_spec)s}%(spec)s\x19%(info_col)s} ' - 'You (\x19%(color)s}%(nick)s\x19%(info_col)s})' - ' left the chatroom') % { - 'info_col': info_col, - 'spec': char_quit, 'color': color, - 'color_spec': spec_col, - 'nick': self.own_nick, - } + msg = ('\x19%(color_spec)s}%(spec)s\x19%(info_col)s} ' + 'You (\x19%(color)s}%(nick)s\x19%(info_col)s})' + ' left the chatroom') % { + 'info_col': info_col, + 'spec': char_quit, 'color': color, + 'color_spec': spec_col, + 'nick': self.own_nick, + } self.add_message(msg, typ=2) self.disconnect() @@ -621,7 +619,7 @@ class MucTab(ChatTab): self.core.current_tab().command_say( xhtml.convert_simple_to_full_colors(msg)) if not r: - self.core.information(_("Cannot find user: %s" % nick), 'Error') + self.core.information("Cannot find user: %s" % nick, 'Error') @command_args_parser.raw def command_topic(self, subject): @@ -630,7 +628,7 @@ class MucTab(ChatTab): """ if not subject: self._text_buffer.add_message( - _("\x19%s}The subject of the room is: %s %s") % + "\x19%s}The subject of the room is: %s %s" % (dump_tuple(get_theme().COLOR_INFORMATION_TEXT), self.topic, '(set by %s)' % self.topic_from if self.topic_from @@ -771,8 +769,8 @@ class MucTab(ChatTab): valid_roles = ('none', 'visitor', 'participant', 'moderator') if not self.joined or role not in valid_roles: - return self.core.information(_('The role must be one of ' + ', '.join(valid_roles)), - _('Error')) + return self.core.information('The role must be one of ' + ', '.join(valid_roles), + 'Error') if not safeJID(self.name + '/' + nick): return self.core.information('Invalid nick', 'Info') @@ -800,8 +798,8 @@ class MucTab(ChatTab): valid_affiliations = ('outcast', 'none', 'member', 'admin', 'owner') if affiliation not in valid_affiliations: - return self.core.information(_('The affiliation must be one of ' + ', '.join(valid_affiliations)), - _('Error')) + return self.core.information('The affiliation must be one of ' + ', '.join(valid_affiliations), + 'Error') if nick in [user.nick for user in self.users]: res = muc.set_user_affiliation(self.core.xmpp, self.name, @@ -812,7 +810,7 @@ class MucTab(ChatTab): affiliation, jid=safeJID(nick), callback=callback) if not res: - self.core.information(_('Could not set affiliation'), _('Error')) + self.core.information('Could not set affiliation', 'Error') @command_args_parser.raw def command_say(self, line, correct=False): @@ -871,12 +869,12 @@ class MucTab(ChatTab): nick = args[0] user = self.get_user_by_name(nick) if not user: - self.core.information(_('%s is not in the room') % nick) + self.core.information('%s is not in the room' % nick) elif user in self.ignores: - self.core.information(_('%s is already ignored') % nick) + self.core.information('%s is already ignored' % nick) else: self.ignores.append(user) - self.core.information(_("%s is now ignored") % nick, 'info') + self.core.information("%s is now ignored" % nick, 'info') @command_args_parser.quoted(1) def command_unignore(self, args): @@ -889,12 +887,12 @@ class MucTab(ChatTab): nick = args[0] user = self.get_user_by_name(nick) if not user: - self.core.information(_('%s is not in the room') % nick) + self.core.information('%s is not in the room' % nick) elif user not in self.ignores: - self.core.information(_('%s is not ignored') % nick) + self.core.information('%s is not ignored' % nick) else: self.ignores.remove(user) - self.core.information(_('%s is now unignored') % nick) + self.core.information('%s is now unignored' % nick) def completion_unignore(self, the_input): if the_input.get_argument_position() == 1: @@ -1118,9 +1116,9 @@ class MucTab(ChatTab): spec_col = dump_tuple(get_theme().COLOR_JOIN_CHAR) self.add_message( - _('\x19%(color_spec)s}%(spec)s\x19%(info_col)s} You ' - '(\x19%(nick_col)s}%(nick)s\x19%(info_col)s}) joined' - ' the chatroom') % + '\x19%(color_spec)s}%(spec)s\x19%(info_col)s} You ' + '(\x19%(nick_col)s}%(nick)s\x19%(info_col)s}) joined' + ' the chatroom' % { 'nick': from_nick, 'spec': get_theme().CHAR_JOIN, @@ -1131,21 +1129,21 @@ class MucTab(ChatTab): typ=2) if '201' in status_codes: self.add_message( - _('\x19%(info_col)s}Info: The room ' - 'has been created') % + '\x19%(info_col)s}Info: The room ' + 'has been created' % {'info_col': info_col}, typ=0) if '170' in status_codes: self.add_message( - _('\x19%(warn_col)s}Warning:\x19%(info_col)s}' - ' This room is publicly logged') % + '\x19%(warn_col)s}Warning:\x19%(info_col)s}' + ' This room is publicly logged' % {'info_col': info_col, 'warn_col': warn_col}, typ=0) if '100' in status_codes: self.add_message( - _('\x19%(warn_col)s}Warning:\x19%(info_col)s}' - ' This room is not anonymous.') % + '\x19%(warn_col)s}Warning:\x19%(info_col)s}' + ' This room is not anonymous.' % {'info_col': info_col, 'warn_col': warn_col}, typ=0) @@ -1205,8 +1203,8 @@ class MucTab(ChatTab): def on_non_member_kicked(self): """We have been kicked because the MUC is members-only""" self.add_message( - _('\x19%(info_col)s}You have been kicked because you ' - 'are not a member and the room is now members-only.') % { + '\x19%(info_col)s}You have been kicked because you ' + 'are not a member and the room is now members-only.' % { 'info_col': dump_tuple(get_theme().COLOR_INFORMATION_TEXT)}, typ=2) self.disconnect() @@ -1214,8 +1212,8 @@ class MucTab(ChatTab): def on_muc_shutdown(self): """We have been kicked because the MUC service is shutting down""" self.add_message( - _('\x19%(info_col)s}You have been kicked because the' - ' MUC service is shutting down.') % { + '\x19%(info_col)s}You have been kicked because the' + ' MUC service is shutting down.' % { 'info_col': dump_tuple(get_theme().COLOR_INFORMATION_TEXT)}, typ=2) self.disconnect() @@ -1240,17 +1238,17 @@ class MucTab(ChatTab): spec_col = dump_tuple(get_theme().COLOR_JOIN_CHAR) char_join = get_theme().CHAR_JOIN if not jid.full: - msg = _('\x19%(color_spec)s}%(spec)s \x19%(color)s}%(nick)s' - '\x19%(info_col)s} joined the chatroom') % { + msg = ('\x19%(color_spec)s}%(spec)s \x19%(color)s}%(nick)s' + '\x19%(info_col)s} joined the chatroom') % { 'nick': from_nick, 'spec': char_join, 'color': color, 'info_col': info_col, 'color_spec': spec_col, } else: - msg = _('\x19%(color_spec)s}%(spec)s \x19%(color)s}%(nick)s ' - '\x19%(info_col)s}(\x19%(jid_color)s}%(jid)s\x19' - '%(info_col)s}) joined the chatroom') % { + msg = ('\x19%(color_spec)s}%(spec)s \x19%(color)s}%(nick)s ' + '\x19%(info_col)s}(\x19%(jid_color)s}%(jid)s\x19' + '%(info_col)s}) joined the chatroom') % { 'spec': char_join, 'nick': from_nick, 'color':color, 'jid':jid.full, 'info_col': info_col, @@ -1281,8 +1279,8 @@ class MucTab(ChatTab): else: color = 3 info_col = dump_tuple(get_theme().COLOR_INFORMATION_TEXT) - self.add_message(_('\x19%(color)s}%(old)s\x19%(info_col)s} is' - ' now known as \x19%(color)s}%(new)s') % { + self.add_message('\x19%(color)s}%(old)s\x19%(info_col)s} is' + ' now known as \x19%(color)s}%(new)s' % { 'old':from_nick, 'new':new_nick, 'color':color, 'info_col': info_col}, typ=2) @@ -1305,13 +1303,13 @@ class MucTab(ChatTab): if from_nick == self.own_nick: # we are banned if by: - kick_msg = _('\x191}%(spec)s \x193}You\x19%(info_col)s}' - ' have been banned by \x194}%(by)s') % { + kick_msg = ('\x191}%(spec)s \x193}You\x19%(info_col)s}' + ' have been banned by \x194}%(by)s') % { 'spec': char_kick, 'by': by, 'info_col': info_col} else: - kick_msg = _('\x191}%(spec)s \x193}You\x19' - '%(info_col)s} have been banned.') % { + kick_msg = ('\x191}%(spec)s \x193}You\x19' + '%(info_col)s} have been banned.') % { 'spec': char_kick, 'info_col': info_col} self.core.disable_private_tabs(self.name, reason=kick_msg) self.disconnect() @@ -1340,20 +1338,20 @@ class MucTab(ChatTab): color = 3 if by: - kick_msg = _('\x191}%(spec)s \x19%(color)s}' - '%(nick)s\x19%(info_col)s} ' - 'has been banned by \x194}%(by)s') % { + kick_msg = ('\x191}%(spec)s \x19%(color)s}' + '%(nick)s\x19%(info_col)s} ' + 'has been banned by \x194}%(by)s') % { 'spec': char_kick, 'nick': from_nick, 'color': color, 'by': by, 'info_col': info_col} else: - kick_msg = _('\x191}%(spec)s \x19%(color)s}%(nick)s' - '\x19%(info_col)s} has been banned') % { + kick_msg = ('\x191}%(spec)s \x19%(color)s}%(nick)s' + '\x19%(info_col)s} has been banned') % { 'spec': char_kick, 'nick': from_nick, 'color': color, 'info_col': info_col} if reason is not None and reason.text: - kick_msg += _('\x19%(info_col)s} Reason: \x196}' - '%(reason)s\x19%(info_col)s}') % { + kick_msg += ('\x19%(info_col)s} Reason: \x196}' + '%(reason)s\x19%(info_col)s}') % { 'reason': reason.text, 'info_col': info_col} self.add_message(kick_msg, typ=2) @@ -1373,14 +1371,14 @@ class MucTab(ChatTab): by = actor_elem.get('nick') or actor_elem.get('jid') if from_nick == self.own_nick: # we are kicked if by: - kick_msg = _('\x191}%(spec)s \x193}You\x19' - '%(info_col)s} have been kicked' - ' by \x193}%(by)s') % { + kick_msg = ('\x191}%(spec)s \x193}You\x19' + '%(info_col)s} have been kicked' + ' by \x193}%(by)s') % { 'spec': char_kick, 'by': by, 'info_col': info_col} else: - kick_msg = _('\x191}%(spec)s \x193}You\x19%(info_col)s}' - ' have been kicked.') % { + kick_msg = ('\x191}%(spec)s \x193}You\x19%(info_col)s}' + ' have been kicked.') % { 'spec': char_kick, 'info_col': info_col} self.core.disable_private_tabs(self.name, reason=kick_msg) @@ -1409,19 +1407,19 @@ class MucTab(ChatTab): else: color = 3 if by: - kick_msg = _('\x191}%(spec)s \x19%(color)s}%(nick)s' - '\x19%(info_col)s} has been kicked by ' - '\x193}%(by)s') % { + kick_msg = ('\x191}%(spec)s \x19%(color)s}%(nick)s' + '\x19%(info_col)s} has been kicked by ' + '\x193}%(by)s') % { 'spec': char_kick, 'nick':from_nick, 'color':color, 'by':by, 'info_col': info_col} else: - kick_msg = _('\x191}%(spec)s \x19%(color)s}%(nick)s' - '\x19%(info_col)s} has been kicked') % { + kick_msg = ('\x191}%(spec)s \x19%(color)s}%(nick)s' + '\x19%(info_col)s} has been kicked') % { 'spec': char_kick, 'nick': from_nick, 'color':color, 'info_col': info_col} if reason is not None and reason.text: - kick_msg += _('\x19%(info_col)s} Reason: \x196}' - '%(reason)s') % { + kick_msg += ('\x19%(info_col)s} Reason: \x196}' + '%(reason)s') % { 'reason': reason.text, 'info_col': info_col} self.add_message(kick_msg, typ=2) @@ -1450,19 +1448,19 @@ class MucTab(ChatTab): spec_col = dump_tuple(get_theme().COLOR_QUIT_CHAR) if not jid.full: - leave_msg = _('\x19%(color_spec)s}%(spec)s \x19%(color)s}' - '%(nick)s\x19%(info_col)s} has left the ' - 'chatroom') % { + leave_msg = ('\x19%(color_spec)s}%(spec)s \x19%(color)s}' + '%(nick)s\x19%(info_col)s} has left the ' + 'chatroom') % { 'nick':from_nick, 'color':color, 'spec':get_theme().CHAR_QUIT, 'info_col': info_col, 'color_spec': spec_col} else: jid_col = dump_tuple(get_theme().COLOR_MUC_JID) - leave_msg = _('\x19%(color_spec)s}%(spec)s \x19%(color)s}' - '%(nick)s\x19%(info_col)s} (\x19%(jid_col)s}' - '%(jid)s\x19%(info_col)s}) has left the ' - 'chatroom') % { + leave_msg = ('\x19%(color_spec)s}%(spec)s \x19%(color)s}' + '%(nick)s\x19%(info_col)s} (\x19%(jid_col)s}' + '%(jid)s\x19%(info_col)s}) has left the ' + 'chatroom') % { 'spec':get_theme().CHAR_QUIT, 'nick':from_nick, 'color':color, 'jid':jid.full, 'info_col': info_col, @@ -1488,29 +1486,29 @@ class MucTab(ChatTab): else: color = 3 if from_nick == self.own_nick: - msg = _('\x19%(color)s}You\x19%(info_col)s} changed: ') % { - 'info_col': dump_tuple(get_theme().COLOR_INFORMATION_TEXT), - 'color': color} + msg = '\x19%(color)s}You\x19%(info_col)s} changed: ' % { + 'info_col': dump_tuple(get_theme().COLOR_INFORMATION_TEXT), + 'color': color} else: - msg = _('\x19%(color)s}%(nick)s\x19%(info_col)s} changed: ') % { - 'nick': from_nick, 'color': color, - 'info_col': dump_tuple(get_theme().COLOR_INFORMATION_TEXT)} + msg = '\x19%(color)s}%(nick)s\x19%(info_col)s} changed: ' % { + 'nick': from_nick, 'color': color, + 'info_col': dump_tuple(get_theme().COLOR_INFORMATION_TEXT)} if affiliation != user.affiliation: - msg += _('affiliation: %s, ') % affiliation + msg += 'affiliation: %s, ' % affiliation display_message = True if role != user.role: - msg += _('role: %s, ') % role + msg += 'role: %s, ' % role display_message = True if show != user.show and show in SHOW_NAME: - msg += _('show: %s, ') % SHOW_NAME[show] + msg += 'show: %s, ' % SHOW_NAME[show] display_message = True if status != user.status: # if the user sets his status to nothing if status: - msg += _('status: %s, ') % status + msg += 'status: %s, ' % status display_message = True elif show in SHOW_NAME and show == user.show: - msg += _('show: %s, ') % SHOW_NAME[show] + msg += 'show: %s, ' % SHOW_NAME[show] display_message = True if not display_message: return @@ -1561,8 +1559,8 @@ class MucTab(ChatTab): """ if time is None and self.joined: # don't log the history messages if not logger.log_message(self.name, nickname, txt, typ=typ): - self.core.information(_('Unable to write in the log file'), - _('Error')) + self.core.information('Unable to write in the log file', + 'Error') def do_highlight(self, txt, time, nickname): """ diff --git a/src/tabs/privatetab.py b/src/tabs/privatetab.py index a79d4961..a715a922 100644 --- a/src/tabs/privatetab.py +++ b/src/tabs/privatetab.py @@ -10,8 +10,6 @@ both participant’s nicks. It also has slightly different features than the ConversationTab (such as tab-completion on nicks from the room). """ -from gettext import gettext as _ - import logging log = logging.getLogger(__name__) @@ -49,15 +47,15 @@ class PrivateTab(OneToOneTab): self.key_func['^I'] = self.completion # commands self.register_command('info', self.command_info, - desc=_('Display some information about the user in the MUC: its/his/her role, affiliation, status and status message.'), - shortdesc=_('Info about the user.')) + desc='Display some information about the user in the MUC: its/his/her role, affiliation, status and status message.', + shortdesc='Info about the user.') self.register_command('unquery', self.command_unquery, - shortdesc=_('Close the tab.')) + shortdesc='Close the tab.') self.register_command('close', self.command_unquery, - shortdesc=_('Close the tab.')) + shortdesc='Close the tab.') self.register_command('version', self.command_version, - desc=_('Get the software version of the current interlocutor (usually its XMPP client and Operating System).'), - shortdesc=_('Get the software version of a jid.')) + desc='Get the software version of the current interlocutor (usually its XMPP client and Operating System).', + shortdesc='Get the software version of a jid.') self.resize() self.parent_muc = self.core.get_tab_by_name(safeJID(name).bare, MucTab) self.on = True @@ -95,7 +93,7 @@ class PrivateTab(OneToOneTab): Log the messages in the archives. """ if not logger.log_message(self.name, nickname, txt, date=time, typ=typ): - self.core.information(_('Unable to write in the log file'), 'Error') + self.core.information('Unable to write in the log file', 'Error') def on_close(self): self.parent_muc.privates.remove(self) @@ -201,9 +199,9 @@ class PrivateTab(OneToOneTab): if not res: return self.core.information('Could not get the software version from %s' % (jid,), 'Warning') version = '%s is running %s version %s on %s' % (jid, - res.get('name') or _('an unknown software'), - res.get('version') or _('unknown'), - res.get('os') or _('an unknown platform')) + res.get('name') or 'an unknown software', + res.get('version') or 'unknown', + res.get('os') or 'an unknown platform') self.core.information(version, 'Info') if args: return self.core.command_version(args[0]) @@ -325,9 +323,9 @@ class PrivateTab(OneToOneTab): """ self.deactivate() if not status_message: - self.add_message(_('\x191}%(spec)s \x193}%(nick)s\x19%(info_col)s} has left the room') % {'nick':from_nick, 'spec':get_theme().CHAR_QUIT, 'info_col': dump_tuple(get_theme().COLOR_INFORMATION_TEXT)}, typ=2) + self.add_message('\x191}%(spec)s \x193}%(nick)s\x19%(info_col)s} has left the room' % {'nick':from_nick, 'spec':get_theme().CHAR_QUIT, 'info_col': dump_tuple(get_theme().COLOR_INFORMATION_TEXT)}, typ=2) else: - self.add_message(_('\x191}%(spec)s \x193}%(nick)s\x19%(info_col)s} has left the room (%(status)s)"') % {'nick':from_nick, 'spec':get_theme().CHAR_QUIT, 'status': status_message, 'info_col': dump_tuple(get_theme().COLOR_INFORMATION_TEXT)}, typ=2) + self.add_message('\x191}%(spec)s \x193}%(nick)s\x19%(info_col)s} has left the room (%(status)s)"' % {'nick':from_nick, 'spec':get_theme().CHAR_QUIT, 'status': status_message, 'info_col': dump_tuple(get_theme().COLOR_INFORMATION_TEXT)}, typ=2) return self.core.current_tab() is self @refresh_wrapper.conditional diff --git a/src/tabs/rostertab.py b/src/tabs/rostertab.py index 349058a3..aaff7de3 100644 --- a/src/tabs/rostertab.py +++ b/src/tabs/rostertab.py @@ -5,8 +5,6 @@ rectangle shows the current contact info. This module also includes functions to match users in the roster. """ -from gettext import gettext as _ - import logging log = logging.getLogger(__name__) @@ -68,80 +66,80 @@ class RosterInfoTab(Tab): self.key_func["S"] = self.start_search_slow self.key_func["n"] = self.change_contact_name self.register_command('deny', self.command_deny, - usage=_('[jid]'), - desc=_('Deny your presence to the provided JID (or the ' - 'selected contact in your roster), who is asking' - 'you to be in his/here roster.'), - shortdesc=_('Deny an user your presence.'), + usage='[jid]', + desc='Deny your presence to the provided JID (or the ' + 'selected contact in your roster), who is asking' + 'you to be in his/here roster.', + shortdesc='Deny an user your presence.', completion=self.completion_deny) self.register_command('accept', self.command_accept, - usage=_('[jid]'), - desc=_('Allow the provided JID (or the selected contact ' - 'in your roster), to see your presence.'), - shortdesc=_('Allow an user your presence.'), + usage='[jid]', + desc='Allow the provided JID (or the selected contact ' + 'in your roster), to see your presence.', + shortdesc='Allow an user your presence.', completion=self.completion_deny) self.register_command('add', self.command_add, - usage=_('<jid>'), - desc=_('Add the specified JID to your roster, ask him to' - ' allow you to see his presence, and allow him to' - ' see your presence.'), - shortdesc=_('Add an user to your roster.')) + usage='<jid>', + desc='Add the specified JID to your roster, ask him to' + ' allow you to see his presence, and allow him to' + ' see your presence.', + shortdesc='Add an user to your roster.') self.register_command('name', self.command_name, - usage=_('<jid> [name]'), - shortdesc=_('Set the given JID\'s name.'), + usage='<jid> [name]', + shortdesc='Set the given JID\'s name.', completion=self.completion_name) self.register_command('groupadd', self.command_groupadd, - usage=_('<jid> <group>'), - desc=_('Add the given JID to the given group.'), - shortdesc=_('Add an user to a group'), + usage='<jid> <group>', + desc='Add the given JID to the given group.', + shortdesc='Add an user to a group', completion=self.completion_groupadd) self.register_command('groupmove', self.command_groupmove, - usage=_('<jid> <old group> <new group>'), - desc=_('Move the given JID from the old group to the new group.'), - shortdesc=_('Move an user to another group.'), + usage='<jid> <old group> <new group>', + desc='Move the given JID from the old group to the new group.', + shortdesc='Move an user to another group.', completion=self.completion_groupmove) self.register_command('groupremove', self.command_groupremove, - usage=_('<jid> <group>'), - desc=_('Remove the given JID from the given group.'), - shortdesc=_('Remove an user from a group.'), + usage='<jid> <group>', + desc='Remove the given JID from the given group.', + shortdesc='Remove an user from a group.', completion=self.completion_groupremove) self.register_command('remove', self.command_remove, - usage=_('[jid]'), - desc=_('Remove the specified JID from your roster. This ' - 'will unsubscribe you from its presence, cancel ' - 'its subscription to yours, and remove the item ' - 'from your roster.'), - shortdesc=_('Remove an user from your roster.'), + usage='[jid]', + desc='Remove the specified JID from your roster. This ' + 'will unsubscribe you from its presence, cancel ' + 'its subscription to yours, and remove the item ' + 'from your roster.', + shortdesc='Remove an user from your roster.', completion=self.completion_remove) self.register_command('export', self.command_export, - usage=_('[/path/to/file]'), - desc=_('Export your contacts into /path/to/file if ' - 'specified, or $HOME/poezio_contacts if not.'), - shortdesc=_('Export your roster to a file.'), + usage='[/path/to/file]', + desc='Export your contacts into /path/to/file if ' + 'specified, or $HOME/poezio_contacts if not.', + shortdesc='Export your roster to a file.', completion=partial(self.completion_file, 1)) self.register_command('import', self.command_import, - usage=_('[/path/to/file]'), - desc=_('Import your contacts from /path/to/file if ' - 'specified, or $HOME/poezio_contacts if not.'), - shortdesc=_('Import your roster from a file.'), + usage='[/path/to/file]', + desc='Import your contacts from /path/to/file if ' + 'specified, or $HOME/poezio_contacts if not.', + shortdesc='Import your roster from a file.', completion=partial(self.completion_file, 1)) self.register_command('password', self.command_password, usage='<password>', - shortdesc=_('Change your password')) + shortdesc='Change your password') self.register_command('reconnect', self.command_reconnect, - desc=_('Disconnect from the remote server if you are ' - 'currently connected and then connect to it again.'), - shortdesc=_('Disconnect and reconnect to the server.')) + desc='Disconnect from the remote server if you are ' + 'currently connected and then connect to it again.', + shortdesc='Disconnect and reconnect to the server.') self.register_command('disconnect', self.command_disconnect, - desc=_('Disconnect from the remote server.'), - shortdesc=_('Disconnect from the server.')) + desc='Disconnect from the remote server.', + shortdesc='Disconnect from the server.') self.register_command('clear', self.command_clear, - shortdesc=_('Clear the info buffer.')) + shortdesc='Clear the info buffer.') self.register_command('last_activity', self.command_last_activity, - usage=_('<jid>'), - desc=_('Informs you of the last activity of a JID.'), - shortdesc=_('Get the activity of someone.'), + usage='<jid>', + desc='Informs you of the last activity of a JID.', + shortdesc='Get the activity of someone.', completion=self.core.completion_last_activity) self.resize() @@ -151,51 +149,51 @@ class RosterInfoTab(Tab): def check_blocking(self, features): if 'urn:xmpp:blocking' in features and not self.core.xmpp.anon: self.register_command('block', self.command_block, - usage=_('[jid]'), - shortdesc=_('Prevent a JID from talking to you.'), + usage='[jid]', + shortdesc='Prevent a JID from talking to you.', completion=self.completion_block) self.register_command('unblock', self.command_unblock, - usage=_('[jid]'), - shortdesc=_('Allow a JID to talk to you.'), + usage='[jid]', + shortdesc='Allow a JID to talk to you.', completion=self.completion_unblock) self.register_command('list_blocks', self.command_list_blocks, - shortdesc=_('Show the blocked contacts.')) + shortdesc='Show the blocked contacts.') self.core.xmpp.del_event_handler('session_start', self.check_blocking) self.core.xmpp.add_event_handler('blocked_message', self.on_blocked_message) def check_saslexternal(self, features): if 'urn:xmpp:saslcert:1' in features and not self.core.xmpp.anon: self.register_command('certs', self.command_certs, - desc=_('List the fingerprints of certificates' - ' which can connect to your account.'), - shortdesc=_('List allowed client certs.')) + desc='List the fingerprints of certificates' + ' which can connect to your account.', + shortdesc='List allowed client certs.') self.register_command('cert_add', self.command_cert_add, - desc=_('Add a client certificate to the authorized ones. ' - 'It must have an unique name and be contained in ' - 'a PEM file. [management] is a boolean indicating' - ' if a client connected using this certificate can' - ' manage the certificates itself.'), - shortdesc=_('Add a client certificate.'), + desc='Add a client certificate to the authorized ones. ' + 'It must have an unique name and be contained in ' + 'a PEM file. [management] is a boolean indicating' + ' if a client connected using this certificate can' + ' manage the certificates itself.', + shortdesc='Add a client certificate.', usage='<name> <certificate path> [management]', completion=self.completion_cert_add) self.register_command('cert_disable', self.command_cert_disable, - desc=_('Remove a certificate from the list ' - 'of allowed ones. Clients currently ' - 'using this certificate will not be ' - 'forcefully disconnected.'), - shortdesc=_('Disable a certificate'), + desc='Remove a certificate from the list ' + 'of allowed ones. Clients currently ' + 'using this certificate will not be ' + 'forcefully disconnected.', + shortdesc='Disable a certificate', usage='<name>') self.register_command('cert_revoke', self.command_cert_revoke, - desc=_('Remove a certificate from the list ' - 'of allowed ones. Clients currently ' - 'using this certificate will be ' - 'forcefully disconnected.'), - shortdesc=_('Revoke a certificate'), + desc='Remove a certificate from the list ' + 'of allowed ones. Clients currently ' + 'using this certificate will be ' + 'forcefully disconnected.', + shortdesc='Revoke a certificate', usage='<name>') self.register_command('cert_fetch', self.command_cert_fetch, - desc=_('Retrieve a certificate with its ' - 'name. It will be stored in <path>.'), - shortdesc=_('Fetch a certificate'), + desc='Retrieve a certificate with its ' + 'name. It will be stored in <path>.', + shortdesc='Fetch a certificate', usage='<name> <path>', completion=self.completion_cert_fetch) @@ -206,8 +204,8 @@ class RosterInfoTab(Tab): """ def cb(iq): if iq['type'] == 'error': - self.core.information(_('Unable to retrieve the certificate list.'), - _('Error')) + self.core.information('Unable to retrieve the certificate list.', + 'Error') return certs = [] for item in iq['sasl_certs']['items']: @@ -215,8 +213,8 @@ class RosterInfoTab(Tab): certs.append((item['name'], users)) if not certs: - return self.core.information(_('No certificates found'), _('Info')) - msg = _('Certificates:\n') + return self.core.information('No certificates found', 'Info') + msg = 'Certificates:\n' msg += '\n'.join(((' %s%s' % (item[0] + (': ' if item[1] else ''), item[1])) for item in certs)) self.core.information(msg, 'Info') @@ -231,9 +229,9 @@ class RosterInfoTab(Tab): return self.core.command_help('cert_add') def cb(iq): if iq['type'] == 'error': - self.core.information(_('Unable to add the certificate.'), _('Error')) + self.core.information('Unable to add the certificate.', 'Error') else: - self.core.information(_('Certificate added.'), _('Info')) + self.core.information('Certificate added.', 'Info') name = args[0] @@ -285,9 +283,9 @@ class RosterInfoTab(Tab): return self.core.command_help('cert_disable') def cb(iq): if iq['type'] == 'error': - self.core.information(_('Unable to disable the certificate.'), _('Error')) + self.core.information('Unable to disable the certificate.', 'Error') else: - self.core.information(_('Certificate disabled.'), _('Info')) + self.core.information('Certificate disabled.', 'Info') name = args[0] @@ -302,9 +300,9 @@ class RosterInfoTab(Tab): return self.core.command_help('cert_revoke') def cb(iq): if iq['type'] == 'error': - self.core.information(_('Unable to revoke the certificate.'), _('Error')) + self.core.information('Unable to revoke the certificate.', 'Error') else: - self.core.information(_('Certificate revoked.'), _('Info')) + self.core.information('Certificate revoked.', 'Info') name = args[0] @@ -320,8 +318,8 @@ class RosterInfoTab(Tab): return self.core.command_help('cert_fetch') def cb(iq): if iq['type'] == 'error': - self.core.information(_('Unable to fetch the certificate.'), - _('Error')) + self.core.information('Unable to fetch the certificate.', + 'Error') return cert = None @@ -331,13 +329,13 @@ class RosterInfoTab(Tab): break if not cert: - return self.core.information(_('Certificate not found.'), _('Info')) + return self.core.information('Certificate not found.', 'Info') cert = ssl.DER_cert_to_PEM_cert(cert) with open(path, 'w') as fd: fd.write(cert) - self.core.information(_('File stored at %s') % path, 'Info') + self.core.information('File stored at %s' % path, 'Info') name = args[0] path = args[1] @@ -623,7 +621,7 @@ class RosterInfoTab(Tab): """ jid = safeJID(safeJID(args[0]).bare) if not jid: - self.core.information(_('No JID specified'), 'Error') + self.core.information('No JID specified', 'Error') return if jid in roster and roster[jid].subscription in ('to', 'both'): return self.core.information('Already subscribed.', 'Roster') @@ -647,7 +645,7 @@ class RosterInfoTab(Tab): contact = roster[jid] if contact is None: - self.core.information(_('No such JID in roster'), 'Error') + self.core.information('No such JID in roster', 'Error') return groups = set(contact.groups) @@ -669,12 +667,12 @@ class RosterInfoTab(Tab): contact = roster[jid] if contact is None: - self.core.information(_('No such JID in roster'), 'Error') + self.core.information('No such JID in roster', 'Error') return new_groups = set(contact.groups) if group in new_groups: - self.core.information(_('JID already in group'), 'Error') + self.core.information('JID already in group', 'Error') return roster.modified() @@ -710,7 +708,7 @@ class RosterInfoTab(Tab): contact = roster[jid] if not contact: - self.core.information(_('No such JID in roster'), 'Error') + self.core.information('No such JID in roster', 'Error') return new_groups = set(contact.groups) @@ -718,19 +716,19 @@ class RosterInfoTab(Tab): new_groups.remove('none') if group_to == 'none' or group_from == 'none': - self.core.information(_('"none" is not a group.'), 'Error') + self.core.information('"none" is not a group.', 'Error') return if group_from not in new_groups: - self.core.information(_('JID not in first group'), 'Error') + self.core.information('JID not in first group', 'Error') return if group_to in new_groups: - self.core.information(_('JID already in second group'), 'Error') + self.core.information('JID already in second group', 'Error') return if group_to == group_from: - self.core.information(_('The groups are the same.'), 'Error') + self.core.information('The groups are the same.', 'Error') return roster.modified() @@ -765,7 +763,7 @@ class RosterInfoTab(Tab): contact = roster[jid] if contact is None: - self.core.information(_('No such JID in roster'), 'Error') + self.core.information('No such JID in roster', 'Error') return new_groups = set(contact.groups) @@ -774,7 +772,7 @@ class RosterInfoTab(Tab): except KeyError: pass if group not in new_groups: - self.core.information(_('JID not in group'), 'Error') + self.core.information('JID not in group', 'Error') return roster.modified() @@ -1005,7 +1003,7 @@ class RosterInfoTab(Tab): success = config.silent_set(option, str(not value)) roster.modified() if not success: - self.core.information(_('Unable to write in the config file'), 'Error') + self.core.information('Unable to write in the config file', 'Error') return True def on_slash(self): diff --git a/src/tabs/xmltab.py b/src/tabs/xmltab.py index d6bdf35d..6899cd6f 100644 --- a/src/tabs/xmltab.py +++ b/src/tabs/xmltab.py @@ -5,8 +5,6 @@ in order to only show the relevant ones, and it can also be frozen or unfrozen on demand so that the relevant information is not drowned by the traffic. """ -from gettext import gettext as _ - import logging log = logging.getLogger(__name__) @@ -71,40 +69,40 @@ class XMLTab(Tab): self.default_help_message = windows.HelpText("/ to enter a command") self.register_command('close', self.close, - shortdesc=_("Close this tab.")) + shortdesc="Close this tab.") self.register_command('clear', self.command_clear, - shortdesc=_('Clear the current buffer.')) + shortdesc='Clear the current buffer.') self.register_command('reset', self.command_reset, - shortdesc=_('Reset the stanza filter.')) + shortdesc='Reset the stanza filter.') self.register_command('filter_id', self.command_filter_id, usage='<id>', - desc=_('Show only the stanzas with the id <id>.'), - shortdesc=_('Filter by id.')) + desc='Show only the stanzas with the id <id>.', + shortdesc='Filter by id.') self.register_command('filter_xpath', self.command_filter_xpath, usage='<xpath>', - desc=_('Show only the stanzas matching the xpath <xpath>.' - ' Any occurrences of %n will be replaced by jabber:client.'), - shortdesc=_('Filter by XPath.')) + desc='Show only the stanzas matching the xpath <xpath>.' + ' Any occurrences of %n will be replaced by jabber:client.', + shortdesc='Filter by XPath.') self.register_command('filter_jid', self.command_filter_jid, usage='<jid>', - desc=_('Show only the stanzas matching the jid <jid> in from= or to=.'), - shortdesc=_('Filter by JID.')) + desc='Show only the stanzas matching the jid <jid> in from= or to=.', + shortdesc='Filter by JID.') self.register_command('filter_from', self.command_filter_from, usage='<jid>', - desc=_('Show only the stanzas matching the jid <jid> in from=.'), - shortdesc=_('Filter by JID from.')) + desc='Show only the stanzas matching the jid <jid> in from=.', + shortdesc='Filter by JID from.') self.register_command('filter_to', self.command_filter_to, usage='<jid>', - desc=_('Show only the stanzas matching the jid <jid> in to=.'), - shortdesc=_('Filter by JID to.')) + desc='Show only the stanzas matching the jid <jid> in to=.', + shortdesc='Filter by JID to.') self.register_command('filter_xmlmask', self.command_filter_xmlmask, - usage=_('<xml mask>'), - desc=_('Show only the stanzas matching the given xml mask.'), - shortdesc=_('Filter by xml mask.')) + usage='<xml mask>', + desc='Show only the stanzas matching the given xml mask.', + shortdesc='Filter by xml mask.') self.register_command('dump', self.command_dump, - usage=_('<filename>'), - desc=_('Writes the content of the XML buffer into a file.'), - shortdesc=_('Write in a file.')) + usage='<filename>', + desc='Writes the content of the XML buffer into a file.', + shortdesc='Write in a file.') self.input = self.default_help_message self.key_func['^T'] = self.close self.key_func['^I'] = self.completion |