Skip to content
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
11 changes: 11 additions & 0 deletions docs/admin/config.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1922,6 +1922,17 @@

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
Expand Down Expand Up @@ -2021,7 +2032,7 @@

.. seealso::

`OpenSSH Legacy Options <https://www.openssh.com/legacy.html>`_

Check warning on line 2035 in docs/admin/config.rst

View workflow job for this annotation

GitHub Actions / Linkcheck

https://www.openssh.com/legacy.html to https://www.openssh.org/legacy.html

.. setting:: STATUS_URL

Expand Down
4 changes: 4 additions & 0 deletions docs/admin/install/docker.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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`.
Expand Down
5 changes: 5 additions & 0 deletions weblate/settings_docker.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
3 changes: 3 additions & 0 deletions weblate/settings_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
11 changes: 8 additions & 3 deletions weblate/trans/views/basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -276,7 +277,7 @@
request=request,
language=language_object,
initial=SearchForm.get_initial(request),
obj=obj,

Check failure on line 280 in weblate/trans/views/basic.py

View workflow job for this annotation

GitHub Actions / mypy

Argument "obj" to "SearchForm" has incompatible type "ProjectLanguage"; expected "type[Model] | type[BaseURLMixin] | None"
bootstrap_5=True,
),
"announcement_form": optional_form(
Expand Down Expand Up @@ -381,9 +382,13 @@
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
Expand Down Expand Up @@ -606,7 +611,7 @@
"search_form": SearchForm(
request=request,
initial=SearchForm.get_initial(request),
obj=obj,

Check failure on line 614 in weblate/trans/views/basic.py

View workflow job for this annotation

GitHub Actions / mypy

Argument "obj" to "SearchForm" has incompatible type "Component"; expected "type[Model] | type[BaseURLMixin] | None"
bootstrap_5=True,
),
"alerts": obj.all_active_alerts
Expand Down Expand Up @@ -809,7 +814,7 @@
if form.is_valid():
languages = Language.objects.filter(code__in=form.cleaned_data["lang"])
language_map = {lang.code: lang for lang in languages}
lang_counters = {lang_code: Counter() for lang_code in language_map}

Check failure on line 817 in weblate/trans/views/basic.py

View workflow job for this annotation

GitHub Actions / mypy

Need type annotation for "lang_counters"

for component in eligible_components:
_, component_counts = add_languages_to_component(
Expand Down Expand Up @@ -901,12 +906,12 @@
"component": component,
"details": {},
}
lang_counts = Counter()

Check failure on line 909 in weblate/trans/views/basic.py

View workflow job for this annotation

GitHub Actions / mypy

Need type annotation for "lang_counts"
with component.repository.lock:
component.commit_pending("add language", None)
for language in languages:
lang_code = language.code
kwargs["details"]["language"] = lang_code

Check failure on line 914 in weblate/trans/views/basic.py

View workflow job for this annotation

GitHub Actions / mypy

Unsupported target for indexed assignment ("object")

if component.can_add_new_language(user):
translation = component.add_new_language(
Expand All @@ -919,7 +924,7 @@
added = True
kwargs["translation"] = translation
if len(languages) == 1:
result = translation

Check failure on line 927 in weblate/trans/views/basic.py

View workflow job for this annotation

GitHub Actions / mypy

Incompatible types in assignment (expression has type "Translation", variable has type "Component")
component.change_set.create(
action=ActionEvents.ADDED_LANGUAGE, **kwargs
)
Expand Down Expand Up @@ -957,7 +962,7 @@
"All languages have been added, updates of translations are in progress."
),
)
result = "{}?info=1".format(

Check failure on line 965 in weblate/trans/views/basic.py

View workflow job for this annotation

GitHub Actions / mypy

Incompatible types in assignment (expression has type "str", variable has type "Component")
reverse(
"show_progress",
kwargs={"path": result.get_url_path()},
Expand Down
Loading