mirror of
https://github.com/Ark0N/Codeman.git
synced 2026-10-09 08:59:40 +02:00
fix(tiles): a translated tile label is not rewritten on every refresh
Three refreshes compared the DOM with the English source: the tile header's tooltip, the Attach overlay's text and the zoom button's title. With App Settings language set to 简体中文 the i18n observer writes the translation into the DOM, so the comparison never matched again and every chrome refresh (each session:updated, several a second with busy tiles) wrote the English back for the observer to translate once more. Each now remembers the last English value on the tile entry and compares with that. English mode behaves exactly as before. Also: tileShortcutFor's comment still called the inert chord a default pending the owner's answer; it is owner decision 6. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -161,6 +161,44 @@ describe('header button size (owner feedback: the 12px glyphs read as tiny)', ()
|
||||
});
|
||||
});
|
||||
|
||||
describe('a translated label survives a refresh (zh-CN)', () => {
|
||||
// The i18n observer writes the translation into the DOM. Comparing the DOM
|
||||
// with the English source would never match again, so each refresh would
|
||||
// rewrite English for the observer to translate again. The guards compare
|
||||
// with the last English value set instead.
|
||||
it('the header tooltip, the Attach overlay text and the zoom title stay translated until they change', () => {
|
||||
const app = makeGridApp(['s-a', 's-b']);
|
||||
let pill = 'idle';
|
||||
app._sidebarRichRow = () => ({ state: pill, pill, since: { at: 1 } });
|
||||
app._mobileOverviewStampText = () => '3m';
|
||||
app.sessions.get('s-b').pid = null;
|
||||
app.openTileGrid(['s-a', 's-b']);
|
||||
const a = app._tileGrid.tiles.get('s-a');
|
||||
const b = app._tileGrid.tiles.get('s-b');
|
||||
expect(a.header.title).toBe('idle 3m');
|
||||
expect(b.overlayText.textContent).toBe('Not attached');
|
||||
app.zoomTile('s-a');
|
||||
expect(a.zoomBtn.title).toBe('Restore the grid');
|
||||
|
||||
// What the translator does to them.
|
||||
a.header.title = '空闲 3m';
|
||||
b.overlayText.textContent = '未附加';
|
||||
a.zoomBtn.title = '恢复平铺网格';
|
||||
app._renderTileChrome();
|
||||
app._applyTileLayout();
|
||||
expect(a.header.title).toBe('空闲 3m');
|
||||
expect(b.overlayText.textContent).toBe('未附加');
|
||||
expect(a.zoomBtn.title).toBe('恢复平铺网格');
|
||||
|
||||
// A real change still writes the new English, for the translator to take.
|
||||
pill = 'working';
|
||||
app._renderTileChrome();
|
||||
expect(a.header.title).toBe('working 3m');
|
||||
app.zoomTile('s-a');
|
||||
expect(a.zoomBtn.title).toBe('Zoom this tile');
|
||||
});
|
||||
});
|
||||
|
||||
describe('rename', () => {
|
||||
function startRename(app: GridApp, id: string) {
|
||||
headerOf(id).children[1].dispatch('dblclick', { stopPropagation: vi.fn() });
|
||||
|
||||
Reference in New Issue
Block a user