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

[Backport 4.0.x] [Fixes #10976] Fix thesaurus labels translations #10992

Merged
merged 1 commit into from
May 2, 2023
Merged
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
3 changes: 3 additions & 0 deletions geonode/base/templatetags/thesaurus.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from django import template
from django.utils.translation import get_language
from geonode.base.models import Thesaurus, ThesaurusKeywordLabel, ThesaurusLabel
from geonode.base.utils import remove_country_from_languagecode

register = template.Library()

Expand All @@ -24,6 +25,7 @@ def get_thesaurus_date(thesaurus_id):
@register.filter
def get_name_translation(tidentifier):
lang = get_language()
lang = remove_country_from_languagecode(lang)
available = Thesaurus.objects.filter(identifier=tidentifier)
if not available.exists():
raise ObjectDoesNotExist("Selected idenfifier does not exists")
Expand All @@ -48,6 +50,7 @@ def get_thesaurus_translation_by_id(id):
@register.filter
def get_thesaurus_localized_label(tkeyword):
lang = get_language()
lang = remove_country_from_languagecode(lang)
translation = (
ThesaurusKeywordLabel.objects.values_list("label", flat=True)
.filter(keyword__id=tkeyword.id)
Expand Down