|
48 | 48 | import functools |
49 | 49 | import psutil |
50 | 50 | from psutil._common import bytes2human # pyright:ignore[reportPrivateImportUsage] |
51 | | -from babel.units import get_unit_name |
52 | 51 |
|
53 | 52 | from collections.abc import Callable, Sequence |
54 | 53 | from typing import override, Final, Literal, Any, cast, TYPE_CHECKING |
@@ -9383,17 +9382,24 @@ def default_xlabel_text(self) -> str: |
9383 | 9382 | if self.flagstart or self.xgrid == 0: |
9384 | 9383 | return '' |
9385 | 9384 | if self.roastersize_setup == 0 and self.roastertype_setup == '': |
| 9385 | + |
9386 | 9386 | if self.aw.qmc.xgrid < 3600: |
| 9387 | + res = 'mins' |
| 9388 | + if self.aw.locale_str != 'en': |
| 9389 | + try: |
| 9390 | + from babel.units import get_unit_name |
| 9391 | + res = get_unit_name('duration-minute', length='short', locale=self.aw.locale_str) or 'mins' |
| 9392 | + except Exception as e: # pylint: disable=broad-except # UnknownLocaleError |
| 9393 | + _log.exception(e) |
| 9394 | + return res |
| 9395 | + res = 'h' |
| 9396 | + if self.aw.locale_str != 'en': |
9387 | 9397 | try: |
9388 | | - return get_unit_name('duration-minute', length='short', locale=self.aw.locale_str) or 'min' |
| 9398 | + from babel.units import get_unit_name |
| 9399 | + return get_unit_name('duration-hour', length='short', locale=self.aw.locale_str) or 'h' |
9389 | 9400 | except Exception as e: # pylint: disable=broad-except # UnknownLocaleError |
9390 | 9401 | _log.exception(e) |
9391 | | - return get_unit_name('duration-minute', length='short', locale='en') or 'min' |
9392 | | - try: |
9393 | | - return get_unit_name('duration-hour', length='short', locale=self.aw.locale_str) or 'h' |
9394 | | - except Exception as e: # pylint: disable=broad-except # UnknownLocaleError |
9395 | | - _log.exception(e) |
9396 | | - return get_unit_name('duration-hour', length='short', locale='en') or 'h' |
| 9402 | + return res |
9397 | 9403 | if right_to_left(self.locale_str): |
9398 | 9404 | return f"{(render_weight(self.roastersize_setup, 1, weight_units.index(self.weight[2]), right_to_left_lang=True) if self.roastersize_setup>=0 else '')} {self.__dijkstra_to_ascii(self.roastertype_setup)}" |
9399 | 9405 | return f"{self.__dijkstra_to_ascii(self.roastertype_setup)} {(render_weight(self.roastersize_setup, 1, weight_units.index(self.weight[2])) if self.roastersize_setup>0 else '')}" |
|
0 commit comments