Skip to content

Commit

Permalink
i18n: mark missing strings for translation
Browse files Browse the repository at this point in the history
  • Loading branch information
Samk13 committed Oct 23, 2024
1 parent 037e2ec commit a269e21
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 23 deletions.
31 changes: 16 additions & 15 deletions invenio_accounts/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#
# This file is part of Invenio.
# Copyright (C) 2015-2018 CERN.
# Copyright (C) 2024 KTH Royal Institute of Technology.
#
# Invenio is free software; you can redistribute it and/or modify it
# under the terms of the MIT License; see LICENSE file for more details.
Expand Down Expand Up @@ -45,14 +46,14 @@ class UserView(ModelView):
form_columns = ("email", "password", "active", "roles", "notification")

form_args = dict(
email=dict(label="Email", validators=[DataRequired()]),
email=dict(label=lazy_gettext("Email"), validators=[DataRequired()]),
password=dict(default=lambda: pwd.genword(length=12)),
)

form_extra_fields = {
"notification": BooleanField(
"Send User Notification",
description="Send the new user an email about their account.",
lazy_gettext("Send User Notification"),
description=lazy_gettext("Send the new user an email about their account."),
)
}

Expand Down Expand Up @@ -159,9 +160,9 @@ class SessionActivityView(ModelView):
list_all = ("user.id", "user.email", "sid_s", "created")

column_labels = {
"user.id": "User ID",
"user.email": "Email",
"sid_s": "Session ID",
"user.id": _("User ID"),
"user.email": _("Email"),
"sid_s": _("Session ID"),
}
column_list = list_all
column_filters = list_all
Expand All @@ -174,7 +175,7 @@ class SessionActivityView(ModelView):
def delete_model(self, model):
"""Delete a specific session."""
if SessionActivity.is_current(sid_s=model.sid_s):
flash("You could not remove your current session", "error")
flash(_("You could not remove your current session"), "error")
return
delete_session(sid_s=model.sid_s)
db.session.commit()
Expand All @@ -188,7 +189,7 @@ def action_delete(self, ids):
"""Delete selected sessions."""
is_current = any(SessionActivity.is_current(sid_s=id_) for id_ in ids)
if is_current:
flash("You could not remove your current session", "error")
flash(_("You could not remove your current session"), "error")
return
for id_ in ids:
delete_session(sid_s=id_)
Expand Down Expand Up @@ -218,34 +219,34 @@ class UserIdentityView(ModelView):
)

column_labels = {
"user.email": _("Email"),
"id_user": _("User ID"),
"user.email": lazy_gettext("Email"),
"id_user": lazy_gettext("User ID"),
}


session_adminview = {
"model": SessionActivity,
"modelview": SessionActivityView,
"category": _("User Management"),
"category": lazy_gettext("User Management"),
}

user_adminview = {
"model": User,
"modelview": UserView,
"category": _("User Management"),
"category": lazy_gettext("User Management"),
}

role_adminview = {
"model": Role,
"modelview": RoleView,
"category": _("User Management"),
"category": lazy_gettext("User Management"),
}

user_identity_adminview = {
"model": UserIdentity,
"modelview": UserIdentityView,
"category": _("User Management"),
"name": _("Linked account identities"),
"category": lazy_gettext("User Management"),
"name": lazy_gettext("Linked account identities"),
}

__all__ = (
Expand Down
16 changes: 10 additions & 6 deletions invenio_accounts/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# This file is part of Invenio.
# Copyright (C) 2016-2018 CERN.
# Copyright (C) 2021 TU Wien.
# Copyright (C) 2022 KTH Royal Institute of Technology
# Copyright (C) 2022-2024 KTH Royal Institute of Technology
#
# Invenio is free software; you can redistribute it and/or modify it
# under the terms of the MIT License; see LICENSE file for more details.
Expand All @@ -12,6 +12,7 @@

from datetime import timedelta

from invenio_i18n import gettext as _t
from invenio_i18n import lazy_gettext as _

from .profiles import UserPreferencesSchema, UserProfileSchema
Expand Down Expand Up @@ -201,19 +202,22 @@
SECURITY_CHANGE_URL = "/account/settings/password/"
"""URL endpoint for password change."""

SECURITY_MSG_LOCAL_LOGIN_DISABLED = ("Local login is disabled.", "error")
SECURITY_MSG_LOCAL_LOGIN_DISABLED = (_t("Local login is disabled."), "error")
"""The error to be displayed in REST login when local login is disabled."""

SECURITY_MSG_REGISTRATION_DISABLED = ("Registration is disabled.", "error")
SECURITY_MSG_REGISTRATION_DISABLED = (_t("Registration is disabled."), "error")
"""The error to be displayed in REST registration when it is disabled."""

SECURITY_MSG_PASSWORD_CHANGE_DISABLED = ("Password change is disabled.", "error")
SECURITY_MSG_PASSWORD_CHANGE_DISABLED = (_t("Password change is disabled."), "error")
"""The error to be displayed in REST password change when it is disabled."""

SECURITY_MSG_PASSWORD_RECOVERY_DISABLED = ("Password recovery is disabled.", "error")
SECURITY_MSG_PASSWORD_RECOVERY_DISABLED = (
_t("Password recovery is disabled."),
"error",
)
"""The error to be displayed in REST password recovery when it is disabled."""

SECURITY_MSG_PASSWORD_RESET_DISABLED = ("Password reset is disabled.", "error")
SECURITY_MSG_PASSWORD_RESET_DISABLED = (_t("Password reset is disabled."), "error")
"""The error to be displayed in REST password reset when it is disabled."""

REMEMBER_COOKIE_DURATION = timedelta(days=90)
Expand Down
6 changes: 4 additions & 2 deletions invenio_accounts/views/security.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#
# This file is part of Invenio.
# Copyright (C) 2017-2018 CERN.
# Copyright (C) 2024 KTH Royal Institute of Technology.
#
# Invenio is free software; you can redistribute it and/or modify it
# under the terms of the MIT License; see LICENSE file for more details.
Expand All @@ -12,6 +13,7 @@
from flask_login import login_required
from flask_security import current_user
from invenio_db import db
from invenio_i18n import gettext as _

from ..forms import RevokeForm
from ..models import SessionActivity
Expand Down Expand Up @@ -58,7 +60,7 @@ def revoke_session():
if not SessionActivity.is_current(sid_s=sid_s):
# if it's the same session doesn't show the message, otherwise
# the session will be still open without the database record
flash("Session {0} successfully removed.".format(sid_s), "success")
flash(_("Session {0} successfully removed.").format(sid_s), "success")
else:
flash("Unable to remove the session {0}.".format(sid_s), "error")
flash(_("Unable to remove the session {0}.").format(sid_s), "error")
return redirect(url_for("invenio_accounts.security"))

0 comments on commit a269e21

Please sign in to comment.