diff --git a/anyway/widgets/all_locations_widgets/accident_count_by_severity_widget.py b/anyway/widgets/all_locations_widgets/accident_count_by_severity_widget.py index 4412370c..5798fa50 100644 --- a/anyway/widgets/all_locations_widgets/accident_count_by_severity_widget.py +++ b/anyway/widgets/all_locations_widgets/accident_count_by_severity_widget.py @@ -110,8 +110,9 @@ def get_transcription(request_params: RequestParams, items: Dict): incident_keyword=_("accidents"), out_of_them_keywoard=_("out of them (feminine)"), ) + non_empty_texts = [text for text in [severity_fatal_count_text, severity_severe_count_text, severity_light_count_text] if text] text += join_strings( - [severity_fatal_count_text, severity_severe_count_text, severity_light_count_text], + non_empty_texts, sep_a=" ,", sep_b=_(" and "), ) diff --git a/anyway/widgets/all_locations_widgets/injured_count_by_severity_widget.py b/anyway/widgets/all_locations_widgets/injured_count_by_severity_widget.py index 70cd77f8..9b6ceb83 100644 --- a/anyway/widgets/all_locations_widgets/injured_count_by_severity_widget.py +++ b/anyway/widgets/all_locations_widgets/injured_count_by_severity_widget.py @@ -129,8 +129,11 @@ def get_transcription(request_params: RequestParams, items: Dict): people_phrase=_("people from car accidents"), out_of_them_keywoard=_("out of them (masculine plural)"), ) + + non_empty_texts = [text for text in [killed_count_text, severity_severe_count_text, severity_light_count_text] if text] + text += join_strings( - [killed_count_text, severity_severe_count_text, severity_light_count_text], + non_empty_texts, sep_a=" ,", sep_b=_(" and "), )