Skip to content

Commit

Permalink
i18n: mark translations for end user msgs
Browse files Browse the repository at this point in the history
  • Loading branch information
Samk13 authored and Sam Arbid committed Oct 19, 2024
1 parent e6c3901 commit bc30415
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 19 deletions.
4 changes: 2 additions & 2 deletions invenio_communities/communities/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -321,8 +321,8 @@ class CommunityFeaturedSchema(Schema):
id = fields.Int(dump_only=True)
start_date = fields.DateTime(
required=True,
title="start date",
description="Accepted format: YYYY-MM-DD hh:mm",
title=_("start date"),
description=_("Accepted format: YYYY-MM-DD hh:mm"),
placeholder="YYYY-MM-DD hh:mm",
)

Expand Down
4 changes: 3 additions & 1 deletion invenio_communities/communities/services/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
# Copyright (C) 2021-2022 Northwestern University.
# Copyright (C) 2022 Graz University of Technology.
# Copyright (C) 2024 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 @@ -13,6 +14,7 @@

from flask import current_app
from invenio_cache.decorators import cached_with_expiration
from invenio_i18n import lazy_gettext as _
from invenio_records_resources.proxies import current_service_registry
from invenio_records_resources.services.base import LinksTemplate
from invenio_records_resources.services.records import (
Expand Down Expand Up @@ -203,7 +205,7 @@ def rename(

if "slug" not in data:
raise ValidationError(
"Missing data for required field.",
_("Missing data for required field."),
field_name="slug",
)

Expand Down
7 changes: 5 additions & 2 deletions invenio_communities/roles.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# -*- coding: utf-8 -*-
#
# Copyright (C) 2022 CERN.
# Copyright (C) 2024 KTH Royal Institute of Technology.
#
# Invenio-Communities 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 @@ -9,6 +10,8 @@

from dataclasses import dataclass, field

from invenio_i18n import lazy_gettext as _


@dataclass(frozen=True)
class Role:
Expand Down Expand Up @@ -58,9 +61,9 @@ def __init__(self, roles_definitions):

for r in self._roles:
if r.is_owner:
assert self._owner is None, "Only one role be defined as owner."
assert self._owner is None, _("Only one role be defined as owner.")
self._owner = r
assert self._owner is not None, "One role must be defined as owner."
assert self._owner is not None, _("One role must be defined as owner.")

def __contains__(self, key):
"""Determine if key is a valid role id."""
Expand Down
4 changes: 3 additions & 1 deletion invenio_communities/subcommunities/services/schema.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
# -*- coding: utf-8 -*-
#
# Copyright (C) 2024 CERN.
# Copyright (C) 2024 KTH Royal Institute of Technology.
#
# Invenio-Communities is free software; you can redistribute it and/or modify
# it under the terms of the MIT License; see LICENSE file for more details.
"""Subcommunities service schemas."""

from invenio_i18n import lazy_gettext as _
from marshmallow import Schema, ValidationError, fields, post_load, pre_load


Expand Down Expand Up @@ -45,6 +47,6 @@ def validate(self, data, **kwargs):
"""Validate that either community_id or community is provided."""
if "community_id" not in data and "community" not in data:
raise ValidationError(
"Either community_id or community should be provided."
_("Either community_id or community should be provided.")
)
return data
25 changes: 12 additions & 13 deletions invenio_communities/views/communities.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) 2016-2024 CERN.
# Copyright (C) 2023 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 @@ -28,15 +29,15 @@

VISIBILITY_FIELDS = [
{
"text": "Public",
"text": _("Public"),
"value": "public",
"icon": "group",
"helpText": _(
"Your community is publicly accessible" " and shows up in search results."
),
},
{
"text": "Restricted",
"text": _("Restricted"),
"value": "restricted",
"icon": "lock",
"helpText": _("Your community is restricted to users" " with access."),
Expand All @@ -45,7 +46,7 @@

MEMBERS_VISIBILITY_FIELDS = [
{
"text": "Public",
"text": _("Public"),
"value": "public",
"icon": "group",
"helpText": _(
Expand All @@ -54,7 +55,7 @@
),
},
{
"text": "Members-only",
"text": _("Members-only"),
"value": "restricted",
"icon": "lock",
"helpText": _(
Expand All @@ -66,7 +67,7 @@

RECORDS_SUBMISSION_POLICY_FIELDS = [
{
"text": "Open",
"text": _("Open"),
"value": "open",
"icon": "lock open",
"helpText": _(
Expand All @@ -75,31 +76,30 @@
),
},
{
"text": "Closed",
"text": _("Closed"),
"value": "closed",
"icon": "lock",
"helpText": _("Only members can submit records to the community."),
},
]


REVIEW_POLICY_FIELDS = [
{
"text": "Review all submissions",
"text": _("Review all submissions"),
"value": "closed",
"icon": "lock",
"helpText": _("All submissions to the community must be reviewed."),
},
{
"text": "Allow curators, managers and owners to publish without review",
"text": _("Allow curators, managers and owners to publish without review"),
"value": "open",
"icon": "group",
"helpText": _(
"Submissions to the community by default requires review, but curators, managers and owners can publish directly without review."
),
},
{
"text": "Allow all members to publish without review",
"text": _("Allow all members to publish without review"),
"value": "members",
"icon": "lock open",
"helpText": _(
Expand All @@ -108,16 +108,15 @@
},
]


MEMBER_POLICY_FIELDS = [
{
"text": "Open",
"text": _("Open"),
"value": "open",
"icon": "user plus",
"helpText": _("Users can request to join your community."),
},
{
"text": "Closed",
"text": _("Closed"),
"value": "closed",
"icon": "user times",
"helpText": _(
Expand Down

0 comments on commit bc30415

Please sign in to comment.