cleaned up some i18n strings in the code. Resolves #684.
This commit is contained in:
parent
7f20631bfc
commit
28158299b5
2 changed files with 43 additions and 32 deletions
|
|
@ -91,15 +91,20 @@ def import_cmdset(path, cmdsetobj, emit_to_obj=None, no_logging=False):
|
||||||
instance from a python module, given a python_path. It's usually accessed
|
instance from a python module, given a python_path. It's usually accessed
|
||||||
through the cmdsethandler's add() and add_default() methods.
|
through the cmdsethandler's add() and add_default() methods.
|
||||||
path - This is the full path to the cmdset object on python dot-form
|
path - This is the full path to the cmdset object on python dot-form
|
||||||
cmdsetobj - the database object/typeclass on which this cmdset is to be
|
|
||||||
|
Args:
|
||||||
|
cmdsetobj (CmdSet): The database object/typeclass on which this cmdset is to be
|
||||||
assigned (this can be also channels and exits, as well as players
|
assigned (this can be also channels and exits, as well as players
|
||||||
but there will always be such an object)
|
but there will always be such an object)
|
||||||
emit_to_obj - if given, error is emitted to this object (in addition
|
emit_to_obj (Object, optional): If given, error is emitted to
|
||||||
to logging)
|
this object (in addition to logging)
|
||||||
no_logging - don't log/send error messages. This can be useful
|
no_logging (bool, optional): Don't log/send error messages.
|
||||||
if import_cmdset is just used to check if this is a
|
This can be useful if import_cmdset is just used to check if
|
||||||
valid python path or not.
|
this is a valid python path or not.
|
||||||
function returns None if an error was encountered or path not found.
|
Returns:
|
||||||
|
cmdset (CmdSet): If an error was encountered, `commands.cmdsethandler._ErrorCmdSet`
|
||||||
|
is returned for the benefit of the handler.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
python_paths = [path] + ["%s.%s" % (prefix, path)
|
python_paths = [path] + ["%s.%s" % (prefix, path)
|
||||||
|
|
@ -124,21 +129,20 @@ def import_cmdset(path, cmdsetobj, emit_to_obj=None, no_logging=False):
|
||||||
return cmdsetclass
|
return cmdsetclass
|
||||||
except ImportError, e:
|
except ImportError, e:
|
||||||
logger.log_trace()
|
logger.log_trace()
|
||||||
errstring += _("Error loading cmdset '%s': %s.")
|
errstring += _("Error loading cmdset {path}: {error}")
|
||||||
errstring = errstring % (python_path, e)
|
errstring = errstring.format(path=python_path, error=e)
|
||||||
except KeyError:
|
except KeyError:
|
||||||
logger.log_trace()
|
logger.log_trace()
|
||||||
errstring += _("Error in loading cmdset: No cmdset class '%(classname)s' in %(modulepath)s.")
|
errstring += _("Error in loading cmdset: No cmdset class '{classname}' in {path}.")
|
||||||
errstring = errstring % {"classname": classname,
|
errstring = errstring.format(classname=classname, path=python_path)
|
||||||
"modulepath": python_path}
|
|
||||||
except SyntaxError, e:
|
except SyntaxError, e:
|
||||||
logger.log_trace()
|
logger.log_trace()
|
||||||
errstring += _("SyntaxError encountered when loading cmdset '%s': %s.")
|
errstring += _("SyntaxError encountered when loading cmdset '{path}': {error}.")
|
||||||
errstring = errstring % (python_path, e)
|
errstring = errstring.format(path=python_path, error=e)
|
||||||
except Exception, e:
|
except Exception, e:
|
||||||
logger.log_trace()
|
logger.log_trace()
|
||||||
errstring += _("Compile/Run error when loading cmdset '%s': %s.")
|
errstring += _("Compile/Run error when loading cmdset '{path}': {error}.")
|
||||||
errstring = errstring % (python_path, e)
|
errstring = errstring.format(path=python_path, error=e)
|
||||||
|
|
||||||
if errstring:
|
if errstring:
|
||||||
# returning an empty error cmdset
|
# returning an empty error cmdset
|
||||||
|
|
@ -214,21 +218,23 @@ class CmdSetHandler(object):
|
||||||
mergetype = self.mergetype_stack[-1]
|
mergetype = self.mergetype_stack[-1]
|
||||||
if mergetype != self.current.mergetype:
|
if mergetype != self.current.mergetype:
|
||||||
merged_on = self.cmdset_stack[-2].key
|
merged_on = self.cmdset_stack[-2].key
|
||||||
mergetype = _("custom %(mergetype)s on cmdset '%(merged_on)s'") % \
|
mergetype = _("custom {mergetype} on cmdset '{cmdset}'")
|
||||||
{"mergetype": mergetype, "merged_on":merged_on}
|
mergetype = mergetype.format(mergetype=mergetype, cmdset=merged_on)
|
||||||
if mergelist:
|
if mergelist:
|
||||||
string += _(" <Merged %(mergelist)s (%(mergetype)s, prio %(prio)i)>: %(current)s") % \
|
tmpstring = _(" <Merged {mergelist} {mergetype}, prio {prio}>: {current}")
|
||||||
{"mergelist": "+".join(mergelist),
|
string += tmpstring.format(mergelist="+".join(mergelist),
|
||||||
"mergetype": mergetype, "prio": self.current.priority,
|
mergetype=mergetype, prio=self.current.priority,
|
||||||
"current":self.current}
|
current=self.current)
|
||||||
else:
|
else:
|
||||||
permstring = "non-perm"
|
permstring = "non-perm"
|
||||||
if self.current.permanent:
|
if self.current.permanent:
|
||||||
permstring = "perm"
|
permstring = "perm"
|
||||||
string += _(" <%(key)s (%(mergetype)s, prio %(prio)i, %(permstring)s)>: %(keylist)s") % \
|
tmpstring = _(" <{key} ({mergetype} prio {prio}, {permstring}>: {keylist}")
|
||||||
{"key": self.current.key, "mergetype": mergetype,
|
string += tmpstring.format(key=self.current.key, mergetype=mergetype,
|
||||||
"prio": self.current.priority, "permstring": permstring,
|
prio=self.current.priority,
|
||||||
"keylist": ", ".join(cmd.key for cmd in sorted(self.current, key=lambda o: o.key))}
|
permstring=permstring,
|
||||||
|
keylist=", ".join(cmd.key for
|
||||||
|
cmd in sorted(self.current, key=lambda o: o.key)))
|
||||||
return string.strip()
|
return string.strip()
|
||||||
|
|
||||||
def _import_cmdset(self, cmdset_path, emit_to_obj=None):
|
def _import_cmdset(self, cmdset_path, emit_to_obj=None):
|
||||||
|
|
@ -299,7 +305,9 @@ class CmdSetHandler(object):
|
||||||
that has to be documented.
|
that has to be documented.
|
||||||
"""
|
"""
|
||||||
if not (isinstance(cmdset, basestring) or utils.inherits_from(cmdset, CmdSet)):
|
if not (isinstance(cmdset, basestring) or utils.inherits_from(cmdset, CmdSet)):
|
||||||
raise Exception(_("Only CmdSets can be added to the cmdsethandler!"))
|
string = _("Only CmdSets can be added to the cmdsethandler!")
|
||||||
|
raise Exception(string)
|
||||||
|
|
||||||
if callable(cmdset):
|
if callable(cmdset):
|
||||||
cmdset = cmdset(self.obj)
|
cmdset = cmdset(self.obj)
|
||||||
elif isinstance(cmdset, basestring):
|
elif isinstance(cmdset, basestring):
|
||||||
|
|
@ -332,7 +340,8 @@ class CmdSetHandler(object):
|
||||||
"""
|
"""
|
||||||
if callable(cmdset):
|
if callable(cmdset):
|
||||||
if not utils.inherits_from(cmdset, CmdSet):
|
if not utils.inherits_from(cmdset, CmdSet):
|
||||||
raise Exception(_("Only CmdSets can be added to the cmdsethandler!"))
|
string = _("Only CmdSets can be added to the cmdsethandler!")
|
||||||
|
raise Exception(string)
|
||||||
cmdset = cmdset(self.obj)
|
cmdset = cmdset(self.obj)
|
||||||
elif isinstance(cmdset, basestring):
|
elif isinstance(cmdset, basestring):
|
||||||
# this is (maybe) a python path. Try to import from cache.
|
# this is (maybe) a python path. Try to import from cache.
|
||||||
|
|
|
||||||
|
|
@ -281,8 +281,9 @@ class ServerSessionHandler(SessionHandler):
|
||||||
self.disconnect_duplicate_sessions(session)
|
self.disconnect_duplicate_sessions(session)
|
||||||
|
|
||||||
nsess = len(self.sessions_from_player(player))
|
nsess = len(self.sessions_from_player(player))
|
||||||
totalstring = "%i session%s total" % (nsess, nsess > 1 and "s" or "")
|
string = _("Logged in: {player} {address} ({nsessions} session(s) total)")
|
||||||
session.log(_('Logged in: %s %s (%s)' % (player, session.address, totalstring)))
|
string = string.format(player=player,address=session.address, nsessions=nsess)
|
||||||
|
session.log(string)
|
||||||
|
|
||||||
session.logged_in = True
|
session.logged_in = True
|
||||||
# sync the portal to the session
|
# sync the portal to the session
|
||||||
|
|
@ -305,8 +306,9 @@ class ServerSessionHandler(SessionHandler):
|
||||||
if hasattr(session, "player") and session.player:
|
if hasattr(session, "player") and session.player:
|
||||||
# only log accounts logging off
|
# only log accounts logging off
|
||||||
nsess = len(self.sessions_from_player(session.player)) - 1
|
nsess = len(self.sessions_from_player(session.player)) - 1
|
||||||
remaintext = nsess and "%i session%s remaining" % (nsess, nsess > 1 and "s" or "") or "no more sessions"
|
string = _("Logged out: {player} {address} ({nsessions} sessions(s) remaining)")
|
||||||
session.log(_('Logged out: %s %s (%s)' % (session.player, session.address, remaintext)))
|
string = string.format(player=session.player, address=session.address, nsessions=nsess)
|
||||||
|
session.log(string)
|
||||||
|
|
||||||
session.at_disconnect()
|
session.at_disconnect()
|
||||||
sessid = session.sessid
|
sessid = session.sessid
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue