diff --git a/invenio_rdm_records/assets/semantic-ui/js/invenio_rdm_records/src/deposit/fields/FileUploader/FileModification/FileModification.js b/invenio_rdm_records/assets/semantic-ui/js/invenio_rdm_records/src/deposit/fields/FileUploader/FileModification/FileModification.js index aec366513..60d85cfa7 100644 --- a/invenio_rdm_records/assets/semantic-ui/js/invenio_rdm_records/src/deposit/fields/FileUploader/FileModification/FileModification.js +++ b/invenio_rdm_records/assets/semantic-ui/js/invenio_rdm_records/src/deposit/fields/FileUploader/FileModification/FileModification.js @@ -1,10 +1,11 @@ // This file is part of InvenioRDM // Copyright (C) 2025. +// Copyright (C) 2026 KTH Royal Institute of Technology. // // Invenio RDM Records is free software; you can redistribute it and/or modify it // under the terms of the MIT License; see LICENSE file for more details. -import { i18next } from "@translations/invenio_app_rdm/i18next"; +import { i18next } from "@translations/invenio_rdm_records/i18next"; import PropTypes from "prop-types"; import React, { useState } from "react"; import { Button, Icon, Popup } from "semantic-ui-react"; diff --git a/invenio_rdm_records/oaiserver/services/errors.py b/invenio_rdm_records/oaiserver/services/errors.py index 5c4a1e2c2..a5fc62f4b 100644 --- a/invenio_rdm_records/oaiserver/services/errors.py +++ b/invenio_rdm_records/oaiserver/services/errors.py @@ -2,6 +2,7 @@ # # This file is part of Invenio. # Copyright (C) 2022-2023 Graz University of Technology. +# Copyright (C) 2026 KTH Royal Institute of Technology. # # Invenio-RDM-Records is free software; you can redistribute it and/or modify # under the terms of the MIT License; see LICENSE file for more details. @@ -27,9 +28,8 @@ def __init__(self, query_arguments): """Initialise error.""" super().__init__( description=_( - "A set where {query_arguments} does not exist.".format( - query_arguments=query_arguments - ) + "A set where %(query_arguments)s does not exist.", + query_arguments=query_arguments, ) ) @@ -39,9 +39,7 @@ class OAIPMHSetIDDoesNotExistError(OAIPMHError): def __init__(self, id): """Initialise error.""" - super().__init__( - description=_("A set with id {id} does not exist.".format(id=id)) - ) + super().__init__(description=_("A set with id %(id)s does not exist.", id=id)) class OAIPMHSetSpecAlreadyExistsError(OAIPMHError): @@ -50,7 +48,7 @@ class OAIPMHSetSpecAlreadyExistsError(OAIPMHError): def __init__(self, spec): """Initialise error.""" super().__init__( - description=_("A set with spec '{spec}' already exists.".format(spec=spec)) + description=_("A set with spec '%(spec)s' already exists.", spec=spec) ) @@ -60,5 +58,5 @@ class OAIPMHSetNotEditable(OAIPMHError): def __init__(self, id): """Initialise error.""" super().__init__( - description=_("The set with id {id} is not editable.".format(id=id)) + description=_("The set with id %(id)s is not editable.", id=id) ) diff --git a/invenio_rdm_records/requests/quota_increase.py b/invenio_rdm_records/requests/quota_increase.py index 60d163bd5..103891973 100644 --- a/invenio_rdm_records/requests/quota_increase.py +++ b/invenio_rdm_records/requests/quota_increase.py @@ -1,6 +1,7 @@ # -*- coding: utf-8 -*- # # Copyright (C) 2026 CERN. +# Copyright (C) 2026 KTH Royal Institute of Technology. # # Invenio-RDM-Records is free software; you can redistribute it and/or modify # it under the terms of the MIT License; see LICENSE file for more details. @@ -8,6 +9,7 @@ """Quota increase request.""" from invenio_access.permissions import system_identity +from invenio_i18n import gettext from invenio_i18n import lazy_gettext as _ from invenio_requests.customizations import actions from marshmallow import fields @@ -22,10 +24,15 @@ class CreateAction(actions.CreateAction): def execute(self, identity, uow): """Verify request preconditions and create the request.""" record = self.request.topic.resolve() - - self.request["title"] = _('Quota increase request for "{record_title}"').format( - record_title=record.metadata.get("title", "Empty draft title") - ) + record_title = record.metadata.get("title") + + if record_title: + self.request["title"] = gettext( + 'Quota increase request for "%(record_title)s"', + record_title=record_title, + ) + else: + self.request["title"] = gettext("Quota increase request") super().execute(identity, uow) diff --git a/invenio_rdm_records/requests/record_deletion.py b/invenio_rdm_records/requests/record_deletion.py index de42f35d0..8cb4a9d28 100644 --- a/invenio_rdm_records/requests/record_deletion.py +++ b/invenio_rdm_records/requests/record_deletion.py @@ -1,6 +1,7 @@ # -*- coding: utf-8 -*- # # Copyright (C) 2025-2026 CERN. +# Copyright (C) 2026 KTH Royal Institute of Technology. # # Invenio-RDM-Records is free software; you can redistribute it and/or modify # it under the terms of the MIT License; see LICENSE file for more details. @@ -8,6 +9,7 @@ """Record deletion request.""" from invenio_access.permissions import system_identity +from invenio_i18n import gettext from invenio_i18n import lazy_gettext as _ from invenio_notifications.services.uow import NotificationOp from invenio_pidstore.errors import PIDDoesNotExistError @@ -39,8 +41,9 @@ def execute(self, identity, uow): ) self._verify_removal_reason() - self.request["title"] = _('Deletion request for "{record_title}"').format( - record_title=record.metadata["title"] + self.request["title"] = gettext( + 'Deletion request for "%(record_title)s"', + record_title=record.metadata["title"], ) super().execute(identity, uow) diff --git a/invenio_rdm_records/secret_links/errors.py b/invenio_rdm_records/secret_links/errors.py index d9e0d5c18..810764cb2 100644 --- a/invenio_rdm_records/secret_links/errors.py +++ b/invenio_rdm_records/secret_links/errors.py @@ -7,6 +7,8 @@ """Errors for secret links.""" +from invenio_i18n import gettext as _ + class SecretLinkError(Exception): """Base exception for secret links errors.""" @@ -19,4 +21,9 @@ class InvalidPermissionLevelError(SecretLinkError): def __init__(self, permission_level): """Initialise error.""" - super().__init__(f"Invalid permission level: {permission_level}") + super().__init__( + _( + "Invalid permission level: %(permission_level)s", + permission_level=permission_level, + ) + ) diff --git a/invenio_rdm_records/services/pids/errors.py b/invenio_rdm_records/services/pids/errors.py index 6b44b677c..472388ac8 100644 --- a/invenio_rdm_records/services/pids/errors.py +++ b/invenio_rdm_records/services/pids/errors.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # # Copyright (C) 2021-2024 CERN. -# Copyright (C) 2024 KTH Royal Institute of Technology. +# Copyright (C) 2024-2026 KTH Royal Institute of Technology. # # Invenio-RDM-Records is free software; you can redistribute it and/or modify # it under the terms of the MIT License; see LICENSE file for more details. @@ -19,7 +19,7 @@ class PIDSchemeNotSupportedError(RDMRecordsException): def __init__(self, schemes): """Initialise error.""" super().__init__( - _("No configuration defined for PIDs {schemes}".format(schemes=schemes)) + _("No configuration defined for PIDs %(schemes)s", schemes=schemes) ) diff --git a/invenio_rdm_records/services/pids/manager.py b/invenio_rdm_records/services/pids/manager.py index 6206aa70e..f4ed551be 100644 --- a/invenio_rdm_records/services/pids/manager.py +++ b/invenio_rdm_records/services/pids/manager.py @@ -83,7 +83,7 @@ def _validate_identifiers(self, pids, errors): errors.append( { "field": f"pids.{scheme}", - "messages": [_("Invalid {scheme}").format(scheme=label)], + "messages": [_("Invalid %(scheme)s", scheme=label)], } ) else: @@ -159,8 +159,8 @@ def create(self, draft, scheme, identifier=None, provider_name=None): else: if draft.pids.get(scheme): raise ValidationError( - message=_("A PID already exists for type {scheme}").format( - scheme=scheme + message=_( + "A PID already exists for type %(scheme)s", scheme=scheme ), field_name=f"pids.{scheme}", ) @@ -201,7 +201,7 @@ def update(self, record, scheme, url=None): pid_attrs = record.pids.get(scheme, None) if not pid_attrs: raise ValidationError( - message=_("PID not found for type {scheme}").format(scheme=scheme), + message=_("PID not found for type %(scheme)s", scheme=scheme), field_name="pids", ) @@ -227,7 +227,7 @@ def register(self, record, scheme, url): pid_attrs = record.pids.get(scheme, None) if not pid_attrs: raise ValidationError( - message=_("PID not found for type {scheme}").format(scheme=scheme), + message=_("PID not found for type %(scheme)s", scheme=scheme), field_name="pids", ) diff --git a/invenio_rdm_records/services/pids/providers/base.py b/invenio_rdm_records/services/pids/providers/base.py index 3d2f01b48..764165ac9 100644 --- a/invenio_rdm_records/services/pids/providers/base.py +++ b/invenio_rdm_records/services/pids/providers/base.py @@ -2,7 +2,7 @@ # # Copyright (C) 2021 CERN. # Copyright (C) 2021-2024 Graz University of Technology. -# Copyright (C) 2024 KTH Royal Institute of Technology. +# Copyright (C) 2024-2026 KTH Royal Institute of Technology. # # Invenio-RDM-Records is free software; you can redistribute it and/or modify # it under the terms of the MIT License; see LICENSE file for more details. @@ -173,8 +173,10 @@ def validate(self, record, identifier=None, provider=None, **kwargs): { "field": f"pids.{self.pid_type}", "messages": [ - _("{pid_type}:{identifier} already exists.").format( - pid_type=self.pid_type, identifier=identifier + _( + "%(pid_type)s:%(identifier)s already exists.", + pid_type=self.pid_type, + identifier=identifier, ) ], } diff --git a/invenio_rdm_records/services/pids/providers/external.py b/invenio_rdm_records/services/pids/providers/external.py index 975e277ea..40fb59937 100644 --- a/invenio_rdm_records/services/pids/providers/external.py +++ b/invenio_rdm_records/services/pids/providers/external.py @@ -3,6 +3,7 @@ # Copyright (C) 2021 CERN. # Copyright (C) 2023 Northwestern University. # Copyright (C) 2023-2024 Graz University of Technology. +# Copyright (C) 2026 KTH Royal Institute of Technology. # # Invenio-RDM-Records is free software; you can redistribute it and/or modify # it under the terms of the MIT License; see LICENSE file for more details. @@ -42,8 +43,10 @@ def __call__(self, record, identifier, provider, errors): if identifier.startswith(p): errors.append( _( - "The prefix '{prefix}' is managed by {sitename}. Please supply an external DOI or select 'No' to have a DOI generated for you." - ).format(prefix=p, sitename=current_app.config["THEME_SITENAME"]) + "The prefix '%(prefix)s' is managed by %(sitename)s. Please supply an external DOI or select 'No' to have a DOI generated for you.", + prefix=p, + sitename=current_app.config["THEME_SITENAME"], + ) ) # Bail early return @@ -88,7 +91,7 @@ def validate(self, record, identifier=None, provider=None, client=None, **kwargs if not identifier: self._insert_pid_type_error_msg( errors, - _("Missing {scheme} for required field.").format(scheme=self.label), + _("Missing %(scheme)s for required field.", scheme=self.label), ) for v in self._validators: diff --git a/invenio_rdm_records/services/schemas/access.py b/invenio_rdm_records/services/schemas/access.py index 9422c94b6..0cd985475 100644 --- a/invenio_rdm_records/services/schemas/access.py +++ b/invenio_rdm_records/services/schemas/access.py @@ -4,6 +4,7 @@ # Copyright (C) 2020-2021 Northwestern University. # Copyright (C) 2021 TU Wien. # Copyright (C) 2021-2025 Graz University of Technology. +# Copyright (C) 2026 KTH Royal Institute of Technology. # # Invenio-RDM-Records is free software; you can redistribute it and/or modify # it under the terms of the MIT License; see LICENSE file for more details. @@ -64,8 +65,9 @@ def validate_protection_value(self, value, field_name): """Check that the protection value is valid.""" if value not in ["public", "restricted"]: raise ValidationError( - _("'{field_name}' must be either 'public' or 'restricted'").format( - field_name=field_name + _( + "'%(field_name)s' must be either 'public' or 'restricted'", + field_name=field_name, ), "record", ) diff --git a/invenio_rdm_records/services/schemas/community_records.py b/invenio_rdm_records/services/schemas/community_records.py index ed875b065..10aea2118 100644 --- a/invenio_rdm_records/services/schemas/community_records.py +++ b/invenio_rdm_records/services/schemas/community_records.py @@ -2,6 +2,7 @@ # # Copyright (C) 2023 CERN. # Copyright (C) 2025 Graz University of Technology. +# Copyright (C) 2026 KTH Royal Institute of Technology. # # Invenio-RDM-Records is free software; you can redistribute it and/or modify # it under the terms of the MIT License; see LICENSE file for more details. @@ -33,9 +34,8 @@ def validate_records(self, value): if max_number < len(value): raise ValidationError( _( - "Too many records passed, {max_number} max allowed.".format( - max_number=max_number - ) + "Too many records passed, %(max_number)s max allowed.", + max_number=max_number, ) ) @@ -50,5 +50,5 @@ def validate_records(self, value): if duplicated: raise ValidationError( - _("Duplicated records {rec_ids}.".format(rec_ids=duplicated)) + _("Duplicated records %(rec_ids)s.", rec_ids=duplicated) ) diff --git a/invenio_rdm_records/services/schemas/metadata.py b/invenio_rdm_records/services/schemas/metadata.py index 8cef76026..f4d1b1bde 100644 --- a/invenio_rdm_records/services/schemas/metadata.py +++ b/invenio_rdm_records/services/schemas/metadata.py @@ -3,6 +3,7 @@ # Copyright (C) 2020-2025 CERN. # Copyright (C) 2020 Northwestern University. # Copyright (C) 2021-2025 Graz University of Technology. +# Copyright (C) 2026 KTH Royal Institute of Technology. # # Invenio-RDM-Records is free software; you can redistribute it and/or modify # it under the terms of the MIT License; see LICENSE file for more details. @@ -90,11 +91,11 @@ class PersonOrOrganizationSchema(Schema): required=True, validate=validate.OneOf( choices=NAMES, - error=_("Invalid value. Choose one of {NAMES}.").format(NAMES=NAMES), + error=_("Invalid value. Choose one of %(names)s.", names=NAMES), ), error_messages={ # [] needed to mirror error message above - "required": [_("Invalid value. Choose one of {NAMES}.").format(NAMES=NAMES)] + "required": [_("Invalid value. Choose one of %(names)s.", names=NAMES)] }, ) name = SanitizedUnicode() diff --git a/invenio_rdm_records/services/schemas/parent/__init__.py b/invenio_rdm_records/services/schemas/parent/__init__.py index 1211d9783..da01c868b 100644 --- a/invenio_rdm_records/services/schemas/parent/__init__.py +++ b/invenio_rdm_records/services/schemas/parent/__init__.py @@ -2,6 +2,7 @@ # # Copyright (C) 2021 TU Wien. # Copyright (C) 2021-2024 CERN. +# Copyright (C) 2026 KTH Royal Institute of Technology. # # Invenio-RDM-Records is free software; you can redistribute it and/or modify # it under the terms of the MIT License; see LICENSE file for more details. @@ -25,7 +26,7 @@ def validate_scheme(scheme): """Validate a PID scheme.""" if scheme not in current_app.config["RDM_PARENT_PERSISTENT_IDENTIFIERS"]: raise ValidationError( - _("Invalid persistent identifier scheme {scheme}.".format(scheme=scheme)) + _("Invalid persistent identifier scheme %(scheme)s.", scheme=scheme) ) diff --git a/invenio_rdm_records/services/schemas/record_communities.py b/invenio_rdm_records/services/schemas/record_communities.py index c64df55bf..da34ec1ba 100644 --- a/invenio_rdm_records/services/schemas/record_communities.py +++ b/invenio_rdm_records/services/schemas/record_communities.py @@ -2,6 +2,7 @@ # # Copyright (C) 2023 CERN. # Copyright (C) 2025 Graz University of Technology. +# Copyright (C) 2026 KTH Royal Institute of Technology. # # Invenio-RDM-Records is free software; you can redistribute it and/or modify # it under the terms of the MIT License; see LICENSE file for more details. @@ -36,9 +37,8 @@ def validate_communities(self, value): if max_number < len(value): raise ValidationError( _( - "Too many communities passed, {max_number} max allowed.".format( - max_number=max_number - ) + "Too many communities passed, %(max_number)s max allowed.", + max_number=max_number, ) ) @@ -53,5 +53,5 @@ def validate_communities(self, value): if duplicated: raise ValidationError( - _("Duplicated communities {com_ids}.".format(com_ids=duplicated)) + _("Duplicated communities %(com_ids)s.", com_ids=duplicated) )