Files
orca/config/scripts/audit-localization-coverage.test.mjs
T
f2d62a7887 fix(i18n): localize the status bar Resource Manager tooltip and remote-host count (#12478)
* fix(i18n): localize the status bar Resource Manager tooltip and remote-host count

The Resource Manager tooltip/aria label and the SSH segment's host count were
assembled from bare English literals inside helper functions, so they stayed
English under every non-English UI language while the labels around them
translated. Route them through the catalog with _one/_other plural keys and
whole-line messages (locales reorder and repunctuate the summary), and add
en/es/ja/ko/zh entries.

Root cause of the miss: audit-localization-coverage bailed on any ancestor
binary expression whose operator was not `+`, which hid every string under a
`cond && <JSX/>` guard or a `?? 'fallback'` — including this segment's
'Connecting…'. Only comparison operands are code, so keep `??`, `||` and
`&&` walking, and localize the four real strings that surfaced.

Co-authored-by: Orca <help@stably.ai>

* fix(status-bar): flag the space-scan tooltip row instead of matching its English text

The tooltip tinted a row with `line === 'Space scan ready'`, so routing that
copy through the catalog silently dropped the tint in every translated build.
Return `{ text, emphasized }` and let the segment read the flag.

Adopted from #12439 by @smwbev.

Co-authored-by: Evgenii <smwbev@users.noreply.github.com>

Co-authored-by: Orca <help@stably.ai>

* fix(status-bar): key Resource Manager tooltip rows by role instead of array index

Co-authored-by: Orca <help@stably.ai>

---------

Co-authored-by: Orca <help@stably.ai>
2026-08-06 19:14:15 -07:00

45 lines
1.3 KiB
JavaScript

import { describe, expect, it } from 'vitest'
import { collectLocalizationCandidates } from './audit-localization-coverage.mjs'
const ROOT = process.cwd()
function candidates(fileName, source) {
return collectLocalizationCandidates(`${ROOT}/src/renderer/src/${fileName}`, source, ROOT)
}
describe('localization coverage candidates', () => {
it('sees copy guarded by a nullish or logical fallback', () => {
const reports = candidates(
'Sample.tsx',
`export function Sample({ label, connecting }) {
return <span>{label ?? (connecting ? 'Connecting…' : 'Idle')}</span>
}`
)
expect(reports.map((report) => report.text)).toEqual(['Connecting…', 'Idle'])
})
it('sees copy nested inside a conditional JSX guard', () => {
const reports = candidates(
'Sample.tsx',
`export function Sample({ show }) {
return <div>{show && <button aria-label="Retry the sync" />}</div>
}`
)
expect(reports.map((report) => report.text)).toEqual(['Retry the sync'])
})
it('ignores literals used as comparison operands', () => {
const reports = candidates(
'Sample.tsx',
`export function Sample({ phase }) {
return <span>{phase === 'workspace conflict' ? phase : null}</span>
}`
)
expect(reports).toEqual([])
})
})