misc: modify strings for translation (#47773)

This commit is contained in:
Benjamin Dauvergne 2020-10-16 09:14:22 +02:00
parent 11869fb4b8
commit 13bb51ecef
7 changed files with 28 additions and 27 deletions

View File

@ -18,7 +18,7 @@ from collections import namedtuple
from django.core.exceptions import ValidationError
from django.core.validators import MinValueValidator
from django.utils import six
from django.utils.translation import ugettext_lazy as _
from django.utils.translation import ugettext_lazy as _, pgettext_lazy
from django.utils.text import slugify
from django.db import models
from django.contrib.contenttypes.models import ContentType
@ -423,9 +423,9 @@ GenericRelation(Permission,
CHANGE_PASSWORD_OP = Operation(name=_('Change password'), slug='change_password')
RESET_PASSWORD_OP = Operation(name=_('Reset password'), slug='reset_password')
ACTIVATE_OP = Operation(name=_('Activate'), slug='activate')
CHANGE_EMAIL_OP = Operation(name=_('Change email'), slug='change_email')
RESET_PASSWORD_OP = Operation(name=_('Password reset'), slug='reset_password')
ACTIVATE_OP = Operation(name=_('Activation'), slug='activate')
CHANGE_EMAIL_OP = Operation(name=pgettext_lazy('operation', 'Change email'), slug='change_email')
MANAGE_MEMBERS_OP = Operation(name=_('Manage role members'), slug='manage_members')
MANAGE_AUTHORIZATIONS_OP = Operation(
name=_('Manage service consents'), slug='manage_authorizations')

View File

@ -80,12 +80,12 @@ class SearchEngine:
if not hasattr(self, method_name):
return
yield from getattr(self, method_name)(lexem[len(prefix) + 1 :])
yield from getattr(self, method_name)(lexem[len(prefix) + 1:])
@classmethod
def documentation(cls):
yield _('You can use quote around to preserve spaces.')
yield _('You can use colon terminated prefixes to make special searches.')
yield _('You can use colon terminated prefixes to make special searches, '
'and you can use quote around the suffix to preserve spaces.')
for name in dir(cls):
documentation = getattr(getattr(cls, name), 'documentation', None)
if documentation:
@ -126,11 +126,11 @@ to users with this email address.</tt>.'''
)
def search_by_username(self, lexem):
users = User.objects.filter(username__startswith=lexem)
yield (self.query_for_users(users) | Q(data__username__startswith=lexem.lower()))
users = User.objects.filter(username__iexact=lexem)
yield (self.query_for_users(users) | Q(data__username__iexact=lexem.lower()))
search_by_username.documentation = _(
'''\
You can use <tt>username:john</tt> to find all events related \
to users whose username starts with <tt>john</tt>.'''
to users whose username is <tt>john</tt>.'''
)

View File

@ -50,11 +50,11 @@ def login_method_label(how):
if how.startswith('password'):
return _('password')
elif how == 'fc':
return _('FranceConnect')
return 'FranceConnect'
elif how == 'saml':
return _('SAML')
return 'SAML'
elif how == 'oidc':
return _('OpenIDConnect')
return 'OpenIDConnect'
elif how:
return how
else:
@ -212,7 +212,7 @@ class UserEdit(EventTypeWithService):
class UserDeletion(EventTypeWithService):
name = 'user.deletion'
label = _('deletion')
label = _('user deletion')
@classmethod
def record(cls, user, session, service):
@ -235,7 +235,7 @@ class UserServiceSSO(EventTypeWithService):
class UserServiceSSOAuthorization(EventTypeWithService):
name = 'user.service.sso.authorization'
label = _('consentment to single sign on')
label = _('consent to single sign on')
@classmethod
def record(cls, user, session, service, **kwargs):
@ -249,7 +249,7 @@ class UserServiceSSOAuthorization(EventTypeWithService):
class UserServiceSSOUnauthorization(EventTypeWithService):
name = 'user.service.sso.unauthorization'
label = _('remove consentment to single sign on')
label = _('remove consent to single sign on')
@classmethod
def record(cls, user, session, service):

View File

@ -248,11 +248,12 @@ class ManagerUserSSOAuthorizationDeletion(EventTypeWithService):
__, user = event.get_typed_references(None, User)
service_name = cls.get_service_name(event)
if context and context == user:
return _('deletion of authorization of single sign on with "%s" by administrator') % service_name
return _('deletion of authorization of single sign on with "{service}" by administrator').format(
service=service_name)
elif user:
return _('deletion of authorization of single sign on with "%s" of user "%s"') % (
service_name,
user.get_full_name(),
return _('deletion of authorization of single sign on with "{service}" of user "{user}"').format(
service=service_name,
user=user.get_full_name(),
)
return super().get_message(event, context)
@ -264,7 +265,7 @@ class RoleEventsMixin(EventTypeDefinition):
references = [role] + references
data = data or {}
data.update(
{'role_name': str(role), 'role_uuid': role.uuid,}
{'role_name': str(role), 'role_uuid': role.uuid}
)
super().record(
user=user, session=session, references=references, data=data,
@ -300,9 +301,9 @@ class ManagerRoleEdit(RoleEventsMixin):
new = event.get_data('new')
edited_attributes = ', '.join(get_attributes_label(new)) or ''
if context != role:
return _('edit of role "%s" (%s)') % (role, edited_attributes)
return _('edit of role "{role}" ({change})').format(role=role, change=edited_attributes)
else:
return _('edit (%s)') % edited_attributes
return _('edit ({change})').format(change=edited_attributes)
class ManagerRoleDeletion(RoleEventsMixin):

View File

@ -1,4 +1,4 @@
{% load i18n %}{% blocktrans with hostname=request.get_host %}A new account was created for you on {{ hostname }}{% endblocktrans %}
{% load i18n %}{% blocktrans with hostname=request.get_host context "api" %}A new account was created for you on {{ hostname }}{% endblocktrans %}
{% if data.username %}
{% trans "Username" %} : {{ data.username }}{% endif %}
{% trans "Email" %} : {{ data.email }}

View File

@ -1 +1 @@
{% load i18n %}{% blocktrans with hostname=request.get_host %}Your account was created on {{ hostname }}{% endblocktrans %}
{% load i18n %}{% blocktrans with hostname=request.get_host context "api" %}Your account was created on {{ hostname }}{% endblocktrans %}

View File

@ -305,7 +305,7 @@ def test_global_journal(app, superuser, events):
'user': 'Johnny doe',
},
{
'message': 'deletion',
'message': 'user deletion',
'timestamp': 'Jan. 1, 2020, 11 a.m.',
'type': 'user.deletion',
'user': 'Johnny doe',
@ -532,7 +532,7 @@ def test_user_journal(app, superuser, events):
'user': 'Johnny doe',
},
{
'message': 'deletion',
'message': 'user deletion',
'timestamp': 'Jan. 1, 2020, 11 a.m.',
'type': 'user.deletion',
'user': 'Johnny doe',