Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

i18n: add Translations Missing Entry Point #242

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 9 additions & 57 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
# This file is part of Invenio.
# Copyright (C) 2020 CERN.
# Copyright (C) 2022 Graz University of Technology.
# 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.
Expand All @@ -11,9 +12,11 @@ name: CI

on:
push:
branches: master
branches:
- master
pull_request:
branches: master
branches:
- master
schedule:
# * is a special character in YAML so you have to quote this string
- cron: '0 3 * * 6'
Expand All @@ -25,58 +28,7 @@ on:
default: 'Manual trigger'

jobs:
Tests:
runs-on: ubuntu-20.04
timeout-minutes: 20
strategy:
matrix:
python-version: [3.8, 3.9]
requirements-level: [pypi]
db-service: [postgresql14,postgresql13,mysql8]
mq-service: [rabbitmq]
search-service: [opensearch2,elasticsearch7]
include:
- db-service: postgresql14
DB_EXTRAS: "postgresql"

- db-service: postgresql13
DB_EXTRAS: "postgresql"

- db-service: mysql8
DB_EXTRAS: "mysql"
env:
DB: ${{ matrix.db-service }}
MQ: ${{ matrix.mq-service }}
SEARCH: ${{ matrix.search-service }}
EXTRAS: tests,${{ matrix.search-service }}
steps:
- name: Checkout
uses: actions/checkout@v2

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}

- name: Generate dependencies
run: |
pip install wheel requirements-builder
requirements-builder -e "$EXTRAS" --level=${{ matrix.requirements-level }} setup.py > .${{ matrix.requirements-level }}-${{ matrix.python-version }}-requirements.txt

- name: Cache pip
uses: actions/cache@v2
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('.${{ matrix.requirements-level }}-${{ matrix.python-version }}-requirements.txt') }}

- name: Install dependencies
run: |
pip install -r .${{ matrix.requirements-level }}-${{ matrix.python-version }}-requirements.txt
pip install ".[$EXTRAS]"
pip freeze
docker --version
docker compose --version

- name: Run tests
run: |
./run-tests.sh
Python:
uses: inveniosoftware/workflows/.github/workflows/tests-python.yml@master
with:
extras: "tests"
7 changes: 2 additions & 5 deletions invenio_oaiserver/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,19 @@
#
# This file is part of Invenio.
# Copyright (C) 2015-2018 CERN.
# 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.

"""Admin model views for OAI sets."""

from flask_admin.contrib.sqla import ModelView
from invenio_i18n import gettext as _

from .models import OAISet


def _(x):
"""Identity."""
return x


class OAISetModelView(ModelView):
"""OAISets model view."""

Expand Down
3 changes: 2 additions & 1 deletion invenio_oaiserver/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
# This file is part of Invenio.
# Copyright (C) 2015-2022 CERN.
# Copyright (C) 2022 Graz University of Technology.
# 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.
Expand Down Expand Up @@ -79,7 +80,7 @@ class OAISet(db.Model, Timestamp):
def validate_spec(self, key, value):
"""Forbit updates of set identifier."""
if self.spec and self.spec != value:
raise OAISetSpecUpdateError("Updating spec is not allowed.")
raise OAISetSpecUpdateError(_("Updating spec is not allowed."))
return value


Expand Down
6 changes: 5 additions & 1 deletion invenio_oaiserver/percolator.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
# This file is part of Invenio.
# Copyright (C) 2017-2024 CERN.
# Copyright (C) 2022 Graz University of Technology.
# 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.
Expand All @@ -12,6 +13,7 @@
import json

from flask import current_app
from invenio_i18n import lazy_gettext as _
from invenio_indexer.api import RecordIndexer
from invenio_search import current_search, current_search_client
from invenio_search.engine import search
Expand Down Expand Up @@ -128,7 +130,9 @@ def create_percolate_query(
)
else:
raise Exception(
"Either documents or (document_search_ids and document_search_indices) must be specified."
_(
"Either documents or (document_search_ids and document_search_indices) must be specified."
)
)

if percolator_ids:
Expand Down
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 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
3 changes: 3 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
# This file is part of Invenio.
# Copyright (C) 2015-2018 CERN.
# Copyright (C) 2022 Graz University of Technology.
# 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.
Expand Down Expand Up @@ -73,6 +74,8 @@ invenio_pidstore.minters =
oaiid = invenio_oaiserver.minters:oaiid_minter
invenio_pidstore.fetchers =
oaiid = invenio_oaiserver.fetchers:oaiid_fetcher
invenio_i18n.translations =
invenio_oaiserver = invenio_oaiserver

[build_sphinx]
source-dir = docs/
Expand Down