Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

i18n: Mark Missing Strings for Translation #493

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 20 additions & 19 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 All @@ -74,8 +75,8 @@ def after_model_change(self, form, User, is_created):

@action(
"inactivate",
_("Inactivate"),
_("Are you sure you want to inactivate selected users?"),
lazy_gettext("Inactivate"),
lazy_gettext("Are you sure you want to inactivate selected users?"),
)
@commit
def action_inactivate(self, ids):
Expand All @@ -99,8 +100,8 @@ def action_inactivate(self, ids):

@action(
"activate",
_("Activate"),
_("Are you sure you want to activate selected users?"),
lazy_gettext("Activate"),
lazy_gettext("Are you sure you want to activate selected users?"),
)
@commit
def action_activate(self, ids):
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": lazy_gettext("User ID"),
"user.email": lazy_gettext("Email"),
"sid_s": lazy_gettext("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"))
Loading