(direction: str, response_language: str = "zh")
| 1150 | |
| 1151 | def _format_direction_label(direction: str, response_language: str = "zh") -> str: |
| 1152 | language = _normalize_response_language(response_language) |
| 1153 | normalized = str(direction or "").strip() |
| 1154 | if not normalized: |
| 1155 | return "Current direction" if language == "en" else "当前方向" |
| 1156 | formatter = getattr(direction_lexicon, "format_direction_label", None) |
| 1157 | if callable(formatter): |
| 1158 | label = str(formatter(normalized, prefer_chinese=(language != "en")) or "").strip() |
| 1159 | if label: |
| 1160 | return label |
| 1161 | lowered = normalized.lower() |
| 1162 | if language == "en": |
| 1163 | return ( |
| 1164 | normalized.replace("-", " ").replace("_", " ").title().replace("Gui", "GUI").replace("Ai", "AI") |
| 1165 | ) |
| 1166 | if lowered in DIRECTION_LABELS: |
| 1167 | return DIRECTION_LABELS[lowered] |
| 1168 | if any("\u4e00" <= ch <= "\u9fff" for ch in normalized): |
| 1169 | return normalized |
| 1170 | return ( |
| 1171 | normalized.replace("-", " ").replace("_", " ").title().replace("Gui", "GUI").replace("Ai", "AI") |
| 1172 | ) |
| 1173 | |
| 1174 | |
| 1175 | def _format_authors(authors: Any) -> str: |
| 1176 | names = _parse_jsonish_list(authors) |
no test coverage detected