Skip to content

Commit

Permalink
i18n: Fix untranslated strings in vocabularies
Browse files Browse the repository at this point in the history
In a couple of places (administration, jobs, subjects) the texts
that will be visible in UI were not marked as translatable or
were marked incorrectly with gettext where lazy_gettext should
be used. This commit fixes that.
  • Loading branch information
mesemus committed Dec 10, 2024
1 parent ca6e3ae commit d01458d
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 25 deletions.
16 changes: 7 additions & 9 deletions invenio_vocabularies/administration/views/vocabularies.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,20 @@

"""Vocabularies admin interface."""

from invenio_administration.views.base import (
AdminResourceEditView,
AdminResourceListView,
)
from invenio_administration.views.base import AdminResourceListView
from invenio_i18n import lazy_gettext as _


class VocabulariesListView(AdminResourceListView):
"""Configuration for vocabularies list view."""

api_endpoint = "/vocabularies/"
name = "vocabulary-types"
menu_label = "Vocabulary Types"
menu_label = _("Vocabulary Types")
resource_config = "vocabulary_admin_resource"
search_request_headers = {"Accept": "application/json"}
title = "Vocabulary Types"
category = "Site management"
title = _("Vocabulary Types")
category = _("Site management")

pid_path = "id"
icon = "exchange"
Expand All @@ -36,8 +34,8 @@ class VocabulariesListView(AdminResourceListView):
display_create = False

item_field_list = {
"id": {"text": "Name", "order": 1},
"count": {"text": "Number of entries", "order": 2},
"id": {"text": _("Name"), "order": 1},
"count": {"text": _("Number of entries"), "order": 2},
}

search_config_name = "VOCABULARIES_TYPES_SEARCH"
Expand Down
22 changes: 11 additions & 11 deletions invenio_vocabularies/jobs.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import datetime
from datetime import timezone

from invenio_i18n import gettext as _
from invenio_i18n import lazy_gettext as _
from invenio_jobs.jobs import JobType
from marshmallow import Schema, fields
from marshmallow_utils.fields import TZDateTime
Expand Down Expand Up @@ -52,8 +52,8 @@ class ProcessDataStreamJob(JobType):
class ProcessRORAffiliationsJob(ProcessDataStreamJob):
"""Process ROR affiliations datastream registered task."""

description = "Process ROR affiliations"
title = "Load ROR affiliations"
description = _("Process ROR affiliations")
title = _("Load ROR affiliations")
id = "process_ror_affiliations"

@classmethod
Expand Down Expand Up @@ -95,8 +95,8 @@ def default_args(cls, job_obj, since=None, **kwargs):
class ProcessRORFundersJob(ProcessDataStreamJob):
"""Process ROR funders datastream registered task."""

description = "Process ROR funders"
title = "Load ROR funders"
description = _("Process ROR funders")
title = _("Load ROR funders")
id = "process_ror_funders"

@classmethod
Expand Down Expand Up @@ -138,8 +138,8 @@ def default_args(cls, job_obj, since=None, **kwargs):
class ImportAwardsOpenAIREJob(ProcessDataStreamJob):
"""Import awards from OpenAIRE registered task."""

description = "Import awards from OpenAIRE"
title = "Import Awards OpenAIRE"
description = _("Import awards from OpenAIRE")
title = _("Import Awards OpenAIRE")
id = "import_awards_openaire"

@classmethod
Expand Down Expand Up @@ -173,8 +173,8 @@ def default_args(cls, job_obj, **kwargs):
class UpdateAwardsCordisJob(ProcessDataStreamJob):
"""Update awards from CORDIS registered task."""

description = "Update awards from CORDIS"
title = "Update Awards CORDIS"
description = _("Update awards from CORDIS")
title = _("Update Awards CORDIS")
id = "update_awards_cordis"

@classmethod
Expand All @@ -201,8 +201,8 @@ def default_args(cls, job_obj, **kwargs):
class ImportORCIDJob(ProcessDataStreamJob):
"""Import ORCID data registered task."""

description = "Import ORCID data"
title = "Import ORCID data"
description = _("Import ORCID data")
title = _("Import ORCID data")
id = "import_orcid"

@classmethod
Expand Down
5 changes: 4 additions & 1 deletion invenio_vocabularies/records/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"""Vocabulary models."""

from invenio_db import db
from invenio_i18n import gettext as _
from invenio_records.models import RecordMetadataBase


Expand Down Expand Up @@ -79,7 +80,9 @@ def create(cls, **data):
"""Create a new vocabulary subtype."""
banned = [",", ":"]
for b in banned:
assert b not in data["id"], f"No '{b}' allowed in VocabularyScheme.id"
assert b not in data["id"], _(
"No '{banned_char}' allowed in VocabularyScheme.id"
).format(banned_char=b)

with db.session.begin_nested():
obj = cls(**data)
Expand Down
8 changes: 4 additions & 4 deletions invenio_vocabularies/services/custom_fields/subject.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,12 @@ def mapping(self):
ui_widget="SubjectAutocompleteDropdown",
isGenericVocabulary=False,
props=dict(
label="Keywords and subjects",
label=_("Keywords and subjects"),
icon="tag",
description="The subjects related to the community",
placeholder="Search for a subject by name e.g. Psychology ...",
description=_("The subjects related to the community"),
placeholder=_("Search for a subject by name e.g. Psychology ..."),
autocompleteFrom="api/subjects",
noQueryMessage="Search for subjects...",
noQueryMessage=_("Search for subjects..."),
autocompleteFromAcceptHeader="application/vnd.inveniordm.v1+json",
required=False,
multiple=True,
Expand Down

0 comments on commit d01458d

Please sign in to comment.