| 12345678910111213141516171819202122232425262728293031323334353637383940 |
- //
- // AppMenuLocalizer.swift
- // App for Indeed
- //
- import Cocoa
- /// Applies in-app language to the main menu and window chrome (storyboard defaults are English).
- enum AppMenuLocalizer {
- static func apply() {
- let appName = AppMarketingLinks.appDisplayName
- if let window = AppWindowConfiguration.mainWindow() {
- window.title = appName
- }
- if let item = NSApp.delegate as? AppDelegate {
- item.refreshMainWindowMenuItemTitle()
- }
- guard let mainMenu = NSApp.mainMenu,
- let appMenuItem = mainMenu.items.first,
- let appMenu = appMenuItem.submenu else { return }
- appMenuItem.title = appName
- for item in appMenu.items {
- let action = item.action
- if action == #selector(NSApplication.orderFrontStandardAboutPanel(_:)) {
- item.title = String(format: L("About %@"), appName)
- } else if action == #selector(NSApplication.hide(_:)) {
- item.title = String(format: L("Hide %@"), appName)
- } else if action == #selector(NSApplication.terminate(_:)) {
- item.title = String(format: L("Quit %@"), appName)
- } else if item.keyEquivalent == "," {
- item.title = L("Preferences…")
- }
- }
- }
- }
|