Keep the news at the end of a tile's line: a shorter "Yest. 9:15 PM" and a robot's battery that stays
A tile has one line under the name, and LVGL cuts what doesn't fit off the end, which is where that line often carries what you want to read. Two lines lost it: - "Yesterday 9:15 PM" (English with a 12-hour clock) read "Yesterday 9:1…" on both boards. The tile now takes a shorter wording of the same line when the full one doesn't fit, screen.script.yesterday_time_short; every language whose word is short enough keeps the same text there. - A robot's battery stood behind Home Assistant's own word for its state, so German, French and Polish showed "Angedockt / 10…". The battery keeps its room now and the word takes the dots: "Angedo… / 10 %". `tools/i18n.py check` measures a tile line with a 12-hour clock in its placeholder, so a translation that is too long for the line fails there. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
+10
-3
@@ -133,10 +133,13 @@ def check():
|
||||
if ours and code != 'en' and len(text) > max(8, len(source) * 1.6) and not plural:
|
||||
notes.append(f'{code}: {key} is much longer than the English ({len(text)} vs {len(source)})')
|
||||
if width and key in TILE_LINES:
|
||||
shown_text = text
|
||||
for name, sample in TILE_SAMPLES.items():
|
||||
shown_text = shown_text.replace('{' + name + '}', sample)
|
||||
for board, (size, room) in TILE_LINES[key].items():
|
||||
if width(size, text) > room:
|
||||
problems.append(f'{code}: {key} "{text}" is too wide for a tile on the {board} '
|
||||
f'({width(size, text):.0f} of {room} px); make it shorter')
|
||||
if width(size, shown_text) > room:
|
||||
problems.append(f'{code}: {key} "{shown_text}" is too wide for a tile on the {board} '
|
||||
f'({width(size, shown_text):.0f} of {room} px); make it shorter')
|
||||
# The weather columns of the CYD hold a day of two letters beside its icon.
|
||||
if key.startswith('screen.date.weekdays_min.') and len(text) > 2:
|
||||
problems.append(f'{code}: {key} "{text}" is longer than two letters; the CYD\'s weather columns cut it')
|
||||
@@ -154,8 +157,12 @@ TILE_ROOM = {'CYD': (11, 88), 'Guition': (16, 128)}
|
||||
# Camera tiles are the Guition's alone.
|
||||
TILE_LINES = {'screen.tile.tap_to_open': TILE_ROOM, 'screen.script.never_run': TILE_ROOM, 'screen.script.running': TILE_ROOM,
|
||||
'screen.media.not_playing': TILE_ROOM, 'screen.timer.paused': TILE_ROOM,
|
||||
'screen.script.last_time': TILE_ROOM, 'screen.script.yesterday_time_short': TILE_ROOM,
|
||||
'screen.camera.tap_to_view': {'Guition': TILE_ROOM['Guition']},
|
||||
'screen.camera.no_image_yet': {'Guition': TILE_ROOM['Guition']}}
|
||||
# What a placeholder stands for while a tile line is measured: the widest clock a screen writes is a 12-hour one
|
||||
# with its AM/PM ("Yesterday 9:15 PM" is why screen.script.yesterday_time_short exists).
|
||||
TILE_SAMPLES = {'time': '9:15 PM'}
|
||||
|
||||
|
||||
def text_width():
|
||||
|
||||
Reference in New Issue
Block a user