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:
Griatch 2012-06-14 02:43:35 +02:00
parent 80da420ee7
commit 4c849ec351
26 changed files with 918 additions and 1420 deletions

View file

@ -42,11 +42,11 @@ simple format. The engine runs each command in sequence, as if they
had been run at the game prompt.
Each evennia command must be delimited by a line comment to mark its
end.
end.
#INSERT path.batchcmdfile - this as the first entry on a line will
import and run a batch.ev file in this position, as if it was
written in this file.
import and run a batch.ev file in this position, as if it was
written in this file.
This way entire game worlds can be created and planned offline; it is
especially useful in order to create long room descriptions where a
@ -54,11 +54,11 @@ real offline text editor is often much better than any online text
editor or prompt.
Example of batch.ev file:
----------------------------
----------------------------
# batch file
# all lines starting with # are comments; they also indicate
# that a command definition is over.
# that a command definition is over.
@create box
@ -66,10 +66,10 @@ Example of batch.ev file:
@set box/desc = A large box.
Inside are some scattered piles of clothing.
Inside are some scattered piles of clothing.
It seems the bottom of the box is a bit loose.
It seems the bottom of the box is a bit loose.
# Again, this comment indicates the @set command is over. Note how
# the description could be freely added. Excess whitespace on a line
@ -81,7 +81,7 @@ It seems the bottom of the box is a bit loose.
# (Assuming #221 is a warehouse or something.)
# (remember, this comment ends the @teleport command! Don'f forget it)
# Example of importing another file at this point.
# Example of importing another file at this point.
#IMPORT examples.batch
@drop box
@ -90,7 +90,7 @@ It seems the bottom of the box is a bit loose.
# close the @drop command since it's the end of the file)
-------------------------
An example batch file is game/gamesrc/commands/examples/batch_example.ev.
An example batch file is game/gamesrc/commands/examples/batch_example.ev.
==========================================================================
@ -114,9 +114,9 @@ code words.
automatically be pasted at the top of all code
blocks. Observe that changes to these variables made in one
block is not preserved between blocks!
#CODE
#CODE
#CODE (info)
#CODE (info) objname1, objname1, ... -
#CODE (info) objname1, objname1, ... -
This designates a code block that will be executed like a
stand-alone piece of code together with any #HEADER
defined. (info) text is used by the interactive mode to
@ -140,12 +140,12 @@ caller - the object executing the script
Example batch.py file
-----------------------------------
#HEADER
#HEADER
import traceback
import traceback
from django.config import settings
from src.utils import create
from game.gamesrc.typeclasses import basetypes
from game.gamesrc.typeclasses import basetypes
GOLD = 10
@ -188,12 +188,12 @@ def read_batchfile(pythonpath, file_ending='.py'):
Filename is considered to be the name of the batch file
relative the directory specified in settings.py.
file_ending specify which batchfile ending should be
file_ending specify which batchfile ending should be
assumed (.ev or .py).
"""
"""
# open the file
if pythonpath and not (pythonpath.startswith('src.') or pythonpath.startswith('game.')
if pythonpath and not (pythonpath.startswith('src.') or pythonpath.startswith('game.')
or pythonpath.startswith('contrib.')):
abspaths = []
for basepath in settings.BASE_BATCHPROCESS_PATHS:
@ -202,24 +202,24 @@ def read_batchfile(pythonpath, file_ending='.py'):
abspaths = [utils.pypath_to_realpath(pythonpath, file_ending)]
fobj, lines, err = None, [], None
for file_encoding in ENCODINGS:
# try different encodings, in order
# try different encodings, in order
load_errors = []
for abspath in abspaths:
# try different paths, until we get a match
try:
# try different paths, until we get a match
try:
# we read the file directly into unicode.
fobj = codecs.open(abspath, 'r', encoding=file_encoding)
except IOError:
load_errors.append("Could not open batchfile '%s'." % abspath)
continue
continue
break
if not fobj:
continue
continue
load_errors = []
err =None
err =None
# We have successfully found and opened the file. Now actually
# try to decode it using the given protocol.
# try to decode it using the given protocol.
try:
lines = fobj.readlines()
except UnicodeDecodeError:
@ -230,19 +230,19 @@ def read_batchfile(pythonpath, file_ending='.py'):
for lnum, line in enumerate(fobj):
pass
except UnicodeDecodeError, err:
# lnum starts from 0, so we add +1 line,
# lnum starts from 0, so we add +1 line,
# besides the faulty line is never read
# so we add another 1 (thus +2) to get
# the actual line number seen in an editor.
err.linenum = lnum + 2
# the actual line number seen in an editor.
err.linenum = lnum + 2
fobj.close()
# possibly try another encoding
continue
continue
# if we get here, the encoding worked. Stop iteration.
break
if load_errors:
break
if load_errors:
logger.log_errmsg("\n".join(load_errors))
if err:
if err:
return err
else:
return lines
@ -257,7 +257,7 @@ class BatchCommandProcessor(object):
"""
This class implements a batch-command processor.
"""
"""
def parse_file(self, pythonpath):
"""
This parses the lines of a batchfile according to the following
@ -266,15 +266,15 @@ class BatchCommandProcessor(object):
It is also a comment and any number of # can exist on subsequent
lines (but not inside comments).
2) #INSERT at the beginning of a line imports another
batch-cmd file file and pastes it into the batch file as if
it was written there.
batch-cmd file file and pastes it into the batch file as if
it was written there.
3) Commands are placed alone at the beginning of a line and their
arguments are considered to be everything following (on any
number of lines) until the next comment line beginning with #.
4) Newlines are ignored in command definitions
5) A completely empty line in a command line definition is condered
a newline (so two empty lines is a paragraph).
6) Excess spaces and indents inside arguments are stripped.
6) Excess spaces and indents inside arguments are stripped.
"""
@ -287,7 +287,7 @@ class BatchCommandProcessor(object):
if line.strip().startswith("#INSERT"):
return "insert"
elif line.strip()[0] == '#':
return "comment"
return "comment"
else:
return "commanddef"
except IndexError:
@ -295,10 +295,10 @@ class BatchCommandProcessor(object):
#read the indata, if possible.
lines = read_batchfile(pythonpath, file_ending='.ev')
#line = utils.to_unicode(line)
if not lines:
return None
return None
commands = []
curr_cmd = ""
@ -309,34 +309,34 @@ class BatchCommandProcessor(object):
#parse all command definitions into a list.
for line in lines:
typ = identify_line(line)
if typ == "commanddef":
curr_cmd += line
elif typ == "empty" and curr_cmd:
curr_cmd += "\r\n"
elif typ == "insert":
# note that we are not safeguarding for
# note that we are not safeguarding for
# cyclic imports here!
if curr_cmd:
commands.append(curr_cmd.strip())
curr_cmd = ""
filename = line.lstrip("#INSERT").strip()
filename = line.lstrip("#INSERT").strip()
insert_commands = self.parse_file(filename)
if insert_commands == None:
insert_commands = ["{rINSERT ERROR: %s{n" % filename]
commands.extend(insert_commands)
commands.extend(insert_commands)
else: #comment
if curr_cmd:
commands.append(curr_cmd.strip())
curr_cmd = ""
if curr_cmd:
commands.append(curr_cmd.strip())
curr_cmd = ""
if curr_cmd:
commands.append(curr_cmd.strip())
#second round to clean up now merged line edges etc.
reg2 = re.compile(r"[ \t\f\v]+")
commands = [reg2.sub(" ", c) for c in commands]
commands = [reg2.sub(" ", c) for c in commands]
#remove eventual newline at the end of commands
commands = [c.strip('\r\n') for c in commands]
@ -359,7 +359,7 @@ def tb_iter(tb):
class BatchCodeProcessor(object):
"""
This implements a batch-code processor
"""
def parse_file(self, pythonpath):
@ -369,8 +369,8 @@ class BatchCodeProcessor(object):
1) Lines starting with #HEADER starts a header block (ends other blocks)
2) Lines starting with #CODE begins a code block (ends other blocks)
3) #CODE headers may be of the following form: #CODE (info) objname, objname2, ...
4) Lines starting with #INSERT are on form #INSERT filename.
3) #CODE headers may be of the following form: #CODE (info) objname, objname2, ...
4) Lines starting with #INSERT are on form #INSERT filename.
3) All lines outside blocks are stripped.
4) All excess whitespace beginning/ending a block is stripped.
@ -379,9 +379,9 @@ class BatchCodeProcessor(object):
# helper function
def parse_line(line):
"""
Identifies the line type: block command, comment, empty or normal code.
Identifies the line type: block command, comment, empty or normal code.
"""
"""
parseline = line.strip()
if parseline.startswith("#HEADER"):
@ -399,7 +399,7 @@ class BatchCodeProcessor(object):
if info:
info = info[0]
line = line.replace(info, "")
objs = [o.strip() for o in line.split(",") if o.strip()]
objs = [o.strip() for o in line.split(",") if o.strip()]
return ("codeheader", info, objs)
elif parseline.startswith('#'):
return ('comment', "", "%s" % line)
@ -422,25 +422,25 @@ class BatchCodeProcessor(object):
in_code = False
for line in lines:
# parse line
# parse line
mode, info, line = parse_line(line)
# try:
# print "::", in_header, in_code, mode, line.strip()
# print "::", in_header, in_code, mode, line.strip()
# except:
# print "::", in_header, in_code, mode, line
if mode == 'insert':
# print "::", in_header, in_code, mode, line
if mode == 'insert':
# recursive load of inserted code files - note that we
# are not checking for cyclic imports!
in_header = False
in_code = False
inserted_codes = self.parse_file(line) or [{'objs':"", 'info':line, 'code':""}]
for codedict in inserted_codes:
codedict["inserted"] = True
for codedict in inserted_codes:
codedict["inserted"] = True
codes.extend(inserted_codes)
elif mode == 'header':
in_header = True
in_code = False
elif mode == 'codeheader':
elif mode == 'codeheader':
in_header = False
in_code = True
# the line is a list of object variable names
@ -468,9 +468,9 @@ class BatchCodeProcessor(object):
# just check for errors.
if not codedict['code']:
codedict['code'] = "{r#INSERT ERROR: %s{n" % codedict['info']
else:
else:
objs = ", ".join(codedict["objs"])
if objs:
if objs:
objs = "[%s]" % objs
codedict["code"] = "#CODE %s %s \n%s\n\n%s" % (codedict['info'],
objs,
@ -486,7 +486,7 @@ class BatchCodeProcessor(object):
"""
# define the execution environment
environ = "setup_environ(settings_module)"
environdict = {"setup_environ":setup_environ,
environdict = {"setup_environ":setup_environ,
"settings_module":settings_module}
if extra_environ:
for key, value in extra_environ.items():
@ -499,11 +499,11 @@ class BatchCodeProcessor(object):
for obj in codedict['objs']:
code += "\ntry: %s.delete()\nexcept: pass" % obj
# execute the block
# execute the block
try:
exec(code, environdict)
except Exception:
etype, value, tb = sys.exc_info()
etype, value, tb = sys.exc_info()
fname = tb_filename(tb)
for tb in tb_iter(tb):
@ -512,15 +512,15 @@ class BatchCodeProcessor(object):
lineno = tb.tb_lineno - 1
err = ""
for iline, line in enumerate(code.split("\n")):
if iline == lineno:
err += "\n{w%02i{n: %s" % (iline + 1, line)
elif lineno - 5 < iline < lineno + 5:
err += "\n%02i: %s" % (iline + 1, line)
if iline == lineno:
err += "\n{w%02i{n: %s" % (iline + 1, line)
elif lineno - 5 < iline < lineno + 5:
err += "\n%02i: %s" % (iline + 1, line)
err += "\n".join(traceback.format_exception(etype, value, tb))
err += "\n".join(traceback.format_exception(etype, value, tb))
#errlist = format_exc().split('\n')
#if len(errlist) > 4:
# errlist = errlist[4:]
# errlist = errlist[4:]
#err = "\n".join(" %s" % line for line in errlist if line)
if debug: