Reapplies PR 4269 that was reverted and resolves the mentioned issue.
The error occurred because the language Tagalog was stored in the LanguageTag model without a corresponding name_t (Name for translation) in the LanguageTagTranslation model. This caused an error when the existing get_search_facet_display method looked for a corresponding name for translation.
Resolution
I've added a validation check to verify the existence of the corresponding name_t (Name for translation) in the LanguageTagTranslation model before accessing it, furthermore I have disabled the translation flag for get_transcript_languages_search_facet_names because we do not require translated transcript language names, and not all languages stored in transcript_languages have a corresponding name for translation stored.
File "/edx/app/discovery/discovery/course_discovery/apps/api/serializers.py", line 1096, in get_transcript_languages_search_facet_names
transcript_languages_facet_names.append(language.get_search_facet_display(translate=True))
File "/edx/app/discovery/discovery/course_discovery/apps/ietf_language_tags/models.py", line 29, in get_search_facet_display
return self.translated_macrolanguage if translate else self.macrolanguage
File "/edx/app/discovery/discovery/course_discovery/apps/ietf_language_tags/models.py", line 22, in translated_macrolanguage
return self.name_t.split('-')[0].strip()
File "/edx/app/discovery/venvs/discovery/lib/python3.8/site-packages/parler/fields.py", line 142, in __get__
translation = instance._get_translated_model(use_fallback=True, meta=meta)
File "/edx/app/discovery/venvs/discovery/lib/python3.8/site-packages/parler/models.py", line 620, in _get_translated_model
raise meta.model.DoesNotExist(
parler.models.DoesNotExist: language tag does not have a translation for the current language!
language tag ID #tl, language=en (tried fallbacks en)
Attempted to read attribute name_t.
Ticket
ENT-8400
Description
Tagalog
was stored in theLanguageTag
model without a correspondingname_t
(Name for translation) in theLanguageTagTranslation
model. This caused an error when the existingget_search_facet_display
method looked for a corresponding name for translation.Resolution
I've added a validation check to verify the existence of the corresponding
name_t
(Name for translation) in theLanguageTagTranslation
model before accessing it, furthermore I have disabled the translation flag forget_transcript_languages_search_facet_names
because we do not require translated transcript language names, and not all languages stored in transcript_languages have a corresponding name for translation stored.