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