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

@ -1,5 +1,5 @@
"""
These managers handles the
These managers handles the
"""
import itertools
@ -18,7 +18,7 @@ def to_object(inp, objtype='player'):
Locates the object related to the given
playername or channel key. If input was already
the correct object, return it.
inp - the input object/string
inp - the input object/string
objtype - 'player' or 'channel'
"""
from src.players.models import PlayerDB
@ -30,43 +30,43 @@ def to_object(inp, objtype='player'):
else:
umatch = PlayerDB.objects.filter(user__username__iexact=inp)
if umatch:
return umatch[0]
return umatch[0]
elif objtype == 'external':
from src.comms.models import ExternalChannelConnection
if type (inp) == ExternalChannelConnection:
return inp
umatch = ExternalChannelConnection.objects.filter(db_key=inp)
if umatch:
return umatch[0]
return umatch[0]
else:
# have to import this way to avoid circular imports
from src.comms.models import Channel
#= ContentType.objects.get(app_label="comms",
from src.comms.models import Channel
#= ContentType.objects.get(app_label="comms",
# model="channel").model_class()
if type(inp) == Channel:
return inp
cmatch = Channel.objects.filter(db_key__iexact=inp)
if cmatch:
return cmatch[0]
return None
return None
#
# Msg manager
#
class MsgManager(models.Manager):
"""
This MsgManager implements methods for searching
This MsgManager implements methods for searching
and manipulating Messages directly from the database.
These methods will all return database objects
These methods will all return database objects
(or QuerySets) directly.
A Message represents one unit of communication, be it over a
A Message represents one unit of communication, be it over a
Channel or via some form of in-game mail system. Like an e-mail,
it always has a sender and can have any number of receivers (some
of which may be Channels).
of which may be Channels).
Evennia-specific:
get_message_by_id
get_messages_by_sender
@ -75,22 +75,22 @@ class MsgManager(models.Manager):
text_search
message_search (equivalent to ev.search_messages)
"""
def get_message_by_id(self, idnum):
"Retrieve message by its id."
"Retrieve message by its id."
try:
idnum = int(idnum)
return self.get(id=id)
except Exception:
return None
def get_messages_by_sender(self, player):
"""
Get all messages sent by one player
"""
player = to_object(player, objtype='player')
player = to_object(player, objtype='player')
if not player:
return None
return None
return self.filter(db_sender=player).exclude(db_hide_from_sender=True)
def get_messages_by_receiver(self, receiver):
@ -99,7 +99,7 @@ class MsgManager(models.Manager):
"""
receiver = to_object(receiver)
if not receiver:
return None
return None
return [msg for msg in self.all()
if receiver in msg.receivers
and receiver not in msg.hide_from_receivers]
@ -110,30 +110,30 @@ class MsgManager(models.Manager):
"""
channel = to_object(channel, objtype='channel')
if not channel:
return None
return None
return [msg for msg in self.all()
if channel in msg.channels
if channel in msg.channels
and channel not in msg.hide_from_channels]
#TODO add search limited by send_times
#TODO add search limited by send_times
def text_search(self, searchstring, filterdict=None):
"""
Returns all messages that contain the matching
search string. To avoid too many results, and also
since this can be a very computing-
heavy operation, it's recommended to be filtered
by at least channel or sender/receiver.
by at least channel or sender/receiver.
searchstring - string to search for
filterdict -
{'channels':[list],
'senders':[list],
'receivers':[list]}
lists can contain either the name/keys of the
objects or the actual objects to filter by.
"""
objects or the actual objects to filter by.
"""
if filterdict:
# obtain valid objects for all filters
# obtain valid objects for all filters
channels = [chan for chan in
[to_object(chan, objtype='channel')
for chan in filterdict.get('channels',[])]
@ -141,23 +141,23 @@ class MsgManager(models.Manager):
senders = [sender for sender in
[to_object(sender)
for sender in filterdict.get('senders',[])]
if sender]
if sender]
receivers = [receiver for receiver in
[to_object(receiver)
for receiver in filterdict.get('receivers',[])]
if receiver]
# filter the messages lazily using the filter objects
# filter the messages lazily using the filter objects
msgs = []
for sender in senders:
msgs = list(sender.message_set.filter(
db_message__icontains=searchstring))
db_message__icontains=searchstring))
for receiver in receivers:
rec_msgs = receiver.message_set.filter(
db_message__icontains=searchstring)
if msgs:
msgs = [msg for msg in rec_msgs if msg in msgs]
else:
msgs = rec_msgs
msgs = rec_msgs
for channel in channels:
chan_msgs = list(channel.message_set.filter(
db_message__icontains=searchstring))
@ -168,21 +168,21 @@ class MsgManager(models.Manager):
return list(set(msgs))
return list(self.all().filter(db_message__icontains=searchstring))
def message_search(self, sender=None, receiver=None, channel=None, freetext=None, dbref=None):
def message_search(self, sender=None, receiver=None, channel=None, freetext=None, dbref=None):
"""
Search the message database for particular messages. At least one
of the arguments must be given to do a search.
Search the message database for particular messages. At least one
of the arguments must be given to do a search.
sender - get messages sent by a particular player
receiver - get messages received by a certain player or players
channel - get messages sent to a particular channel or channels
freetext - Search for a text string in a message.
freetext - Search for a text string in a message.
NOTE: This can potentially be slow, so make sure to supply
one of the other arguments to limit the search.
dbref - (int) the exact database id of the message. This will override
one of the other arguments to limit the search.
dbref - (int) the exact database id of the message. This will override
all other search crieteria since it's unique and
always gives a list with only one match.
"""
"""
if dbref:
return self.filter(id=dbref)
if freetext:
@ -199,12 +199,12 @@ class MsgManager(models.Manager):
msgs = []
if sender:
msgs = self.get_messages_by_sender(sender)
if receiver:
if receiver:
rec_msgs = self.get_messages_by_receiver(receiver)
if msgs:
msgs = [msg for msg in rec_msgs if msg in msgs]
else:
msgs = rec_msgs
msgs = rec_msgs
if channel:
chan_msgs = self.get_messaqge_by_channel(channel)
if msgs:
@ -212,20 +212,20 @@ class MsgManager(models.Manager):
else:
msgs = chan_msgs
return msgs
#
# Channel manager
#
class ChannelManager(models.Manager):
"""
This ChannelManager implements methods for searching
This ChannelManager implements methods for searching
and manipulating Channels directly from the database.
These methods will all return database objects
These methods will all return database objects
(or QuerySets) directly.
A Channel is an in-game venue for communication. It's
A Channel is an in-game venue for communication. It's
essentially representation of a re-sender: Users sends
Messages to the Channel, and the Channel re-sends those
messages to all users subscribed to the Channel.
@ -248,9 +248,9 @@ class ChannelManager(models.Manager):
def get_channel(self, channelkey):
"""
Return the channel object if given its key.
Also searches its aliases.
Also searches its aliases.
"""
# first check the channel key
# first check the channel key
channels = self.filter(db_key__iexact=channelkey)
if not channels:
# also check aliases
@ -258,23 +258,23 @@ class ChannelManager(models.Manager):
if channelkey in channel.aliases]
if channels:
return channels[0]
return None
return None
def del_channel(self, channelkey):
"""
Delete channel matching channelkey.
Also cleans up channelhandler.
Also cleans up channelhandler.
"""
channels = self.filter(db_key__iexact=channelkey)
if not channels:
# no aliases allowed for deletion.
return False
return False
for channel in channels:
channel.delete()
channel.delete()
from src.comms.channelhandler import CHANNELHANDLER
CHANNELHANDLER.update()
return None
return None
def get_all_connections(self, channel):
"""
Return the connections of all players listening
@ -282,9 +282,9 @@ class ChannelManager(models.Manager):
"""
# import here to avoid circular imports
#from src.comms.models import PlayerChannelConnection
PlayerChannelConnection = ContentType.objects.get(app_label="comms",
PlayerChannelConnection = ContentType.objects.get(app_label="comms",
model="playerchannelconnection").model_class()
ExternalChannelConnection = ContentType.objects.get(app_label="comms",
ExternalChannelConnection = ContentType.objects.get(app_label="comms",
model="externalchannelconnection").model_class()
return itertools.chain(PlayerChannelConnection.objects.get_all_connections(channel),
ExternalChannelConnection.objects.get_all_connections(channel))
@ -297,10 +297,10 @@ class ChannelManager(models.Manager):
"""
channels = []
try:
# try an id match first
# try an id match first
dbref = int(ostring.strip('#'))
channels = self.filter(id=dbref)
except Exception:
except Exception:
pass
if not channels:
# no id match. Search on the key.
@ -308,17 +308,17 @@ class ChannelManager(models.Manager):
if not channels:
# still no match. Search by alias.
channels = [channel for channel in self.all() if ostring.lower in [a.lower for a in channel.aliases]]
return channels
return channels
#
# PlayerChannelConnection manager
#
class PlayerChannelConnectionManager(models.Manager):
"""
This PlayerChannelConnectionManager implements methods for searching
This PlayerChannelConnectionManager implements methods for searching
and manipulating PlayerChannelConnections directly from the database.
These methods will all return database objects
These methods will all return database objects
(or QuerySets) directly.
A PlayerChannelConnection defines a user's subscription to an in-game
@ -333,7 +333,7 @@ class PlayerChannelConnectionManager(models.Manager):
break_connection
"""
def get_all_player_connections(self, player):
"Get all connections that the given player has."
player = to_object(player)
@ -346,18 +346,18 @@ class PlayerChannelConnectionManager(models.Manager):
if player and channel:
return self.filter(db_player=player).filter(db_channel=channel).count() > 0
return False
def get_all_connections(self, channel):
"""
Get all connections for a channel
"""
channel = to_object(channel, objtype='channel')
return self.filter(db_channel=channel)
def create_connection(self, player, channel):
"""
Connect a player to a channel. player and channel
can be actual objects or keystrings.
can be actual objects or keystrings.
"""
player = to_object(player)
channel = to_object(channel, objtype='channel')
@ -379,13 +379,13 @@ class PlayerChannelConnectionManager(models.Manager):
class ExternalChannelConnectionManager(models.Manager):
"""
This ExternalChannelConnectionManager implements methods for searching
This ExternalChannelConnectionManager implements methods for searching
and manipulating HelpEntries directly from the database.
These methods will all return database objects
These methods will all return database objects
(or QuerySets) directly.
An ExternalChannelConnetion describes the connection between an in-game
An ExternalChannelConnetion describes the connection between an in-game
channel and some external source, such as an IRC or IMC channel.
Evennia-specific:
@ -394,9 +394,9 @@ class ExternalChannelConnectionManager(models.Manager):
get_all_connections
create_connection
break_connection
"""
def get_all_external_connections(self, external):
"Get all connections that the given as external."
external = to_object(external, objtype='external')
@ -409,18 +409,18 @@ class ExternalChannelConnectionManager(models.Manager):
if external and channel:
return self.filter(db_external_key=external).filter(db_channel=channel).count() > 0
return False
def get_all_connections(self, channel):
"""
Get all connections for a channel
"""
channel = to_object(channel, objtype='channel')
return self.filter(db_channel=channel)
def create_connection(self, external, channel, config=""):
"""
Connect a external to a channel. external and channel
can be actual objects or keystrings.
can be actual objects or keystrings.
"""
channel = to_object(channel, objtype='channel')
if not channel: