diff --git a/docs/admin/config.rst b/docs/admin/config.rst index 3ce41b61787b..f18551cac231 100644 --- a/docs/admin/config.rst +++ b/docs/admin/config.rst @@ -1922,6 +1922,17 @@ for these default combinations. Turn this off if you want to different translations for each variant. +.. setting:: HIDE_SHARED_GLOSSARY_COMPONENTS + +HIDE_SHARED_GLOSSARY_COMPONENTS +------------------------------- + +Glossary components are typically shared into other projects to +make them available for translation work. +When these are visible in the component list of projects which are +using them, it can cause confusion or distract translators from +the actual components that are meant to be translated. + .. setting:: SITE_DOMAIN SITE_DOMAIN diff --git a/docs/admin/install/docker.rst b/docs/admin/install/docker.rst index ed6813b1f59a..6e3b2d3b93d9 100644 --- a/docs/admin/install/docker.rst +++ b/docs/admin/install/docker.rst @@ -849,6 +849,10 @@ Generic settings Configures the language simplification policy, see :setting:`SIMPLIFY_LANGUAGES`. +.. envvar:: WEBLATE_HIDE_SHARED_GLOSSARY_COMPONENTS + + Hides glossary components when shared to other projects, see :setting:`HIDE_SHARED_GLOSSARY_COMPONENTS`. + .. envvar:: WEBLATE_DEFAULT_ACCESS_CONTROL Configures the default :ref:`project-access_control` for new projects, see :setting:`DEFAULT_ACCESS_CONTROL`. diff --git a/weblate/settings_docker.py b/weblate/settings_docker.py index 6d9e006f79e0..7deeacab4b36 100644 --- a/weblate/settings_docker.py +++ b/weblate/settings_docker.py @@ -1044,6 +1044,11 @@ # Use simple language codes for default language/country combinations SIMPLIFY_LANGUAGES = get_env_bool("WEBLATE_SIMPLIFY_LANGUAGES", True) +# This allows to hide glossary components when shared to other projects +HIDE_SHARED_GLOSSARY_COMPONENTS = get_env_bool( + "WEBLATE_HIDE_SHARED_GLOSSARY_COMPONENTS", False +) + # Default number of elements to display when pagination is active DEFAULT_PAGE_LIMIT = get_env_int("WEBLATE_DEFAULT_PAGE_LIMIT", 100) diff --git a/weblate/settings_example.py b/weblate/settings_example.py index 628af7db8543..0e6bdc142a8f 100644 --- a/weblate/settings_example.py +++ b/weblate/settings_example.py @@ -697,6 +697,9 @@ # Use simple language codes for default language/country combinations SIMPLIFY_LANGUAGES = True +# This allows to hide glossary components when shared to other projects +HIDE_SHARED_GLOSSARY_COMPONENTS = False + # Render forms using bootstrap CRISPY_ALLOWED_TEMPLATE_PACKS = ["bootstrap3", "bootstrap5"] CRISPY_TEMPLATE_PACK = "bootstrap3" diff --git a/weblate/trans/views/basic.py b/weblate/trans/views/basic.py index ef29d3a920b0..549ae536585b 100644 --- a/weblate/trans/views/basic.py +++ b/weblate/trans/views/basic.py @@ -6,6 +6,7 @@ from collections import Counter from typing import TYPE_CHECKING, Any +from django.conf import settings from django.contrib.auth.decorators import login_required from django.db import transaction from django.db.models import Q @@ -381,9 +382,13 @@ def show_project(request: AuthenticatedHttpRequest, obj): last_changes = all_changes.recent() last_announcements = all_changes.filter_announcements().recent() - all_components = obj.get_child_components_access( - user, lambda qs: qs.filter(category=None) - ) + def filter_components(qs): + qs = qs.filter(category=None) + if settings.HIDE_SHARED_GLOSSARY_COMPONENTS: + qs = qs.exclude(Q(is_glossary=True) & ~Q(project=obj)) + return qs + + all_components = obj.get_child_components_access(user, filter_components) all_components = get_paginator(request, all_components, stats=True) for component in all_components: component.is_shared = None if component.project == obj else component.project