i18n
This commit is contained in:
parent
56ff8faacb
commit
95fe5c060f
5 changed files with 32 additions and 30 deletions
|
|
@ -275,11 +275,11 @@ class DefaultAccount(AccountDB, metaclass=TypeclassBase):
|
||||||
raise RuntimeError("Session not found")
|
raise RuntimeError("Session not found")
|
||||||
if self.get_puppet(session) == obj:
|
if self.get_puppet(session) == obj:
|
||||||
# already puppeting this object
|
# already puppeting this object
|
||||||
self.msg("You are already puppeting this object.")
|
self.msg(_("You are already puppeting this object.")
|
||||||
return
|
return
|
||||||
if not obj.access(self, "puppet"):
|
if not obj.access(self, "puppet"):
|
||||||
# no access
|
# no access
|
||||||
self.msg(f"You don't have permission to puppet '{obj.key}'.")
|
self.msg(_(f"You don't have permission to puppet '{obj.key}'.")
|
||||||
return
|
return
|
||||||
if obj.account:
|
if obj.account:
|
||||||
# object already puppeted
|
# object already puppeted
|
||||||
|
|
@ -295,12 +295,12 @@ class DefaultAccount(AccountDB, metaclass=TypeclassBase):
|
||||||
else:
|
else:
|
||||||
txt1 = f"Taking over |c{obj.name}|n from another of your sessions."
|
txt1 = f"Taking over |c{obj.name}|n from another of your sessions."
|
||||||
txt2 = f"|c{obj.name}|n|R is now acted from another of your sessions.|n"
|
txt2 = f"|c{obj.name}|n|R is now acted from another of your sessions.|n"
|
||||||
self.msg(txt1, session=session)
|
self.msg(_(txt1), session=session)
|
||||||
self.msg(txt2, session=obj.sessions.all())
|
self.msg(_(txt2), session=obj.sessions.all())
|
||||||
self.unpuppet_object(obj.sessions.get())
|
self.unpuppet_object(obj.sessions.get())
|
||||||
elif obj.account.is_connected:
|
elif obj.account.is_connected:
|
||||||
# controlled by another account
|
# controlled by another account
|
||||||
self.msg(f"|c{obj.key}|R is already puppeted by another Account.")
|
self.msg(_(f"|c{obj.key}|R is already puppeted by another Account."))
|
||||||
return
|
return
|
||||||
|
|
||||||
# do the puppeting
|
# do the puppeting
|
||||||
|
|
@ -496,7 +496,7 @@ class DefaultAccount(AccountDB, metaclass=TypeclassBase):
|
||||||
|
|
||||||
# See if authentication is currently being throttled
|
# See if authentication is currently being throttled
|
||||||
if ip and LOGIN_THROTTLE.check(ip):
|
if ip and LOGIN_THROTTLE.check(ip):
|
||||||
errors.append("Too many login failures; please try again in a few minutes.")
|
errors.append(_("Too many login failures; please try again in a few minutes."))
|
||||||
|
|
||||||
# With throttle active, do not log continued hits-- it is a
|
# With throttle active, do not log continued hits-- it is a
|
||||||
# waste of storage and can be abused to make your logs harder to
|
# waste of storage and can be abused to make your logs harder to
|
||||||
|
|
@ -508,8 +508,8 @@ class DefaultAccount(AccountDB, metaclass=TypeclassBase):
|
||||||
if banned:
|
if banned:
|
||||||
# this is a banned IP or name!
|
# this is a banned IP or name!
|
||||||
errors.append(
|
errors.append(
|
||||||
"|rYou have been banned and cannot continue from here."
|
_("|rYou have been banned and cannot continue from here."
|
||||||
"\nIf you feel this ban is in error, please email an admin.|x"
|
"\nIf you feel this ban is in error, please email an admin.|x")
|
||||||
)
|
)
|
||||||
logger.log_sec(f"Authentication Denied (Banned): {username} (IP: {ip}).")
|
logger.log_sec(f"Authentication Denied (Banned): {username} (IP: {ip}).")
|
||||||
LOGIN_THROTTLE.update(ip, "Too many sightings of banned artifact.")
|
LOGIN_THROTTLE.update(ip, "Too many sightings of banned artifact.")
|
||||||
|
|
@ -519,7 +519,7 @@ class DefaultAccount(AccountDB, metaclass=TypeclassBase):
|
||||||
account = authenticate(username=username, password=password)
|
account = authenticate(username=username, password=password)
|
||||||
if not account:
|
if not account:
|
||||||
# User-facing message
|
# User-facing message
|
||||||
errors.append("Username and/or password is incorrect.")
|
errors.append(_("Username and/or password is incorrect."))
|
||||||
|
|
||||||
# Log auth failures while throttle is inactive
|
# Log auth failures while throttle is inactive
|
||||||
logger.log_sec(f"Authentication Failure: {username} (IP: {ip}).")
|
logger.log_sec(f"Authentication Failure: {username} (IP: {ip}).")
|
||||||
|
|
@ -688,7 +688,7 @@ class DefaultAccount(AccountDB, metaclass=TypeclassBase):
|
||||||
ip = kwargs.get("ip", "")
|
ip = kwargs.get("ip", "")
|
||||||
if ip and CREATION_THROTTLE.check(ip):
|
if ip and CREATION_THROTTLE.check(ip):
|
||||||
errors.append(
|
errors.append(
|
||||||
"You are creating too many accounts. Please log into an existing account."
|
_("You are creating too many accounts. Please log into an existing account.")
|
||||||
)
|
)
|
||||||
return None, errors
|
return None, errors
|
||||||
|
|
||||||
|
|
@ -717,8 +717,8 @@ class DefaultAccount(AccountDB, metaclass=TypeclassBase):
|
||||||
if banned:
|
if banned:
|
||||||
# this is a banned IP or name!
|
# this is a banned IP or name!
|
||||||
string = (
|
string = (
|
||||||
"|rYou have been banned and cannot continue from here."
|
_("|rYou have been banned and cannot continue from here."
|
||||||
"\nIf you feel this ban is in error, please email an admin.|x"
|
"\nIf you feel this ban is in error, please email an admin.|x")
|
||||||
)
|
)
|
||||||
errors.append(string)
|
errors.append(string)
|
||||||
return None, errors
|
return None, errors
|
||||||
|
|
@ -733,7 +733,7 @@ class DefaultAccount(AccountDB, metaclass=TypeclassBase):
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
errors.append(
|
errors.append(
|
||||||
"There was an error creating the Account. If this problem persists, contact an admin."
|
_("There was an error creating the Account. If this problem persists, contact an admin.")
|
||||||
)
|
)
|
||||||
logger.log_trace()
|
logger.log_trace()
|
||||||
return None, errors
|
return None, errors
|
||||||
|
|
@ -785,7 +785,7 @@ class DefaultAccount(AccountDB, metaclass=TypeclassBase):
|
||||||
# We are in the middle between logged in and -not, so we have
|
# We are in the middle between logged in and -not, so we have
|
||||||
# to handle tracebacks ourselves at this point. If we don't,
|
# to handle tracebacks ourselves at this point. If we don't,
|
||||||
# we won't see any errors at all.
|
# we won't see any errors at all.
|
||||||
errors.append("An error occurred. Please e-mail an admin if the problem persists.")
|
errors.append(_("An error occurred. Please e-mail an admin if the problem persists."))
|
||||||
logger.log_trace()
|
logger.log_trace()
|
||||||
|
|
||||||
# Update the throttle to indicate a new account was created from this IP
|
# Update the throttle to indicate a new account was created from this IP
|
||||||
|
|
@ -1260,14 +1260,14 @@ class DefaultAccount(AccountDB, metaclass=TypeclassBase):
|
||||||
try:
|
try:
|
||||||
self.puppet_object(session, self.db._last_puppet)
|
self.puppet_object(session, self.db._last_puppet)
|
||||||
except RuntimeError:
|
except RuntimeError:
|
||||||
self.msg("The Character does not exist.")
|
self.msg(_("The Character does not exist."))
|
||||||
return
|
return
|
||||||
elif _MULTISESSION_MODE == 1:
|
elif _MULTISESSION_MODE == 1:
|
||||||
# in this mode all sessions connect to the same puppet.
|
# in this mode all sessions connect to the same puppet.
|
||||||
try:
|
try:
|
||||||
self.puppet_object(session, self.db._last_puppet)
|
self.puppet_object(session, self.db._last_puppet)
|
||||||
except RuntimeError:
|
except RuntimeError:
|
||||||
self.msg("The Character does not exist.")
|
self.msg(_("The Character does not exist."))
|
||||||
return
|
return
|
||||||
elif _MULTISESSION_MODE in (2, 3):
|
elif _MULTISESSION_MODE in (2, 3):
|
||||||
# In this mode we by default end up at a character selection
|
# In this mode we by default end up at a character selection
|
||||||
|
|
@ -1305,7 +1305,7 @@ class DefaultAccount(AccountDB, metaclass=TypeclassBase):
|
||||||
|
|
||||||
"""
|
"""
|
||||||
reason = f" ({reason if reason else ''})"
|
reason = f" ({reason if reason else ''})"
|
||||||
self._send_to_connect_channel(f"|R{self.key} disconnected{reason}|n")
|
self._send_to_connect_channel(_(f"|R{self.key} disconnected{reason}|n"))
|
||||||
|
|
||||||
def at_post_disconnect(self, **kwargs):
|
def at_post_disconnect(self, **kwargs):
|
||||||
"""
|
"""
|
||||||
|
|
@ -1411,7 +1411,7 @@ class DefaultAccount(AccountDB, metaclass=TypeclassBase):
|
||||||
if hasattr(target, "return_appearance"):
|
if hasattr(target, "return_appearance"):
|
||||||
return target.return_appearance(self)
|
return target.return_appearance(self)
|
||||||
else:
|
else:
|
||||||
return "{} has no in-game appearance.".format(target)
|
return _(f"{target} has no in-game appearance.")
|
||||||
else:
|
else:
|
||||||
# list of targets - make list to disconnect from db
|
# list of targets - make list to disconnect from db
|
||||||
characters = list(tar for tar in target if tar) if target else []
|
characters = list(tar for tar in target if tar) if target else []
|
||||||
|
|
@ -1454,7 +1454,7 @@ class DefaultAccount(AccountDB, metaclass=TypeclassBase):
|
||||||
if is_su or len(characters) < charmax:
|
if is_su or len(characters) < charmax:
|
||||||
if not characters:
|
if not characters:
|
||||||
result.append(
|
result.append(
|
||||||
"\n\n You don't have any characters yet. See |whelp @charcreate|n for creating one."
|
_("\n\n You don't have any characters yet. See |whelp @charcreate|n for creating one.")
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
result.append("\n |w@charcreate <name> [=description]|n - create new character")
|
result.append("\n |w@charcreate <name> [=description]|n - create new character")
|
||||||
|
|
@ -1534,7 +1534,7 @@ class DefaultGuest(DefaultAccount):
|
||||||
|
|
||||||
# check if guests are enabled.
|
# check if guests are enabled.
|
||||||
if not settings.GUEST_ENABLED:
|
if not settings.GUEST_ENABLED:
|
||||||
errors.append("Guest accounts are not enabled on this server.")
|
errors.append(_("Guest accounts are not enabled on this server."))
|
||||||
return None, errors
|
return None, errors
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
|
@ -1544,7 +1544,7 @@ class DefaultGuest(DefaultAccount):
|
||||||
username = name
|
username = name
|
||||||
break
|
break
|
||||||
if not username:
|
if not username:
|
||||||
errors.append("All guest accounts are in use. Please try again later.")
|
errors.append(_("All guest accounts are in use. Please try again later."))
|
||||||
if ip:
|
if ip:
|
||||||
LOGIN_THROTTLE.update(ip, "Too many requests for Guest access.")
|
LOGIN_THROTTLE.update(ip, "Too many requests for Guest access.")
|
||||||
return None, errors
|
return None, errors
|
||||||
|
|
@ -1572,7 +1572,7 @@ class DefaultGuest(DefaultAccount):
|
||||||
# We are in the middle between logged in and -not, so we have
|
# We are in the middle between logged in and -not, so we have
|
||||||
# to handle tracebacks ourselves at this point. If we don't,
|
# to handle tracebacks ourselves at this point. If we don't,
|
||||||
# we won't see any errors at all.
|
# we won't see any errors at all.
|
||||||
errors.append("An error occurred. Please e-mail an admin if the problem persists.")
|
errors.append(_("An error occurred. Please e-mail an admin if the problem persists."))
|
||||||
logger.log_trace()
|
logger.log_trace()
|
||||||
return None, errors
|
return None, errors
|
||||||
|
|
||||||
|
|
@ -1589,7 +1589,7 @@ class DefaultGuest(DefaultAccount):
|
||||||
overriding the call (unused by default).
|
overriding the call (unused by default).
|
||||||
|
|
||||||
"""
|
"""
|
||||||
self._send_to_connect_channel(f"|G{self.key} connected|n")
|
self._send_to_connect_channel(_(f"|G{self.key} connected|n"))
|
||||||
self.puppet_object(session, self.db._last_puppet)
|
self.puppet_object(session, self.db._last_puppet)
|
||||||
|
|
||||||
def at_server_shutdown(self):
|
def at_server_shutdown(self):
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,7 @@ from evennia.accounts.accounts import DefaultAccount
|
||||||
from evennia.scripts.scripts import DefaultScript
|
from evennia.scripts.scripts import DefaultScript
|
||||||
from evennia.utils import search
|
from evennia.utils import search
|
||||||
from evennia.utils import utils
|
from evennia.utils import utils
|
||||||
|
from django.utils.translation import gettext as _
|
||||||
|
|
||||||
_IDLE_TIMEOUT = settings.IDLE_TIMEOUT
|
_IDLE_TIMEOUT = settings.IDLE_TIMEOUT
|
||||||
|
|
||||||
|
|
@ -328,7 +329,7 @@ class IRCBot(Bot):
|
||||||
chstr = f"{self.db.irc_channel} ({self.db.irc_network}:{self.db.irc_port})"
|
chstr = f"{self.db.irc_channel} ({self.db.irc_network}:{self.db.irc_port})"
|
||||||
nicklist = ", ".join(sorted(kwargs["nicklist"], key=lambda n: n.lower()))
|
nicklist = ", ".join(sorted(kwargs["nicklist"], key=lambda n: n.lower()))
|
||||||
for obj in self._nicklist_callers:
|
for obj in self._nicklist_callers:
|
||||||
obj.msg(f"Nicks at {chstr}:\n {nicklist}")
|
obj.msg(_(f"Nicks at {chstr}:\n {nicklist}")
|
||||||
self._nicklist_callers = []
|
self._nicklist_callers = []
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
@ -337,7 +338,7 @@ class IRCBot(Bot):
|
||||||
if hasattr(self, "_ping_callers") and self._ping_callers:
|
if hasattr(self, "_ping_callers") and self._ping_callers:
|
||||||
chstr = f"{self.db.irc_channel} ({self.db.irc_network}:{self.db.irc_port})"
|
chstr = f"{self.db.irc_channel} ({self.db.irc_network}:{self.db.irc_port})"
|
||||||
for obj in self._ping_callers:
|
for obj in self._ping_callers:
|
||||||
obj.msg(f"IRC ping return from {chstr} took {kwargs['timing']}s.")
|
obj.msg(_(f"IRC ping return from {chstr} took {kwargs['timing']}s.")
|
||||||
self._ping_callers = []
|
self._ping_callers = []
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -131,7 +131,7 @@ class HelpEntryManager(TypedObjectManager):
|
||||||
for topic in topics:
|
for topic in topics:
|
||||||
topic.help_category = default_category
|
topic.help_category = default_category
|
||||||
topic.save()
|
topic.save()
|
||||||
string = "Help database moved to category %s" % default_category
|
string = _(f"Help database moved to category {default_category}")
|
||||||
logger.log_info(string)
|
logger.log_info(string)
|
||||||
|
|
||||||
def search_help(self, ostring, help_category=None):
|
def search_help(self, ostring, help_category=None):
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@ from django.contrib import admin
|
||||||
from evennia.typeclasses.admin import AttributeInline, TagInline
|
from evennia.typeclasses.admin import AttributeInline, TagInline
|
||||||
from evennia.objects.models import ObjectDB
|
from evennia.objects.models import ObjectDB
|
||||||
from django.contrib.admin.utils import flatten_fieldsets
|
from django.contrib.admin.utils import flatten_fieldsets
|
||||||
|
from django.utils.translation import gettext as _
|
||||||
|
|
||||||
class ObjectAttributeInline(AttributeInline):
|
class ObjectAttributeInline(AttributeInline):
|
||||||
"""
|
"""
|
||||||
|
|
@ -61,7 +61,7 @@ class ObjectCreateForm(forms.ModelForm):
|
||||||
required=False,
|
required=False,
|
||||||
widget=forms.TextInput(attrs={"size": "78"}),
|
widget=forms.TextInput(attrs={"size": "78"}),
|
||||||
help_text="Most non-character objects don't need a cmdset"
|
help_text="Most non-character objects don't need a cmdset"
|
||||||
" and can leave this field blank.",
|
" and can leave this field blank.")
|
||||||
)
|
)
|
||||||
raw_id_fields = ("db_destination", "db_location", "db_home")
|
raw_id_fields = ("db_destination", "db_location", "db_home")
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -15,6 +15,7 @@ from django.core.exceptions import ValidationError as _error
|
||||||
from django.core.validators import validate_email as _val_email
|
from django.core.validators import validate_email as _val_email
|
||||||
from evennia.utils.ansi import strip_ansi
|
from evennia.utils.ansi import strip_ansi
|
||||||
from evennia.utils.utils import string_partial_matching as _partial
|
from evennia.utils.utils import string_partial_matching as _partial
|
||||||
|
from django.utils.translation import gettext as _
|
||||||
|
|
||||||
_TZ_DICT = {str(tz): _pytz.timezone(tz) for tz in _pytz.common_timezones}
|
_TZ_DICT = {str(tz): _pytz.timezone(tz) for tz in _pytz.common_timezones}
|
||||||
|
|
||||||
|
|
@ -58,7 +59,7 @@ def datetime(entry, option_key="Datetime", account=None, from_tz=None, **kwargs)
|
||||||
|
|
||||||
"""
|
"""
|
||||||
if not entry:
|
if not entry:
|
||||||
raise ValueError(f"No {option_key} entered!")
|
raise ValueError(_(f"No {option_key} entered!"))
|
||||||
if not from_tz:
|
if not from_tz:
|
||||||
from_tz = _pytz.UTC
|
from_tz = _pytz.UTC
|
||||||
if account:
|
if account:
|
||||||
|
|
@ -66,7 +67,7 @@ def datetime(entry, option_key="Datetime", account=None, from_tz=None, **kwargs)
|
||||||
try:
|
try:
|
||||||
from_tz = _pytz.timezone(acct_tz)
|
from_tz = _pytz.timezone(acct_tz)
|
||||||
except Exception as err:
|
except Exception as err:
|
||||||
raise ValueError(f"Timezone string '{acct_tz}' is not a valid timezone ({err})")
|
raise ValueError(_(f"Timezone string '{acct_tz}' is not a valid timezone ({err})"))
|
||||||
else:
|
else:
|
||||||
from_tz = _pytz.UTC
|
from_tz = _pytz.UTC
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue