fix(desktop): localize macOS application menu names
This commit is contained in:
1 parent
8cf9c0eded
commit
fd75c47ae9
8 files changed
+69
-6
No files matched your search
@@ -2,5 +2,5 @@
|
||||
# side as of the last confirmed-consistent state. Both languages carry equal authority;
|
||||
# after editing either side, bring the other along and re-record with:
|
||||
# pnpm run verify-translation-pairing --write apps/desktop/README.md
|
||||
README.md: 6c9a6a8784732e6fa1369df5632391b789786b22
|
||||
README.zh.md: a0f2184d911eeab46902670cf992b6847e2bca31
|
||||
README.md: da4db5806b8ca50e14fc2e95d579cbcf0e50bb77
|
||||
README.zh.md: 8d43dbde6b829555203b39d06c71b367f318e14b
|
||||
@@ -4,7 +4,7 @@ English | [中文](README.zh.md)
|
||||
|
||||
The desktop application is an Electron shell around the complete dsh Web application. An Electron RunAsNode child starts the shared profile runner, and Electron immediately loads the packaged Web entry at `dsh-app://app/`. Its shared loading page waits for Host boot injections, then starts the client without navigating to another document. Electron forwards application HTTP requests to the authenticated Web Host; WebSocket streams connect to that Host with credentials attached only for the owned application window. Node IPC carries boot injections, readiness, and shutdown. Desktop defaults to port `19387`, separate from Web’s `3080`; a `webserver.config.port` patch can override it.
|
||||
|
||||
The first application-menu command, **About DeepSeek Harness**, opens Electron's native About panel with the application icon, product name, and installed release version. The menu follows the Desktop shell locale. macOS reads the icon from its application bundle, so an unpackaged development launch displays Electron's icon; Windows receives the packaged PNG.
|
||||
The first application-menu command, **About DeepSeek Harness**, opens Electron's native About panel with the application icon, product name, and installed release version. The menu follows the Desktop shell locale. On macOS, Hide, Hide Others, Show All, and Quit use localized labels; Hide and Quit include the DeepSeek Harness product name. These commands retain their native actions and shortcuts. macOS reads the icon from its application bundle, so an unpackaged development launch displays Electron's icon; Windows receives the packaged PNG.
|
||||
|
||||
Desktop’s local native directory flow opens an Electron folder dialog attached to the application window, restoring, showing, and focusing that window first. Concurrent requests share one dialog; cancellation returns no path and failures remain retryable. Ordinary Web uses the Host chooser. Browse mode lists Host directories. On Linux without zenity or kdialog, automatic selection uses browse instead of the Electron dialog.
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
桌面应用是完整 dsh Web 应用外的一层 Electron 壳。Electron RunAsNode 子进程启动共享 profile runner,Electron 立即从 `dsh-app://app/` 加载打包内的 Web 入口。共享加载页等待 Host 启动注入,然后在同一文档中启动客户端。Electron 将应用 HTTP 请求转发给已认证的 Web Host;WebSocket 流连接到该 Host,仅为归属的应用窗口附加凭据。Node IPC 承载启动注入、就绪与关闭。Desktop 默认使用端口 `19387`,与 Web 的 `3080` 分开;可通过 `webserver.config.port` patch 覆盖。
|
||||
|
||||
应用菜单第一项“**关于 DeepSeek Harness**”打开 Electron 原生关于面板,展示应用图标、产品名称和当前安装的发布版本。菜单文案跟随桌面壳的语言。macOS 从应用包读取图标,因此未打包的开发启动会显示 Electron 图标;Windows 使用随包分发的 PNG。
|
||||
应用菜单第一项“**关于 DeepSeek Harness**”打开 Electron 原生关于面板,展示应用图标、产品名称和当前安装的发布版本。菜单文案跟随桌面壳的语言。macOS 的隐藏、隐藏其他、显示全部和退出条目使用本地化文案,隐藏和退出条目包含 DeepSeek Harness 产品名称。这些条目保留原生动作和快捷键。macOS 从应用包读取图标,因此未打包的开发启动会显示 Electron 图标;Windows 使用随包分发的 PNG。
|
||||
|
||||
Desktop 的本地原生目录流程打开绑定应用窗口的 Electron 文件夹对话框,并先恢复、显示和聚焦该窗口。并发请求共用一个对话框;取消不返回路径,失败后可以重试。普通 Web 使用 Host 选择器。浏览模式列出 Host 目录。Linux 缺少 zenity 或 kdialog 时,自动选择使用浏览模式,不使用 Electron 对话框。
|
||||
|
||||
|
||||
@@ -3,6 +3,10 @@
|
||||
export const en = {
|
||||
application: 'Application',
|
||||
aboutMenu: 'About DeepSeek Harness',
|
||||
hideApplication: 'Hide DeepSeek Harness',
|
||||
hideOtherApplications: 'Hide Others',
|
||||
showAllApplications: 'Show All',
|
||||
quitApplication: 'Quit DeepSeek Harness',
|
||||
edit: 'Edit',
|
||||
menuBar: 'Application menu',
|
||||
delete: 'Delete',
|
||||
@@ -94,6 +98,10 @@ export type DesktopMessages = { readonly [Key in keyof typeof en]: string }
|
||||
export const zh = {
|
||||
application: '应用',
|
||||
aboutMenu: '关于 DeepSeek Harness',
|
||||
hideApplication: '隐藏 DeepSeek Harness',
|
||||
hideOtherApplications: '隐藏其他',
|
||||
showAllApplications: '显示全部',
|
||||
quitApplication: '退出 DeepSeek Harness',
|
||||
edit: '编辑',
|
||||
menuBar: '应用菜单',
|
||||
delete: '删除',
|
||||
|
||||
@@ -613,7 +613,9 @@ async function main(): Promise<void> {
|
||||
? [{ role: 'fileMenu' }, { role: 'editMenu' }, { role: 'windowMenu' }]
|
||||
: [{ role: 'editMenu' }]
|
||||
const hideCommands: MenuItemConstructorOptions[] = darwin
|
||||
? [{ role: 'hide' }, { role: 'hideOthers' }, { role: 'unhide' }, { type: 'separator' }]
|
||||
? [{ role: 'hide', label: currentDesktopLocale().messages.hideApplication },
|
||||
{ role: 'hideOthers', label: currentDesktopLocale().messages.hideOtherApplications },
|
||||
{ role: 'unhide', label: currentDesktopLocale().messages.showAllApplications }, { type: 'separator' }]
|
||||
: []
|
||||
const applicationItems = (): MenuItemConstructorOptions[] => [
|
||||
{ label: currentDesktopLocale().messages.aboutMenu, role: 'about' },
|
||||
@@ -621,7 +623,8 @@ async function main(): Promise<void> {
|
||||
{ label: currentDesktopLocale().messages.checkUpdatesMenu, click: () => { void openUpdatePrompt(true) } },
|
||||
{ type: 'separator' },
|
||||
...hideCommands,
|
||||
{ role: 'quit', ...(process.platform === 'win32' ? { label: currentDesktopLocale().messages.exitApplication } : {}) },
|
||||
{ role: 'quit', ...(darwin ? { label: currentDesktopLocale().messages.quitApplication }
|
||||
: process.platform === 'win32' ? { label: currentDesktopLocale().messages.exitApplication } : {}) },
|
||||
]
|
||||
Menu.setApplicationMenu(process.platform === 'win32' ? null : Menu.buildFromTemplate([{
|
||||
label: darwin ? app.name : currentDesktopLocale().messages.application,
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
[
|
||||
{
|
||||
"role": "hide",
|
||||
"label": "Hide DeepSeek Harness"
|
||||
},
|
||||
{
|
||||
"role": "hideOthers",
|
||||
"label": "Hide Others"
|
||||
},
|
||||
{
|
||||
"role": "unhide",
|
||||
"label": "Show All"
|
||||
},
|
||||
{
|
||||
"role": "quit",
|
||||
"label": "Quit DeepSeek Harness"
|
||||
}
|
||||
]
|
||||
@@ -0,0 +1,18 @@
|
||||
[
|
||||
{
|
||||
"role": "hide",
|
||||
"label": "隐藏 DeepSeek Harness"
|
||||
},
|
||||
{
|
||||
"role": "hideOthers",
|
||||
"label": "隐藏其他"
|
||||
},
|
||||
{
|
||||
"role": "unhide",
|
||||
"label": "显示全部"
|
||||
},
|
||||
{
|
||||
"role": "quit",
|
||||
"label": "退出 DeepSeek Harness"
|
||||
}
|
||||
]
|
||||
@@ -672,6 +672,22 @@ describe('desktop main startup', () => {
|
||||
expect(harness.menu.setApplicationMenu).toHaveBeenCalledOnce()
|
||||
})
|
||||
|
||||
it.each(['en-US', 'zh-CN'])('localizes macOS visibility and quit commands without changing the application name (%s)', async (locale) => {
|
||||
vi.spyOn(process, 'platform', 'get').mockReturnValue('darwin')
|
||||
vi.spyOn(harness.app, 'getLocale').mockReturnValue(locale)
|
||||
const originalName = harness.app.name
|
||||
harness.app.name = '@deepseek-ai/dsh-desktop'
|
||||
try {
|
||||
await import('../src/main.ts')
|
||||
await harness.preparing.promise
|
||||
const commands = applicationMenuItems().filter(item =>
|
||||
item.role === 'hide' || item.role === 'hideOthers' || item.role === 'unhide' || item.role === 'quit')
|
||||
await expect(JSON.stringify(commands, null, 2) + '\n')
|
||||
.toMatchFileSnapshot(`./expected/application-menu-${locale}.json`)
|
||||
expect(harness.app.name).toBe('@deepseek-ai/dsh-desktop')
|
||||
} finally { harness.app.name = originalName }
|
||||
})
|
||||
|
||||
it('attaches Host socket credentials only to the owned application origin and window', async () => {
|
||||
await import('../src/main.ts')
|
||||
await harness.preparing.promise
|
||||
|
||||
Reference in new issue
Block a user