Skip to content

Commit

Permalink
i18n: add translation for verbs.py
Browse files Browse the repository at this point in the history
  • Loading branch information
Samk13 committed Oct 28, 2024
1 parent 0489c0d commit e2f644a
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions invenio_oaiserver/verbs.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,15 @@
# Copyright (C) 2015-2018 CERN.
# Copyright (C) 2021-2022 Graz University of Technology.
# Copyright (C) 2022 RERO.
# 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.

"""OAI-PMH verbs."""

from flask import current_app, request
from invenio_i18n import lazy_gettext as _
from invenio_rest.serializer import BaseSchema
from marshmallow import ValidationError, fields, validates_schema
from marshmallow.fields import DateTime as _DateTime
Expand All @@ -28,7 +30,7 @@ def validate_metadata_prefix(value, **kwargs):
metadataFormats = current_app.config["OAISERVER_METADATA_FORMATS"]
if value not in metadataFormats:
raise ValidationError(
"metadataPrefix does not exist", field_names=["metadataPrefix"]
_("metadataPrefix does not exist"), field_names=["metadataPrefix"]
)


Expand Down Expand Up @@ -88,12 +90,13 @@ def validate(self, data, **kwargs):
if "verb" in data and data["verb"] != self.__class__.__name__:
raise ValidationError(
# FIXME encode data
"This is not a valid OAI-PMH verb:{0}".format(data["verb"]),
_("This is not a valid OAI-PMH verb:{0}").format(data["verb"]),
field_names=["verb"],
)

if "from_" in data and "until" in data and data["from_"] > data["until"]:
raise ValidationError('Date "from" must be before "until".')

raise ValidationError(_('Date "from" must be before "until".'))


class Verbs(object):
Expand Down Expand Up @@ -162,7 +165,7 @@ def check_extra_params_in_request(verb):
]
)
if extra:
raise ValidationError({"_schema": ["You have passed too many arguments."]})
raise ValidationError({"_schema": [_("You have passed too many arguments.")]})


def make_request_validator(request):
Expand Down

0 comments on commit e2f644a

Please sign in to comment.