def get_caption_group_together(self): """ A descriptive text for the group_together option. """ caption = "" if self.group_together: if self.cardinality is None: loop_dict = self.group_together else: # Looping only on the value really used in the answers loop_dict = self.cardinality has_and = False for key in loop_dict: values = self.group_together.get(key) if values is None: # group_together does not contain every answers continue standardized_values = Question.standardize_list( values, self.group_by_letter_case, self.group_by_slugify ) standardized_key = Question.standardize(key, self.group_by_letter_case, self.group_by_slugify) relevant_values = [v for v in standardized_values if v != standardized_key] if not relevant_values: # If there is no relevant value the group_together was just # a placeholder ex Yes for [yes Yës yEs] continue # We duplicate the translations so makemessage find it caption += "with '{}' standing for ".format(key) for value in values: caption += "'{}' {} ".format(value, _("or")) caption = caption[: -len("{} ".format(_("or")))] has_and = True caption += "{} ".format(_("and")) if has_and: # We remove the final "and " if there is one caption = caption[: -len("{} ".format(_("and")))] return caption