diff --git a/invenio_rdm_records/administration/views/oai.py b/invenio_rdm_records/administration/views/oai.py index d71e4a277..4055a9731 100644 --- a/invenio_rdm_records/administration/views/oai.py +++ b/invenio_rdm_records/administration/views/oai.py @@ -2,6 +2,7 @@ # # Copyright (C) 2022-2024 CERN. # Copyright (C) 2023 Graz University of Technology. +# Copyright (C) 2024 KTH Royal Institute of Technology. # # invenio-administration is free software; you can redistribute it and/or # modify it under the terms of the MIT License; see LICENSE file for more @@ -25,8 +26,8 @@ class OaiPmhListView(AdminResourceListView): name = "OAI-PMH" resource_config = "oaipmh_server_resource" search_request_headers = {"Accept": "application/json"} - title = "OAI-PMH Sets" - category = "Site management" + title = _("OAI-PMH Sets") + category = _("Site management") pid_path = "id" icon = "exchange" template = "invenio_rdm_records/oai-search.html" @@ -59,9 +60,9 @@ class OaiPmhEditView(AdminResourceEditView): resource_config = "oaipmh_server_resource" pid_path = "id" api_endpoint = "/oaipmh/sets" - title = "Edit OAI-PMH set" + title = _("Edit OAI-PMH set") - list_view_name = "OAI-PMH" + list_view_name = _("OAI-PMH") form_fields = { "name": { @@ -99,9 +100,9 @@ class OaiPmhCreateView(AdminResourceCreateView): resource_config = "oaipmh_server_resource" pid_path = "id" api_endpoint = "/oaipmh/sets" - title = "Create OAI-PMH set" + title = _("Create OAI-PMH set") - list_view_name = "OAI-PMH" + list_view_name = _("OAI-PMH") form_fields = { "name": { @@ -136,13 +137,13 @@ class OaiPmhDetailView(AdminResourceDetailView): search_request_headers = {"Accept": "application/json"} name = "OAI-PMH details" resource_config = "oaipmh_server_resource" - title = "OAI-PMH Details" + title = _("OAI-PMH Details") template = "invenio_rdm_records/oai-details.html" display_delete = True display_edit = True - list_view_name = "OAI-PMH" + list_view_name = _("OAI-PMH") pid_path = "id" item_field_list = { diff --git a/invenio_rdm_records/assets/semantic-ui/js/invenio_rdm_records/src/deposit/components/CommunitySelectionModal/CommunityListItem.js b/invenio_rdm_records/assets/semantic-ui/js/invenio_rdm_records/src/deposit/components/CommunitySelectionModal/CommunityListItem.js index e35eeffd3..1bb3f25eb 100644 --- a/invenio_rdm_records/assets/semantic-ui/js/invenio_rdm_records/src/deposit/components/CommunitySelectionModal/CommunityListItem.js +++ b/invenio_rdm_records/assets/semantic-ui/js/invenio_rdm_records/src/deposit/components/CommunitySelectionModal/CommunityListItem.js @@ -1,5 +1,6 @@ // This file is part of Invenio-RDM-Records // Copyright (C) 2020-2024 CERN. +// Copyright (C) 2024 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. @@ -75,7 +76,7 @@ export const CommunityListItem = ({ result, record, isInitialSubmission }) => { )} /> )} @@ -107,7 +108,7 @@ export const CommunityListItem = ({ result, record, isInitialSubmission }) => { {hasTheme && ( )} diff --git a/invenio_rdm_records/assets/semantic-ui/js/invenio_rdm_records/src/deposit/fields/ComingSoonField/ComingSoonField.js b/invenio_rdm_records/assets/semantic-ui/js/invenio_rdm_records/src/deposit/fields/ComingSoonField/ComingSoonField.js index 5e56491dd..ff82cdd3c 100644 --- a/invenio_rdm_records/assets/semantic-ui/js/invenio_rdm_records/src/deposit/fields/ComingSoonField/ComingSoonField.js +++ b/invenio_rdm_records/assets/semantic-ui/js/invenio_rdm_records/src/deposit/fields/ComingSoonField/ComingSoonField.js @@ -1,6 +1,7 @@ // This file is part of Invenio-RDM-Records // Copyright (C) 2020-2023 CERN. // Copyright (C) 2020-2022 Northwestern University. +// Copyright (C) 2024 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. @@ -9,6 +10,7 @@ import React, { Component } from "react"; import PropTypes from "prop-types"; import { FieldLabel } from "react-invenio-forms"; import { Form, Segment } from "semantic-ui-react"; +import { i18next } from "@translations/invenio_rdm_records/i18next"; export class ComingSoonField extends Component { render() { @@ -17,7 +19,7 @@ export class ComingSoonField extends Component { - Coming soon + {i18next.t("Coming soon")} ); diff --git a/invenio_rdm_records/assets/semantic-ui/js/invenio_rdm_records/src/deposit/fields/CreatibutorsField/CreatibutorsFieldItem.js b/invenio_rdm_records/assets/semantic-ui/js/invenio_rdm_records/src/deposit/fields/CreatibutorsField/CreatibutorsFieldItem.js index 861af712d..bd06c2443 100644 --- a/invenio_rdm_records/assets/semantic-ui/js/invenio_rdm_records/src/deposit/fields/CreatibutorsField/CreatibutorsFieldItem.js +++ b/invenio_rdm_records/assets/semantic-ui/js/invenio_rdm_records/src/deposit/fields/CreatibutorsField/CreatibutorsFieldItem.js @@ -2,6 +2,7 @@ // Copyright (C) 2020-2024 CERN. // Copyright (C) 2020-2022 Northwestern University. // Copyright (C) 2021 New York University. +// Copyright (C) 2024 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. @@ -111,7 +112,7 @@ export const CreatibutorsFieldItem = ({ (identifier) => identifier.scheme === "orcid" ) && ( ORCID logo identifier.scheme === "ror" ) && ( ROR logo identifier.scheme === "gnd" ) && ( GND logo {firstError && ( )} diff --git a/invenio_rdm_records/assets/semantic-ui/js/invenio_rdm_records/src/deposit/fields/FileUploader/FileUploaderArea.js b/invenio_rdm_records/assets/semantic-ui/js/invenio_rdm_records/src/deposit/fields/FileUploader/FileUploaderArea.js index 12565b9b9..af6dedfd6 100644 --- a/invenio_rdm_records/assets/semantic-ui/js/invenio_rdm_records/src/deposit/fields/FileUploader/FileUploaderArea.js +++ b/invenio_rdm_records/assets/semantic-ui/js/invenio_rdm_records/src/deposit/fields/FileUploader/FileUploaderArea.js @@ -3,6 +3,7 @@ // Copyright (C) 2020-2022 Northwestern University. // Copyright (C) 2021-2022 Graz University of Technology. // Copyright (C) 2022 TU Wien. +// Copyright (C) 2024 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. @@ -32,7 +33,7 @@ const FileTableHeader = ({ filesLocked }) => ( {i18next.t("Preview")}{" "} } /> diff --git a/invenio_rdm_records/assets/semantic-ui/js/invenio_rdm_records/src/deposit/fields/Identifiers/PIDField.js b/invenio_rdm_records/assets/semantic-ui/js/invenio_rdm_records/src/deposit/fields/Identifiers/PIDField.js index bd5b00cae..3eb6c2e86 100644 --- a/invenio_rdm_records/assets/semantic-ui/js/invenio_rdm_records/src/deposit/fields/Identifiers/PIDField.js +++ b/invenio_rdm_records/assets/semantic-ui/js/invenio_rdm_records/src/deposit/fields/Identifiers/PIDField.js @@ -1,6 +1,7 @@ // This file is part of Invenio-RDM-Records // Copyright (C) 2020-2023 CERN. // Copyright (C) 2020-2022 Northwestern University. +// Copyright (C) 2024 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. @@ -515,7 +516,9 @@ export class PIDField extends Component { const { canBeManaged, canBeUnmanaged, fieldPath } = this.props; if (!canBeManaged && !canBeUnmanaged) { - throw Error(`${fieldPath} must be managed, unmanaged or both.`); + throw Error( + i18next.t("{{fieldPath}} must be managed, unmanaged or both.", { fieldPath }) + ); } }; diff --git a/invenio_rdm_records/assets/semantic-ui/js/invenio_rdm_records/src/deposit/fields/License/LicenseModal.js b/invenio_rdm_records/assets/semantic-ui/js/invenio_rdm_records/src/deposit/fields/License/LicenseModal.js index 24d440e7e..b58d07cc3 100644 --- a/invenio_rdm_records/assets/semantic-ui/js/invenio_rdm_records/src/deposit/fields/License/LicenseModal.js +++ b/invenio_rdm_records/assets/semantic-ui/js/invenio_rdm_records/src/deposit/fields/License/LicenseModal.js @@ -2,6 +2,7 @@ // Copyright (C) 2020-2023 CERN. // Copyright (C) 2020-2022 Northwestern University. // Copyright (C) 2021 Graz University of Technology. +// Copyright (C) 2024 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. @@ -146,22 +147,22 @@ export class LicenseModal extends Component { diff --git a/invenio_rdm_records/assets/semantic-ui/js/invenio_rdm_records/src/deposit/fields/TitlesField/AdditionalTitlesField.js b/invenio_rdm_records/assets/semantic-ui/js/invenio_rdm_records/src/deposit/fields/TitlesField/AdditionalTitlesField.js index fb93b9ccc..9119b5e17 100644 --- a/invenio_rdm_records/assets/semantic-ui/js/invenio_rdm_records/src/deposit/fields/TitlesField/AdditionalTitlesField.js +++ b/invenio_rdm_records/assets/semantic-ui/js/invenio_rdm_records/src/deposit/fields/TitlesField/AdditionalTitlesField.js @@ -2,6 +2,7 @@ // Copyright (C) 2020-2023 CERN. // Copyright (C) 2020-2022 Northwestern University. // Copyright (C) 2021 Graz University of Technology. +// Copyright (C) 2024 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. @@ -32,13 +33,13 @@ export class AdditionalTitlesField extends Component { here to access the record.'.format( - url=access_url - ) + "content": _( + 'Click here to access the record.' + ).format(url=access_url) } } current_events_service.create( @@ -310,12 +312,12 @@ def _validate_days(self, value): try: if int(value) < 0: raise ValidationError( - message="Not a valid number of days.", + message=_("Not a valid number of days."), field_name="secret_link_expiration", ) except ValueError: raise ValidationError( - message="Not a valid number of days.", + message=_("Not a valid number of days."), field_name="secret_link_expiration", ) diff --git a/invenio_rdm_records/resources/serializers/cff/schema.py b/invenio_rdm_records/resources/serializers/cff/schema.py index 15d4c2206..d7d622b91 100644 --- a/invenio_rdm_records/resources/serializers/cff/schema.py +++ b/invenio_rdm_records/resources/serializers/cff/schema.py @@ -1,12 +1,14 @@ # -*- coding: utf-8 -*- # # Copyright (C) 2023 CERN. +# Copyright (C) 2024 KTH Royal Institute of Technology. # # Invenio-RDM is free software; you can redistribute it and/or modify # it under the terms of the MIT License; see LICENSE file for more details. """CFF schema.""" from flask_resources.serializers import BaseSerializerSchema +from invenio_i18n import lazy_gettext as _ from marshmallow import ValidationError, fields, missing from marshmallow_utils.fields import SanitizedHTML, SanitizedUnicode @@ -24,7 +26,7 @@ def _serialize_person(person): serialized.update({"given-names": giv_name}) if not serialized: - return ValidationError("One of 'family-names' or 'given-names' is required.") + return ValidationError(_("One of 'family-names' or 'given-names' is required.")) identifiers = person["person_or_org"].get("identifiers", []) affiliations = person.get("affiliations", []) diff --git a/invenio_rdm_records/resources/serializers/schemaorg/schema.py b/invenio_rdm_records/resources/serializers/schemaorg/schema.py index af1cdcad0..59f582432 100644 --- a/invenio_rdm_records/resources/serializers/schemaorg/schema.py +++ b/invenio_rdm_records/resources/serializers/schemaorg/schema.py @@ -3,6 +3,7 @@ # Copyright (C) 2023-2024 CERN. # Copyright (C) 2021 Northwestern University. # Copyright (C) 2023 Graz University of Technology. +# Copyright (C) 2024 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. @@ -17,6 +18,7 @@ from edtf.parser.grammar import ParseException from flask_resources.serializers import BaseSerializerSchema from idutils import to_url +from invenio_i18n import lazy_gettext as _ from marshmallow import Schema, ValidationError, fields, missing from marshmallow_utils.fields import SanitizedHTML, SanitizedUnicode from pydash import py_ @@ -117,7 +119,9 @@ def format_affiliation(affiliation): id_ = affiliation.get("id") if not (name or id_): raise ValidationError( - "Affiliation failed to serialize: one of 'id' or 'name' must be provided." + _( + "Affiliation failed to serialize: one of 'id' or 'name' must be provided." + ) ) serialized_affiliation = {"@type": "Organization"} @@ -360,7 +364,9 @@ def _serialize_award(award): if not (id_ or (title and number)): # One of 'id' or '(title' and 'number') must be provided raise ValidationError( - "Funding serialization failed on award: one of 'id' or ('number' and 'title') are required." + _( + "Funding serialization failed on award: one of 'id' or ('number' and 'title') are required." + ) ) serialized_award = {} diff --git a/invenio_rdm_records/resources/serializers/utils.py b/invenio_rdm_records/resources/serializers/utils.py index 7ac0b3468..dbeb7468e 100644 --- a/invenio_rdm_records/resources/serializers/utils.py +++ b/invenio_rdm_records/resources/serializers/utils.py @@ -2,6 +2,7 @@ # # Copyright (C) 2021-2024 CERN. # Copyright (C) 2021 Northwestern University. +# Copyright (C) 2024 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. @@ -11,6 +12,7 @@ import math from invenio_access.permissions import system_identity +from invenio_i18n import lazy_gettext as _ from invenio_search.engine import dsl from invenio_vocabularies.proxies import current_service as vocabulary_service @@ -32,7 +34,9 @@ def get_vocabulary_props(vocabulary, fields, id_): return h.get("props", {}) raise VocabularyItemNotFoundError( - f"The '{vocabulary}' vocabulary item '{id_}' was not found." + _("The '{vocabulary}' vocabulary item '{id_}' was not found.").format( + vocabulary=vocabulary, id_=id_ + ) ) diff --git a/invenio_rdm_records/services/communities/service.py b/invenio_rdm_records/services/communities/service.py index 92e26aa9d..759032c9a 100644 --- a/invenio_rdm_records/services/communities/service.py +++ b/invenio_rdm_records/services/communities/service.py @@ -422,7 +422,7 @@ def bulk_add(self, identity, community_id, record_ids, set_default=False, uow=No { "record_id": record_id, "community_id": community_id, - "message": "Community already included.", + "message": _("Community already included."), } ) continue diff --git a/invenio_rdm_records/services/community_inclusion/service.py b/invenio_rdm_records/services/community_inclusion/service.py index 8eed5bbc5..81448bbcb 100644 --- a/invenio_rdm_records/services/community_inclusion/service.py +++ b/invenio_rdm_records/services/community_inclusion/service.py @@ -1,6 +1,7 @@ # -*- coding: utf-8 -*- # # Copyright (C) 2023-2024 CERN. +# Copyright (C) 2024 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. @@ -41,7 +42,7 @@ def submit(self, identity, record, community, request, data, uow): It ensures that public records cannot be included in restricted communities. """ if request.type.type_id not in self.supported_types: - raise ValueError("Invalid request type.") + raise ValueError(_("Invalid request type.")) # All other preconditions can be checked by the action itself which can # raise appropriate exceptions. @@ -55,7 +56,7 @@ def include(self, identity, community, request, uow): Request will be accepted based on community policy and identity permissions """ if request.type.type_id not in self.supported_types: - raise ValueError("Invalid request type.") + raise ValueError(_("Invalid request type.")) can_include_directly = current_communities.service.check_permission( identity, "include_directly", record=community diff --git a/invenio_rdm_records/services/github/release.py b/invenio_rdm_records/services/github/release.py index aa89e1380..9f466691e 100644 --- a/invenio_rdm_records/services/github/release.py +++ b/invenio_rdm_records/services/github/release.py @@ -1,6 +1,7 @@ # -*- coding: utf-8 -*- # # Copyright (C) 2023-2024 CERN. +# Copyright (C) 2024 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. @@ -12,6 +13,7 @@ from invenio_db import db from invenio_github.api import GitHubRelease from invenio_github.models import ReleaseStatus +from invenio_i18n import lazy_gettext as _ from invenio_records_resources.services.uow import UnitOfWork from ...proxies import current_rdm_records_service @@ -55,7 +57,7 @@ def metadata(self): { "person_or_org": { "type": "personal", - "family_name": "Unknown", + "family_name": _("Unknown"), }, } ] diff --git a/invenio_rdm_records/services/pids/errors.py b/invenio_rdm_records/services/pids/errors.py index 3ebb39c6f..712d76118 100644 --- a/invenio_rdm_records/services/pids/errors.py +++ b/invenio_rdm_records/services/pids/errors.py @@ -1,6 +1,7 @@ # -*- coding: utf-8 -*- # # Copyright (C) 2021-2024 CERN. +# Copyright (C) 2024 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. @@ -27,4 +28,10 @@ class ProviderNotSupportedError(RDMRecordsException): def __init__(self, provider, scheme): """Initialise error.""" - super().__init__(f"Unknown PID provider {provider} for {scheme}") + super().__init__( + _( + "Unknown PID provider {provider} for {scheme}".format( + provider=provider, scheme=scheme + ) + ) + ) diff --git a/invenio_rdm_records/services/pids/providers/base.py b/invenio_rdm_records/services/pids/providers/base.py index f2bc3188b..3d2f01b48 100644 --- a/invenio_rdm_records/services/pids/providers/base.py +++ b/invenio_rdm_records/services/pids/providers/base.py @@ -2,6 +2,7 @@ # # Copyright (C) 2021 CERN. # Copyright (C) 2021-2024 Graz University of Technology. +# Copyright (C) 2024 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. @@ -81,7 +82,7 @@ def create(self, record, pid_value=None, status=None, **kwargs): """ if pid_value is None: if not self.is_managed(): - raise ValueError("You must provide a pid value.") + raise ValueError(_("You must provide a pid value.")) pid_value = self.generate_id(record) try: diff --git a/invenio_rdm_records/services/services.py b/invenio_rdm_records/services/services.py index e99d0761a..baaa13a05 100644 --- a/invenio_rdm_records/services/services.py +++ b/invenio_rdm_records/services/services.py @@ -5,6 +5,7 @@ # Copyright (C) 2021-2023 TU Wien. # Copyright (C) 2021 Graz University of Technology. # Copyright (C) 2022 Universität Hamburg. +# Copyright (C) 2024 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,6 +20,7 @@ from invenio_db import db from invenio_drafts_resources.services.records import RecordService from invenio_drafts_resources.services.records.uow import ParentRecordCommitOp +from invenio_i18n import lazy_gettext as _ from invenio_records_resources.services import LinksTemplate, ServiceSchemaWrapper from invenio_records_resources.services.errors import PermissionDeniedError from invenio_records_resources.services.uow import ( @@ -628,8 +630,10 @@ def update_draft( ) if end_of_grace_period <= datetime.now(): raise ValidationError( - "Record visibility can not be changed to restricted " - "anymore. Please contact support if you still need to make these changes." + _( + "Record visibility can not be changed to restricted " + "anymore. Please contact support if you still need to make these changes." + ) ) return super().update_draft(