mirror of
https://github.com/morgan9e/macos-stats
synced 2026-04-14 00:04:15 +09:00
feat: add translation to the modules name (#496)
This commit is contained in:
@@ -28,6 +28,7 @@ identifier_name:
|
||||
- NumbersOfProcesses
|
||||
- NetworkReaders
|
||||
- SensorsList
|
||||
- Alignments
|
||||
|
||||
line_length: 200
|
||||
|
||||
|
||||
@@ -224,6 +224,7 @@ internal class HeaderView: NSStackView {
|
||||
private var activityButton: NSButton?
|
||||
private var settingsButton: NSButton?
|
||||
|
||||
private var title: String = ""
|
||||
private var isCloseAction: Bool = false
|
||||
|
||||
override init(frame: NSRect) {
|
||||
@@ -292,7 +293,8 @@ internal class HeaderView: NSStackView {
|
||||
}
|
||||
|
||||
public func setTitle(_ newTitle: String) {
|
||||
self.titleView?.stringValue = newTitle
|
||||
self.title = newTitle
|
||||
self.titleView?.stringValue = localizedString(newTitle)
|
||||
}
|
||||
|
||||
override func draw(_ dirtyRect: NSRect) {
|
||||
@@ -324,7 +326,7 @@ internal class HeaderView: NSStackView {
|
||||
|
||||
@objc func openSettings(_ sender: Any) {
|
||||
self.window?.setIsVisible(false)
|
||||
NotificationCenter.default.post(name: .toggleSettings, object: nil, userInfo: ["module": self.titleView?.stringValue ?? ""])
|
||||
NotificationCenter.default.post(name: .toggleSettings, object: nil, userInfo: ["module": self.title])
|
||||
}
|
||||
|
||||
public func setCloseButton(_ state: Bool) {
|
||||
|
||||
@@ -81,7 +81,7 @@ open class Settings: NSView, Settings_p {
|
||||
titleView.canDrawSubviewsIntoLayer = true
|
||||
titleView.alignment = .natural
|
||||
titleView.font = NSFont.systemFont(ofSize: 18, weight: .light)
|
||||
titleView.stringValue = self.config.pointee.name
|
||||
titleView.stringValue = localizedString(self.config.pointee.name)
|
||||
|
||||
var toggle: NSControl = NSControl()
|
||||
if #available(OSX 10.15, *) {
|
||||
|
||||
@@ -285,7 +285,16 @@ private class MenuView: NSView {
|
||||
super.init(frame: NSRect(x: 0, y: self.height*CGFloat(n), width: width, height: self.height))
|
||||
self.wantsLayer = true
|
||||
self.layer?.backgroundColor = .clear
|
||||
self.toolTip = title == "Stats" ? localizedString("Open application settings") : localizedString("Open moduleName settings", title)
|
||||
|
||||
var toolTip = ""
|
||||
if title == "State" {
|
||||
toolTip = localizedString("Open application settings")
|
||||
} else if title == "Dashboard" {
|
||||
toolTip = localizedString("Open dashboard")
|
||||
} else {
|
||||
toolTip = localizedString("Open \(title) settings")
|
||||
}
|
||||
self.toolTip = toolTip
|
||||
|
||||
let rect = NSRect(x: 0, y: 0, width: self.frame.width, height: self.frame.height)
|
||||
let trackingArea = NSTrackingArea(
|
||||
@@ -302,13 +311,15 @@ private class MenuView: NSView {
|
||||
}
|
||||
imageView.frame = NSRect(x: 8, y: (self.height - 18)/2, width: 18, height: 18)
|
||||
imageView.wantsLayer = true
|
||||
imageView.contentTintColor = .labelColor
|
||||
if #available(OSX 10.14, *) {
|
||||
imageView.contentTintColor = .labelColor
|
||||
}
|
||||
|
||||
let titleView = TextView(frame: NSRect(x: 34, y: (self.height - 16)/2, width: 100, height: 16))
|
||||
titleView.alignment = .natural
|
||||
titleView.textColor = .labelColor
|
||||
titleView.font = NSFont.systemFont(ofSize: 13, weight: .regular)
|
||||
titleView.stringValue = title
|
||||
titleView.stringValue = localizedString(title)
|
||||
|
||||
self.addSubview(imageView)
|
||||
self.addSubview(titleView)
|
||||
|
||||
Reference in New Issue
Block a user