From 60719bdfcc9824bc687dddb6d56f503235e38759 Mon Sep 17 00:00:00 2001 From: Rodrigo Martin Date: Tue, 16 Jul 2024 20:29:49 -0300 Subject: [PATCH] Fix/au 2128 (#35124) * fix: update condition to always return a value * feat: add comments on logic --- xmodule/video_block/transcripts_utils.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/xmodule/video_block/transcripts_utils.py b/xmodule/video_block/transcripts_utils.py index 417c78cc3489..e41f925295f0 100644 --- a/xmodule/video_block/transcripts_utils.py +++ b/xmodule/video_block/transcripts_utils.py @@ -866,11 +866,12 @@ def get_default_transcript_language(self, transcripts, dest_lang=None): """ sub, other_lang = transcripts["sub"], transcripts["transcripts"] - if dest_lang: - if dest_lang in other_lang.keys(): - transcript_language = dest_lang - elif dest_lang == 'en' and (not other_lang or (other_lang and sub)): - transcript_language = 'en' + # language in plugin selector exists as transcript + if dest_lang and dest_lang in other_lang.keys(): + transcript_language = dest_lang + # language in plugin selector is english and empty transcripts or transcripts and sub exists + elif dest_lang and dest_lang == 'en' and (not other_lang or (other_lang and sub)): + transcript_language = 'en' elif self.transcript_language in other_lang: transcript_language = self.transcript_language elif sub: