-
-
Notifications
You must be signed in to change notification settings - Fork 3.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Translate menu in macOS #10049
Comments
That menu is in English in all languages. It depends on Electron not on Tabby. |
Thank you for your response. I’d like to offer a small clarification regarding the menu language in the top-left corner of macOS. It seems that this menu is not directly tied to Electron. From my investigation, I’ve found that it is possible to modify the language displayed in this menu by adjusting the following section of code: Lines 247 to 330 in ac6f60f
For example, I made the following changes to the code: private setupMenu () {
const template: MenuItemConstructorOptions[] = [
{
label: 'Application',
submenu: [
{ role: 'about', label: '关于' },
{ type: 'separator' },
{
label: '偏好设置',
accelerator: 'Cmd+,',
click: async () => {
if (!this.hasWindows()) {
await this.newWindow()
}
this.windows[0].send('host:preferences-menu')
},
},
{ type: 'separator' },
{ role: 'services', label: '服务', submenu: [] },
{ type: 'separator' },
{ role: 'hide', label: '隐藏' },
{ role: 'hideOthers', label: '隐藏其他窗口' },
{ role: 'unhide', label: '显示全部' },
{ type: 'separator' },
{
label: '退出',
accelerator: 'Cmd+Q',
click: () => {
this.quitRequested = true
app.quit()
},
},
],
},
{
label: '编辑',
submenu: [
{ role: 'undo', label: '关于' },
{ role: 'redo', label: '重做' },
{ type: 'separator' },
{ role: 'cut', label: '剪切' },
{ role: 'copy', label: '复制' },
{ role: 'paste', label: '粘贴' },
{ role: 'pasteAndMatchStyle', label: '格式化粘贴' },
{ role: 'delete', label: '删除' },
{ role: 'selectAll', label: '全选' },
],
},
{
label: '视图',
submenu: [
{ role: 'toggleDevTools', label: '开发者工具' },
{ type: 'separator' },
{ role: 'togglefullscreen', label: '全屏' },
],
},
{
role: 'window', label: '窗口',
submenu: [
{ role: 'minimize' },
{ role: 'zoom' },
{ type: 'separator' },
{ role: 'front' },
],
},
{
role: 'help', label: '帮助',
submenu: [
{
label: 'Website',
click () {
shell.openExternal('https://eugeny.github.io/tabby')
},
},
],
},
]
if (process.env.TABBY_DEV) {
template[2].submenu['unshift']({ role: 'reload', label: '重载' })
}
Menu.setApplicationMenu(Menu.buildFromTemplate(template))
} And here’s a gif demonstrating the result: It seems that adding some additional logic to match the language settings and update the label accordingly could be an effective way to ensure the menu reflects the chosen language. |
@yuantao313 Could you kindly confirm if this aligns with the intended outcome? Modificationprivate setupMenu () { function getEffectiveLocale () { const preferredLanguages = app.getPreferredSystemLanguages() |
Describe the problem:
In macOS, my language is Chinese, the menu is still shown in English while the main screen is shown in Chinese correctly.
To Reproduce:
Switch macOS to Chinese:
The text was updated successfully, but these errors were encountered: