Cleaned and updated the i18n strings for various server-core system. Removed i18n for all strings that are only visible on stdout or in logs. Still missing i18n on certain specific things such as model field help and attribute warnings. Updated Swedish translation to match.
This commit is contained in:
parent
80da420ee7
commit
4c849ec351
26 changed files with 918 additions and 1420 deletions
|
|
@ -45,6 +45,8 @@ from src.commands.cmdset import CmdSet
|
|||
from src.commands.cmdparser import at_multimatch_cmd
|
||||
from src.utils.utils import string_suggestions
|
||||
|
||||
from django.utils.translation import ugettext as _
|
||||
|
||||
__all__ = ("cmdhandler",)
|
||||
|
||||
# This decides which command parser is to be used.
|
||||
|
|
@ -196,18 +198,18 @@ def cmdhandler(caller, raw_string, testing=False):
|
|||
if syscmd:
|
||||
sysarg = raw_string
|
||||
else:
|
||||
sysarg = "Command '%s' is not available." % raw_string
|
||||
sysarg = _("Command '%s' is not available.") % raw_string
|
||||
suggestions = string_suggestions(raw_string, cmdset.get_all_cmd_keys_and_aliases(caller), cutoff=0.7, maxnum=3)
|
||||
if suggestions:
|
||||
sysarg += " Maybe you meant %s?" % utils.list_to_string(suggestions, 'or', addquote=True)
|
||||
sysarg += _(" Maybe you meant %s?") % utils.list_to_string(suggestions, _('or'), addquote=True)
|
||||
else:
|
||||
sysarg += " Type \"help\" for help."
|
||||
sysarg += _(" Type \"help\" for help.")
|
||||
raise ExecSystemCommand(syscmd, sysarg)
|
||||
|
||||
if len(matches) > 1:
|
||||
# We have a multiple-match
|
||||
syscmd = yield cmdset.get(CMD_MULTIMATCH)
|
||||
sysarg = "There where multiple matches."
|
||||
sysarg = _("There where multiple matches.")
|
||||
if syscmd:
|
||||
syscmd.matches = matches
|
||||
else:
|
||||
|
|
@ -301,19 +303,19 @@ def cmdhandler(caller, raw_string, testing=False):
|
|||
string += "If logging out/in doesn't solve the problem, try to "
|
||||
string += "contact the server admin through some other means "
|
||||
string += "for assistance."
|
||||
caller.msg(string)
|
||||
caller.msg(_(string))
|
||||
logger.log_errmsg("No cmdsets found: %s" % caller)
|
||||
|
||||
except Exception:
|
||||
# We should not end up here. If we do, it's a programming bug.
|
||||
string = "%s\nAbove traceback is from an untrapped error."
|
||||
string += " Please file a bug report."
|
||||
logger.log_trace(string)
|
||||
logger.log_trace(_(string))
|
||||
caller.msg(string % format_exc())
|
||||
|
||||
except Exception:
|
||||
# This catches exceptions in cmdhandler exceptions themselves
|
||||
string = "%s\nAbove traceback is from a Command handler bug."
|
||||
string += " Please contact an admin and/or file a bug report."
|
||||
logger.log_trace(string)
|
||||
logger.log_trace(_(string))
|
||||
caller.msg(string % format_exc())
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ return a CommandCandidates object.
|
|||
"""
|
||||
|
||||
from src.utils.logger import log_trace
|
||||
from django.utils.translation import ugettext as _
|
||||
|
||||
def cmdparser(raw_string, cmdset, caller, match_index=None):
|
||||
"""
|
||||
|
|
@ -140,7 +141,7 @@ def at_search_result(msg_obj, ostring, results, global_search=False):
|
|||
string = ""
|
||||
if not results:
|
||||
# no results.
|
||||
string = "Could not find '%s'." % ostring
|
||||
string = _("Could not find '%s'." % ostring)
|
||||
results = None
|
||||
|
||||
elif len(results) > 1:
|
||||
|
|
@ -152,11 +153,12 @@ def at_search_result(msg_obj, ostring, results, global_search=False):
|
|||
|
||||
string += "More than one match for '%s'" % ostring
|
||||
string += " (please narrow target):"
|
||||
string = _(string)
|
||||
for num, result in enumerate(results):
|
||||
invtext = ""
|
||||
dbreftext = ""
|
||||
if hasattr(result, "location") and result.location == msg_obj:
|
||||
invtext = " (carried)"
|
||||
if hasattr(result, _("location")) and result.location == msg_obj:
|
||||
invtext = _(" (carried)")
|
||||
if show_dbref:
|
||||
dbreftext = "(#%i)" % result.dbid
|
||||
string += "\n %i-%s%s%s" % (num+1, result.name,
|
||||
|
|
@ -235,11 +237,11 @@ def at_multimatch_cmd(caller, matches):
|
|||
|
||||
is_channel = hasattr(cmd, "is_channel") and cmd.is_channel
|
||||
if is_channel:
|
||||
is_channel = " (channel)"
|
||||
is_channel = _(" (channel)")
|
||||
else:
|
||||
is_channel = ""
|
||||
if cmd.is_exit and cmd.destination:
|
||||
is_exit = " (exit to %s)" % cmd.destination
|
||||
is_exit = _(" (exit to %s)") % cmd.destination
|
||||
else:
|
||||
is_exit = ""
|
||||
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@ together to create interesting in-game effects.
|
|||
"""
|
||||
|
||||
import copy
|
||||
from django.utils.translation import ugettext as _
|
||||
from src.utils.utils import inherits_from, is_iter
|
||||
__all__ = ("CmdSet",)
|
||||
|
||||
|
|
@ -303,9 +304,9 @@ class CmdSet(object):
|
|||
try:
|
||||
cmd = self._instantiate(cmd)
|
||||
except RuntimeError, e:
|
||||
string = "Adding cmdset %s to %s lead to an infinite loop. When adding a cmdset to another, "
|
||||
string = "Adding cmdset %(cmd)s to %(class)s lead to an infinite loop. When adding a cmdset to another, "
|
||||
string += "make sure they are not themself cyclically added to the new cmdset somewhere in the chain."
|
||||
raise RuntimeError(string % (cmd, self.__class__))
|
||||
raise RuntimeError(_(string) % {"cmd":cmd, "class":self.__class__})
|
||||
cmds = cmd.commands
|
||||
elif is_iter(cmd):
|
||||
cmds = [self._instantiate(c) for c in cmd]
|
||||
|
|
|
|||
|
|
@ -67,6 +67,8 @@ import traceback
|
|||
from src.utils import logger, utils
|
||||
from src.commands.cmdset import CmdSet
|
||||
from src.server.models import ServerConfig
|
||||
|
||||
from django.utils.translation import ugettext as _
|
||||
__all__ = ("import_cmdset", "CmdSetHandler")
|
||||
|
||||
_CACHED_CMDSETS = {}
|
||||
|
|
@ -110,15 +112,15 @@ def import_cmdset(python_path, cmdsetobj, emit_to_obj=None, no_logging=False):
|
|||
return cmdsetclass
|
||||
|
||||
except ImportError:
|
||||
errstring = "Error loading cmdset: Couldn't import module '%s'."
|
||||
errstring = _("Error loading cmdset: Couldn't import module '%s'.")
|
||||
errstring = errstring % modulepath
|
||||
raise
|
||||
except KeyError:
|
||||
errstring = "Error in loading cmdset: No cmdset class '%s' in %s."
|
||||
errstring = errstring % (classname, modulepath)
|
||||
errstring = _("Error in loading cmdset: No cmdset class '%(classname)s' in %(modulepath)s.")
|
||||
errstring = errstring % {"classname":classname, "modulepath":modulepath}
|
||||
raise
|
||||
except Exception:
|
||||
errstring = "Compile/Run error when loading cmdset '%s'. Error was logged."
|
||||
errstring = _("Compile/Run error when loading cmdset '%s'. Error was logged.")
|
||||
errstring = errstring % (python_path)
|
||||
raise
|
||||
except Exception:
|
||||
|
|
@ -194,15 +196,17 @@ class CmdSetHandler(object):
|
|||
mergetype = self.mergetype_stack[-1]
|
||||
if mergetype != self.current.mergetype:
|
||||
merged_on = self.cmdset_stack[-2].key
|
||||
mergetype = "custom %s on cmdset '%s'" % (mergetype, merged_on)
|
||||
mergetype = _("custom %(mergetype)s on cmdset '%(merged_on)s'") % {"mergetype":mergetype, "merged_on":merged_on}
|
||||
if mergelist:
|
||||
string += " <Merged %s (%s, prio %i)>: %s" % ("+".join(mergelist), mergetype, self.current.priority, self.current)
|
||||
string += _(" <Merged %(mergelist)s (%(mergetype)s, prio %(prio)i)>: %(current)s") % \
|
||||
{"mergelist": "+".join(mergelist), "mergetype":mergetype, "prio":self.current.priority, "current":self.current}
|
||||
else:
|
||||
permstring = "non-perm"
|
||||
if self.current.permanent:
|
||||
permstring = "perm"
|
||||
string += " <%s (%s, prio %i, %s)>: %s" % (self.current.key, mergetype, self.current.priority, permstring,
|
||||
", ".join(cmd.key for cmd in sorted(self.current, key=lambda o:o.key)))
|
||||
string += _(" <%(key)s (%(mergetype)s, prio %(prio)i, %(permstring)s)>: %(keylist)s") % \
|
||||
{"key":self.current.key, "mergetype":mergetype, "prio":self.current.priority, "permstring":permstring,
|
||||
"keylost":", ".join(cmd.key for cmd in sorted(self.current, key=lambda o:o.key))}
|
||||
return string.strip()
|
||||
|
||||
def _import_cmdset(self, cmdset_path, emit_to_obj=None):
|
||||
|
|
@ -274,7 +278,7 @@ class CmdSetHandler(object):
|
|||
"""
|
||||
if callable(cmdset):
|
||||
if not utils.inherits_from(cmdset, CmdSet):
|
||||
raise Exception("Only CmdSets can be added to the cmdsethandler!")
|
||||
raise Exception(_("Only CmdSets can be added to the cmdsethandler!"))
|
||||
cmdset = cmdset(self.obj)
|
||||
elif isinstance(cmdset, basestring):
|
||||
# this is (maybe) a python path. Try to import from cache.
|
||||
|
|
@ -306,7 +310,7 @@ class CmdSetHandler(object):
|
|||
"""
|
||||
if callable(cmdset):
|
||||
if not utils.inherits_from(cmdset, CmdSet):
|
||||
raise Exception("Only CmdSets can be added to the cmdsethandler!")
|
||||
raise Exception(_("Only CmdSets can be added to the cmdsethandler!"))
|
||||
cmdset = cmdset(self.obj)
|
||||
elif isinstance(cmdset, basestring):
|
||||
# this is (maybe) a python path. Try to import from cache.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue