[PATCH 1/1] UI: macOS: move tunnel peers ip to submenus
Brook Q
brook.qin at gmail.com
Wed Apr 6 08:03:18 UTC 2022
Sometimes allowdIPs as a string is too long as menu title, maybe convert to submenu list is better.
---
Sources/WireGuardApp/Base.lproj/Localizable.strings | 1 +
Sources/WireGuardApp/UI/macOS/StatusMenu.swift | 13 ++++++++++---
Sources/WireGuardApp/de.lproj/Localizable.strings | 1 +
Sources/WireGuardApp/fa.lproj/Localizable.strings | 1 +
Sources/WireGuardApp/fi.lproj/Localizable.strings | 1 +
Sources/WireGuardApp/fr.lproj/Localizable.strings | 1 +
Sources/WireGuardApp/it.lproj/Localizable.strings | 1 +
Sources/WireGuardApp/ja.lproj/Localizable.strings | 1 +
Sources/WireGuardApp/pa.lproj/Localizable.strings | 1 +
Sources/WireGuardApp/pl.lproj/Localizable.strings | 1 +
Sources/WireGuardApp/ro.lproj/Localizable.strings | 1 +
Sources/WireGuardApp/ru.lproj/Localizable.strings | 1 +
Sources/WireGuardApp/sl.lproj/Localizable.strings | 1 +
Sources/WireGuardApp/tr.lproj/Localizable.strings | 1 +
.../WireGuardApp/zh-Hans.lproj/Localizable.strings | 1 +
.../WireGuardApp/zh-Hant.lproj/Localizable.strings | 1 +
16 files changed, 25 insertions(+), 3 deletions(-)
diff --git a/Sources/WireGuardApp/Base.lproj/Localizable.strings b/Sources/WireGuardApp/Base.lproj/Localizable.strings
index 40023ec..3db7659 100644
--- a/Sources/WireGuardApp/Base.lproj/Localizable.strings
+++ b/Sources/WireGuardApp/Base.lproj/Localizable.strings
@@ -301,6 +301,7 @@
// Mac status bar menu / pulldown menu / main menu
+"macMenuNetworks" = "Networks";
"macMenuNetworks (%@)" = "Networks: %@";
"macMenuNetworksNone" = "Networks: None";
diff --git a/Sources/WireGuardApp/UI/macOS/StatusMenu.swift b/Sources/WireGuardApp/UI/macOS/StatusMenu.swift
index 6cd00a4..b74877d 100644
--- a/Sources/WireGuardApp/UI/macOS/StatusMenu.swift
+++ b/Sources/WireGuardApp/UI/macOS/StatusMenu.swift
@@ -107,12 +107,19 @@ class StatusMenu: NSMenu {
networksMenuItem.title = ""
networksMenuItem.isHidden = true
} else {
- let allowedIPs = tunnel.tunnelConfiguration?.peers.flatMap { $0.allowedIPs }.map { $0.stringRepresentation }.joined(separator: ", ") ?? ""
- if !allowedIPs.isEmpty {
- networksMenuItem.title = tr(format: "macMenuNetworks (%@)", allowedIPs)
+ networksMenuItem.submenu?.items.removeAll()
+ let allowedIPs = tunnel.tunnelConfiguration?.peers.flatMap { $0.allowedIPs }.map { $0.stringRepresentation } ?? []
+ if allowedIPs.count > 0 {
+ networksMenuItem.title = tr("macMenuNetworks")
+ allowedIPs.forEach { ip in
+ let networkSubItem = NSMenuItem(title: ip, action: nil, keyEquivalent: "")
+ networkSubItem.isEnabled = false
+ networksMenuItem.submenu?.addItem(networkSubItem)
+ }
} else {
networksMenuItem.title = tr("macMenuNetworksNone")
}
+ networksMenuItem.isEnabled = (networksMenuItem.submenu?.items.count ?? 0) > 0
networksMenuItem.isHidden = false
}
deactivateMenuItem.isHidden = tunnel.status != .active
diff --git a/Sources/WireGuardApp/de.lproj/Localizable.strings b/Sources/WireGuardApp/de.lproj/Localizable.strings
index ffcb429..2f0ee1d 100644
--- a/Sources/WireGuardApp/de.lproj/Localizable.strings
+++ b/Sources/WireGuardApp/de.lproj/Localizable.strings
@@ -291,6 +291,7 @@
// Mac status bar menu / pulldown menu / main menu
+"macMenuNetworks" = "Netzwerke";
"macMenuNetworks (%@)" = "Netzwerke:%@";
"macMenuNetworksNone" = "Keine Netzwerke.";
diff --git a/Sources/WireGuardApp/fa.lproj/Localizable.strings b/Sources/WireGuardApp/fa.lproj/Localizable.strings
index 43bd393..6cfda75 100644
--- a/Sources/WireGuardApp/fa.lproj/Localizable.strings
+++ b/Sources/WireGuardApp/fa.lproj/Localizable.strings
@@ -235,6 +235,7 @@
// Mac status bar menu / pulldown menu / main menu
+"macMenuNetworks" = "شبکهها";
"macMenuNetworks (%@)" = "شبکهها: %@";
"macMenuNetworksNone" = "شبکهها: هیچی";
diff --git a/Sources/WireGuardApp/fi.lproj/Localizable.strings b/Sources/WireGuardApp/fi.lproj/Localizable.strings
index b359675..6600f3c 100644
--- a/Sources/WireGuardApp/fi.lproj/Localizable.strings
+++ b/Sources/WireGuardApp/fi.lproj/Localizable.strings
@@ -244,6 +244,7 @@
// Mac status bar menu / pulldown menu / main menu
+"macMenuNetworks" = "Verkot";
"macMenuNetworks (%@)" = "Verkot: %@";
"macMenuNetworksNone" = "Verkot: Ei mitään";
diff --git a/Sources/WireGuardApp/fr.lproj/Localizable.strings b/Sources/WireGuardApp/fr.lproj/Localizable.strings
index aeeed29..335d061 100644
--- a/Sources/WireGuardApp/fr.lproj/Localizable.strings
+++ b/Sources/WireGuardApp/fr.lproj/Localizable.strings
@@ -291,6 +291,7 @@
// Mac status bar menu / pulldown menu / main menu
+"macMenuNetworks" = "Réseaux";
"macMenuNetworks (%@)" = "Réseaux: %@";
"macMenuNetworksNone" = "Réseaux: Aucun";
diff --git a/Sources/WireGuardApp/it.lproj/Localizable.strings b/Sources/WireGuardApp/it.lproj/Localizable.strings
index 68acfc2..14a74c6 100644
--- a/Sources/WireGuardApp/it.lproj/Localizable.strings
+++ b/Sources/WireGuardApp/it.lproj/Localizable.strings
@@ -291,6 +291,7 @@
// Mac status bar menu / pulldown menu / main menu
+"macMenuNetworks" = "Reti";
"macMenuNetworks (%@)" = "Reti: %@";
"macMenuNetworksNone" = "Reti: nessuna";
diff --git a/Sources/WireGuardApp/ja.lproj/Localizable.strings b/Sources/WireGuardApp/ja.lproj/Localizable.strings
index be5d30b..c729a88 100644
--- a/Sources/WireGuardApp/ja.lproj/Localizable.strings
+++ b/Sources/WireGuardApp/ja.lproj/Localizable.strings
@@ -291,6 +291,7 @@
// Mac status bar menu / pulldown menu / main menu
+"macMenuNetworks" = "ネットワーク";
"macMenuNetworks (%@)" = "ネットワーク: %@";
"macMenuNetworksNone" = "ネットワーク: なし";
diff --git a/Sources/WireGuardApp/pa.lproj/Localizable.strings b/Sources/WireGuardApp/pa.lproj/Localizable.strings
index 54cef5f..76dbc64 100644
--- a/Sources/WireGuardApp/pa.lproj/Localizable.strings
+++ b/Sources/WireGuardApp/pa.lproj/Localizable.strings
@@ -291,6 +291,7 @@
// Mac status bar menu / pulldown menu / main menu
+"macMenuNetworks" = "ਨੈੱਟਵਰਕ";
"macMenuNetworks (%@)" = "ਨੈੱਟਵਰਕ: %@";
"macMenuNetworksNone" = "ਨੈੱਟਵਰਕ: ਕੋਈ ਨਹੀਂ";
diff --git a/Sources/WireGuardApp/pl.lproj/Localizable.strings b/Sources/WireGuardApp/pl.lproj/Localizable.strings
index 550344a..dddca13 100644
--- a/Sources/WireGuardApp/pl.lproj/Localizable.strings
+++ b/Sources/WireGuardApp/pl.lproj/Localizable.strings
@@ -291,6 +291,7 @@
// Mac status bar menu / pulldown menu / main menu
+"macMenuNetworks" = "Sieci";
"macMenuNetworks (%@)" = "Sieci: %@";
"macMenuNetworksNone" = "Sieci: brak";
diff --git a/Sources/WireGuardApp/ro.lproj/Localizable.strings b/Sources/WireGuardApp/ro.lproj/Localizable.strings
index 0b0843f..53ec584 100644
--- a/Sources/WireGuardApp/ro.lproj/Localizable.strings
+++ b/Sources/WireGuardApp/ro.lproj/Localizable.strings
@@ -291,6 +291,7 @@
// Mac status bar menu / pulldown menu / main menu
+"macMenuNetworks" = "Rețele";
"macMenuNetworks (%@)" = "Rețele: %@";
"macMenuNetworksNone" = "Rețele: niciuna";
diff --git a/Sources/WireGuardApp/ru.lproj/Localizable.strings b/Sources/WireGuardApp/ru.lproj/Localizable.strings
index aa18919..906a938 100644
--- a/Sources/WireGuardApp/ru.lproj/Localizable.strings
+++ b/Sources/WireGuardApp/ru.lproj/Localizable.strings
@@ -291,6 +291,7 @@
// Mac status bar menu / pulldown menu / main menu
+"macMenuNetworks" = "Сети";
"macMenuNetworks (%@)" = "Сети: %@";
"macMenuNetworksNone" = "Сети отсутствуют";
diff --git a/Sources/WireGuardApp/sl.lproj/Localizable.strings b/Sources/WireGuardApp/sl.lproj/Localizable.strings
index b57da97..36ff8e7 100644
--- a/Sources/WireGuardApp/sl.lproj/Localizable.strings
+++ b/Sources/WireGuardApp/sl.lproj/Localizable.strings
@@ -291,6 +291,7 @@
// Mac status bar menu / pulldown menu / main menu
+"macMenuNetworks" = "Omrežja";
"macMenuNetworks (%@)" = "Omrežja: %@";
"macMenuNetworksNone" = "Ni omrežij";
diff --git a/Sources/WireGuardApp/tr.lproj/Localizable.strings b/Sources/WireGuardApp/tr.lproj/Localizable.strings
index 537d28c..be52bb5 100644
--- a/Sources/WireGuardApp/tr.lproj/Localizable.strings
+++ b/Sources/WireGuardApp/tr.lproj/Localizable.strings
@@ -291,6 +291,7 @@
// Mac status bar menu / pulldown menu / main menu
+"macMenuNetworks" = "Ağlar";
"macMenuNetworks (%@)" = "Ağlar: %@";
"macMenuNetworksNone" = "Ağlar: Yok";
diff --git a/Sources/WireGuardApp/zh-Hans.lproj/Localizable.strings b/Sources/WireGuardApp/zh-Hans.lproj/Localizable.strings
index 1f97382..557b492 100644
--- a/Sources/WireGuardApp/zh-Hans.lproj/Localizable.strings
+++ b/Sources/WireGuardApp/zh-Hans.lproj/Localizable.strings
@@ -291,6 +291,7 @@
// Mac status bar menu / pulldown menu / main menu
+"macMenuNetworks" = "网络";
"macMenuNetworks (%@)" = "网络:%@";
"macMenuNetworksNone" = "网络:无";
diff --git a/Sources/WireGuardApp/zh-Hant.lproj/Localizable.strings b/Sources/WireGuardApp/zh-Hant.lproj/Localizable.strings
index 5aef8b4..a526d5a 100644
--- a/Sources/WireGuardApp/zh-Hant.lproj/Localizable.strings
+++ b/Sources/WireGuardApp/zh-Hant.lproj/Localizable.strings
@@ -176,6 +176,7 @@
"alertUnableToWriteLogTitle" = "Log export failed";
"alertInvalidPeerMessagePublicKeyRequired" = "Peer’s public key is required";
"macMenuNetworksNone" = "Networks: None";
+"macMenuNetworks" = "Networks";
"tunnelOnDemandSSIDsKey" = "SSIDs";
"alertCantOpenOutputZipFileForWritingMessage" = "Could not open zip file for writing.";
"logViewTitle" = "Log";
--
2.32.0 (Apple Git-132)
More information about the WireGuard
mailing list