From cd6f86e42377866549caa641c5871ac802303cd2 Mon Sep 17 00:00:00 2001 From: Sam Arbid Date: Wed, 4 Dec 2024 13:26:16 +0100 Subject: [PATCH 01/23] i18n: mark strings for oai.py --- invenio_rdm_records/administration/views/oai.py | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) 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 = { From b123fd3500cc1dab21a96cec44a6e272815063c8 Mon Sep 17 00:00:00 2001 From: Sam Arbid Date: Wed, 4 Dec 2024 13:43:09 +0100 Subject: [PATCH 02/23] i18n: mark strings for CommunityListitem.js --- .../components/CommunitySelectionModal/CommunityListItem.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) 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 && ( )} From 6004f92cdd5b3db21684482b42be935a3aff807d Mon Sep 17 00:00:00 2001 From: Sam Arbid Date: Wed, 4 Dec 2024 15:33:00 +0100 Subject: [PATCH 03/23] i18n: mark strings for ComingSoonField.js --- .../src/deposit/fields/ComingSoonField/ComingSoonField.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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")} ); From 45a44729a492e3c51e2f3b559809955e917ec6e7 Mon Sep 17 00:00:00 2001 From: Sam Arbid Date: Wed, 4 Dec 2024 15:39:52 +0100 Subject: [PATCH 04/23] i18n: mark strings for CreatibutorsFieldItem.js --- .../fields/CreatibutorsField/CreatibutorsFieldItem.js | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) 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 && ( )} From f0c1f2e0f25d47abf214a53dd5bf346e6f25e946 Mon Sep 17 00:00:00 2001 From: Sam Arbid Date: Wed, 4 Dec 2024 15:46:52 +0100 Subject: [PATCH 05/23] i18n: mark strings for LicenseModal.js --- .../src/deposit/fields/License/LicenseModal.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) 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 { From 645fa032d453711eba5e9bf8c0adc48f506b6682 Mon Sep 17 00:00:00 2001 From: Sam Arbid Date: Wed, 4 Dec 2024 16:01:43 +0100 Subject: [PATCH 06/23] i18n: mark strings for FileUploaderArea.js --- .../src/deposit/fields/FileUploader/FileUploaderArea.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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")}{" "} } /> From 587d88f4f523a6a49eae56254d3bf07ff02ef769 Mon Sep 17 00:00:00 2001 From: Sam Arbid Date: Wed, 4 Dec 2024 16:02:53 +0100 Subject: [PATCH 07/23] i18n: mark strings for PIDField.js --- .../src/deposit/fields/Identifiers/PIDField.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) 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 }) + ); } }; From 13e43f45bdf8c07014f5be20f7684669677aa076 Mon Sep 17 00:00:00 2001 From: Sam Arbid Date: Wed, 4 Dec 2024 17:57:07 +0100 Subject: [PATCH 08/23] i18n: mark strings for AdditionalTitlesField.js --- .../deposit/fields/TitlesField/AdditionalTitlesField.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) 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 { Date: Wed, 4 Dec 2024 18:11:56 +0100 Subject: [PATCH 09/23] i18n: mark strings for custom_fields.py --- .../contrib/codemeta/custom_fields.py | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/invenio_rdm_records/contrib/codemeta/custom_fields.py b/invenio_rdm_records/contrib/codemeta/custom_fields.py index 55c691ffc..cd0b62257 100644 --- a/invenio_rdm_records/contrib/codemeta/custom_fields.py +++ b/invenio_rdm_records/contrib/codemeta/custom_fields.py @@ -1,6 +1,7 @@ # -*- coding: utf-8 -*- # # Copyright (C) 2023 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. @@ -32,7 +33,7 @@ name="code:codeRepository", field_args={ "validate": validate.URL(), - "error_messages": {"validate": "You must provide a valid URL."}, + "error_messages": {"validate": _("You must provide a valid URL.")}, }, ), VocabularyCF( @@ -57,19 +58,19 @@ ui_widget="Input", props=dict( is_identifier=True, - label="Repository URL", + label=_("Repository URL"), icon="linkify", - description="URL or link where the code repository is hosted.", + description=_("URL or link where the code repository is hosted."), ), ), dict( field="code:programmingLanguage", ui_widget="AutocompleteDropdown", props=dict( - label="Programming language", + label=_("Programming language"), icon="code", - description="Repository's programming language.", - placeholder="e.g. Python ...", + description=_("Repository's programming language."), + placeholder=_("e.g. Python ..."), autocompleteFrom="/api/vocabularies/code:programmingLanguages", autocompleteFromAcceptHeader="application/vnd.inveniordm.v1+json", required=False, @@ -81,10 +82,10 @@ field="code:developmentStatus", ui_widget="Dropdown", props=dict( - label="Development Status", - placeholder="Repository status", + label=_("Development Status"), + placeholder=_("Repository status"), icon="heartbeat", - description="Repository current status.", + description=_("Repository current status."), search=False, multiple=False, clearable=True, From 536a17e54b9d9c2b0a96d845c94971ed2650e9bd Mon Sep 17 00:00:00 2001 From: Sam Arbid Date: Wed, 4 Dec 2024 18:16:23 +0100 Subject: [PATCH 10/23] i18n: mark strings for journal/custom_fields.py --- invenio_rdm_records/contrib/journal/custom_fields.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/invenio_rdm_records/contrib/journal/custom_fields.py b/invenio_rdm_records/contrib/journal/custom_fields.py index 9277213fc..6b9326c77 100644 --- a/invenio_rdm_records/contrib/journal/custom_fields.py +++ b/invenio_rdm_records/contrib/journal/custom_fields.py @@ -1,5 +1,6 @@ # # Copyright (C) 2023 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. @@ -86,22 +87,22 @@ def mapping(self): }, "volume": { "label": _("Volume"), - "placeholder": "e.g. 645", + "placeholder": _("e.g. 645"), "description": "", }, "issue": { "label": _("Issue"), - "placeholder": "e.g. 7", + "placeholder": _("e.g. 7"), "description": "", }, "pages": { "label": _("Page range or article number"), - "placeholder": "e.g. 15-23 or A29", + "placeholder": _("e.g. 15-23 or A29"), "description": "", }, "issn": { "label": _("ISSN"), - "placeholder": "e.g. 2077-9550", + "placeholder": _("e.g. 2077-9550"), "description": _("International Standard Serial Number"), }, "icon": "newspaper outline", From f7cbffc1c1e2334f326744ebf75b058cdaca24f0 Mon Sep 17 00:00:00 2001 From: Sam Arbid Date: Wed, 4 Dec 2024 18:18:57 +0100 Subject: [PATCH 11/23] i18n: mark strings for meeting/custom_fields.py --- invenio_rdm_records/contrib/meeting/custom_fields.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/invenio_rdm_records/contrib/meeting/custom_fields.py b/invenio_rdm_records/contrib/meeting/custom_fields.py index 1b05cbd5e..2dcddad13 100644 --- a/invenio_rdm_records/contrib/meeting/custom_fields.py +++ b/invenio_rdm_records/contrib/meeting/custom_fields.py @@ -1,5 +1,6 @@ # # Copyright (C) 2023 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. @@ -40,7 +41,7 @@ def field(self): "session": SanitizedUnicode(), "title": SanitizedUnicode(), "url": SanitizedUnicode( - validate=_valid_url(error_msg="You must provide a valid URL."), + validate=_valid_url(error_msg=_("You must provide a valid URL.")), ), } ) From 1212c194f4c754041ef37801a11169609f2c7818 Mon Sep 17 00:00:00 2001 From: Sam Arbid Date: Wed, 4 Dec 2024 18:42:04 +0100 Subject: [PATCH 12/23] i18n: mark strings for jobs.py * Checked the spelling or embargoes here: https://dictionary.cambridge.org/dictionary/english/embargoes --- invenio_rdm_records/jobs/jobs.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/invenio_rdm_records/jobs/jobs.py b/invenio_rdm_records/jobs/jobs.py index 7f0d56a5f..144fb1eb1 100644 --- a/invenio_rdm_records/jobs/jobs.py +++ b/invenio_rdm_records/jobs/jobs.py @@ -1,12 +1,14 @@ # -*- coding: utf-8 -*- # # Copyright (C) 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. """Jobs definition module.""" +from invenio_i18n import lazy_gettext as _ from invenio_jobs.jobs import JobType from invenio_rdm_records.services.tasks import update_expired_embargos @@ -16,6 +18,6 @@ job_cls_name="UpdateEmbargoesJob", id_="update_expired_embargos", task=update_expired_embargos, - description="Updates expired embargos", - title="Update expired embargoes", + description=_("Updates expired embargoes"), + title=_("Update expired embargoes"), ) From 08f1b01d52a429527813c2bd458e4f38ce445392 Mon Sep 17 00:00:00 2001 From: Sam Arbid Date: Wed, 4 Dec 2024 19:04:11 +0100 Subject: [PATCH 13/23] i18n: mark strings for schema.py --- invenio_rdm_records/oaiserver/services/schema.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/invenio_rdm_records/oaiserver/services/schema.py b/invenio_rdm_records/oaiserver/services/schema.py index 226e57bad..4ab61780f 100644 --- a/invenio_rdm_records/oaiserver/services/schema.py +++ b/invenio_rdm_records/oaiserver/services/schema.py @@ -1,12 +1,14 @@ # -*- coding: utf-8 -*- # # Copyright (C) 2022 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. """OAI-PMH API schemas.""" +from invenio_i18n import lazy_gettext as _ from marshmallow import EXCLUDE, Schema, fields, validate from marshmallow_utils.fields import SanitizedUnicode @@ -25,7 +27,7 @@ class OAIPMHSetSchema(Schema): description = SanitizedUnicode(load_default=None, dump_default=None) name = SanitizedUnicode(required=True, validate=validate.Length(min=1, max=255)) search_pattern = SanitizedUnicode( - required=True, metadata={"title": "Search pattern"} + required=True, metadata={"title": _("Search pattern")} ) spec = SanitizedUnicode( required=True, From 064a707dba0b36a3402ba22e6115f530106da35a Mon Sep 17 00:00:00 2001 From: Sam Arbid Date: Wed, 4 Dec 2024 19:24:50 +0100 Subject: [PATCH 14/23] i18n: mark strings for requests.py --- invenio_rdm_records/requests/access/requests.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/invenio_rdm_records/requests/access/requests.py b/invenio_rdm_records/requests/access/requests.py index 90e0c11f5..640edfa4f 100644 --- a/invenio_rdm_records/requests/access/requests.py +++ b/invenio_rdm_records/requests/access/requests.py @@ -1,6 +1,7 @@ # -*- coding: utf-8 -*- # # Copyright (C) 2023 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. @@ -13,6 +14,7 @@ from flask import g from invenio_access.permissions import authenticated_user, system_identity from invenio_drafts_resources.services.records.uow import ParentRecordCommitOp +from invenio_i18n import gettext as t from invenio_i18n import lazy_gettext as _ from invenio_notifications.services.uow import NotificationOp from invenio_requests import current_events_service @@ -149,7 +151,7 @@ def execute(self, identity, uow): # by the record owner data = { "permission": payload["permission"], - "description": ( + "description": t( f"Requested by guest: {payload['full_name']} ({payload['email']})" ), "origin": f"request:{self.request.id}", @@ -182,9 +184,9 @@ def execute(self, identity, uow): confirmation_message = { "payload": { - "content": 'Click 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", ) From 42ec39d6e996236b252f092faefef8faabe7639d Mon Sep 17 00:00:00 2001 From: Sam Arbid Date: Wed, 4 Dec 2024 19:38:41 +0100 Subject: [PATCH 15/23] i18n: mark strings for cff/schema.py --- invenio_rdm_records/resources/serializers/cff/schema.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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", []) From 8374bf748dc9e2f86a687a426085d0ef16d01cc6 Mon Sep 17 00:00:00 2001 From: Sam Arbid Date: Wed, 4 Dec 2024 20:07:39 +0100 Subject: [PATCH 16/23] i18n: mark strings for cff/schemaorg/schema.py --- .../resources/serializers/schemaorg/schema.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) 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 = {} From 6ae030c779c7238478bb572571094f25db201632 Mon Sep 17 00:00:00 2001 From: Sam Arbid Date: Wed, 4 Dec 2024 23:15:20 +0100 Subject: [PATCH 17/23] i18n: mark strings for serializers.py --- invenio_rdm_records/resources/serializers/utils.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) 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_ + ) ) From 8cd1c1f2cd3ab860468ba1f9465fe773f68eab1f Mon Sep 17 00:00:00 2001 From: Sam Arbid Date: Wed, 4 Dec 2024 23:15:39 +0100 Subject: [PATCH 18/23] i18n: mark strings for communities/service.py --- invenio_rdm_records/services/communities/service.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 From ba350645adfb84ebd980aef7fc90d3c58ee8809b Mon Sep 17 00:00:00 2001 From: Sam Arbid Date: Wed, 4 Dec 2024 23:17:26 +0100 Subject: [PATCH 19/23] i18n: mark strings for community_inclusion/service.py --- invenio_rdm_records/services/community_inclusion/service.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) 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 From ca0b8462e478873002c558ba1e68358bb102b821 Mon Sep 17 00:00:00 2001 From: Sam Arbid Date: Wed, 4 Dec 2024 23:26:00 +0100 Subject: [PATCH 20/23] i18n: mark strings for github/release.py * should this be translated? --- invenio_rdm_records/services/github/release.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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"), }, } ] From 7351b99aea264fefea91fd25499535770b1033ee Mon Sep 17 00:00:00 2001 From: Sam Arbid Date: Wed, 4 Dec 2024 23:29:40 +0100 Subject: [PATCH 21/23] i18n: mark strings for providers/base.py --- invenio_rdm_records/services/pids/providers/base.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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: From 10624801f9fff21cc950a5e2d98a83c17c4a157f Mon Sep 17 00:00:00 2001 From: Sam Arbid Date: Wed, 4 Dec 2024 23:33:59 +0100 Subject: [PATCH 22/23] i18n: mark strings for pids/errors.py --- invenio_rdm_records/services/pids/errors.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) 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 + ) + ) + ) From 88ae05f58158735488c15e92f65f5ff55d6c553e Mon Sep 17 00:00:00 2001 From: Sam Arbid Date: Thu, 5 Dec 2024 00:20:29 +0100 Subject: [PATCH 23/23] i18n: mark strings for services/services.py --- invenio_rdm_records/services/services.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) 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(