Skip to content

Commit

Permalink
Merge pull request #1029 from nikdale/feature/localization-updates
Browse files Browse the repository at this point in the history
Localization upgrade on missing strings
  • Loading branch information
garthvh authored Dec 21, 2024
2 parents 561d576 + 136a521 commit cd7093b
Show file tree
Hide file tree
Showing 8 changed files with 624 additions and 67 deletions.
605 changes: 581 additions & 24 deletions Localizable.xcstrings

Large diffs are not rendered by default.

22 changes: 11 additions & 11 deletions Meshtastic/Enums/DeviceEnums.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,27 +27,27 @@ enum DeviceRoles: Int, CaseIterable, Identifiable {
var name: String {
switch self {
case .client:
return "Client"
return "device.role.name.client".localized
case .clientMute:
return "Client Mute"
return "device.role.name.clientMute".localized
case .router:
return "Router"
return "device.role.name.router".localized
case .routerClient:
return "Router & Client"
return "device.role.name.routerClient".localized
case .repeater:
return "Repeater"
return "device.role.name.repeater".localized
case .tracker:
return "Tracker"
return "device.role.name.tracker".localized
case .sensor:
return "Sensor"
return "device.role.name.sensor".localized
case .tak:
return "TAK"
return "device.role.name.tak".localized
case .takTracker:
return "TAK Tracker"
return "device.role.name.takTracker".localized
case .clientHidden:
return "Client Hidden"
return "device.role.name.clientHidden".localized
case .lostAndFound:
return "Lost and Found"
return "device.role.name.lostAndFound".localized
}

}
Expand Down
8 changes: 4 additions & 4 deletions Meshtastic/Enums/DisplayEnums.swift
Original file line number Diff line number Diff line change
Expand Up @@ -149,13 +149,13 @@ enum DisplayModes: Int, CaseIterable, Identifiable {
var description: String {
switch self {
case .defaultMode:
return "Default 128x64 screen layout"
return "default.128x64.screen.layout".localized
case .twoColor:
return "Optimized for 2 color displays"
return "optimized.for.2.color.displays".localized
case .inverted:
return "Inverted top bar for 2 Color display"
return "inverted.top.bar.for.2.color.display".localized
case .color:
return "TFT Full Color Displays"
return "tft.full.color.displays".localized
}
}
func protoEnumValue() -> Config.DisplayConfig.DisplayMode {
Expand Down
12 changes: 6 additions & 6 deletions Meshtastic/Enums/TelemetryEnums.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,17 @@ enum Aqi: Int, CaseIterable, Identifiable {
var description: String {
switch self {
case .good:
return "Good"
return "telemetry.good".localized
case .moderate:
return "Moderate"
return "telemetry.moderate".localized
case .sensitive:
return "Unhealthy for Sensitive Groups"
return "telemetry.sensitive".localized
case .unhealthy:
return "Unhealthy"
return "telementry.unhealthy".localized
case .veryUnhealthy:
return "Very Unhealthy"
return "telementry.veryUnhealthy".localized
case .hazardous:
return "Hazardous"
return "telementry.hazardous".localized
}
}
var color: Color {
Expand Down
30 changes: 15 additions & 15 deletions Meshtastic/Helpers/BLEManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -242,14 +242,14 @@ class BLEManager: NSObject, CBPeripheralDelegate, MqttClientProxyManagerDelegate
if errorCode == 6 { // CBError.Code.connectionTimeout The connection has timed out unexpectedly.
// Happens when device is manually reset / powered off
lastConnectionError = "🚨" + String.localizedStringWithFormat("ble.errorcode.6 %@".localized, e.localizedDescription)
Logger.services.error("🚨 [BLE] Disconnected: \(peripheral.name ?? "Unknown", privacy: .public) Error Code: \(errorCode, privacy: .public) Error: \(e.localizedDescription, privacy: .public)")
Logger.services.error("🚨 [BLE] Disconnected: \(peripheral.name ?? "Unknown".localized, privacy: .public) Error Code: \(errorCode, privacy: .public) Error: \(e.localizedDescription, privacy: .public)")
} else if errorCode == 7 { // CBError.Code.peripheralDisconnected The specified device has disconnected from us.
// Seems to be what is received when a tbeam sleeps, immediately recconnecting does not work.
if UserDefaults.preferredPeripheralId == peripheral.identifier.uuidString {
manager.notifications = [
Notification(
id: (peripheral.identifier.uuidString),
title: "Radio Disconnected",
title: "Radio Disconnected".localized,
subtitle: "\(peripheral.name ?? "unknown".localized)",
content: e.localizedDescription,
target: "bluetooth",
Expand All @@ -258,18 +258,18 @@ class BLEManager: NSObject, CBPeripheralDelegate, MqttClientProxyManagerDelegate
]
manager.schedule()
}
lastConnectionError = "🚨 \(e.localizedDescription)"
Logger.services.error("🚨 [BLE] Disconnected: \(peripheral.name ?? "Unknown", privacy: .public) Error Code: \(errorCode, privacy: .public) Error: \(e.localizedDescription, privacy: .public)")
lastConnectionError = "🚨 \("The specified device has disconnected from us".localized)"
Logger.services.error("🚨 [BLE] Disconnected: \(peripheral.name ?? "Unknown".localized, privacy: .public) Error Code: \(errorCode, privacy: .public) Error: \(e.localizedDescription, privacy: .public)")
} else if errorCode == 14 { // Peer removed pairing information
// Forgetting and reconnecting seems to be necessary so we need to show the user an error telling them to do that
lastConnectionError = "🚨 " + String.localizedStringWithFormat("ble.errorcode.14 %@".localized, e.localizedDescription)
Logger.services.error("🚨 [BLE] Disconnected: \(peripheral.name ?? "Unknown") Error Code: \(errorCode, privacy: .public) Error: \(self.lastConnectionError, privacy: .public)")
Logger.services.error("🚨 [BLE] Disconnected: \(peripheral.name ?? "Unknown".localized) Error Code: \(errorCode, privacy: .public) Error: \(self.lastConnectionError, privacy: .public)")
} else {
if UserDefaults.preferredPeripheralId == peripheral.identifier.uuidString {
manager.notifications = [
Notification(
id: (peripheral.identifier.uuidString),
title: "Radio Disconnected",
title: "Radio Disconnected".localized,
subtitle: "\(peripheral.name ?? "unknown".localized)",
content: e.localizedDescription,
target: "bluetooth",
Expand All @@ -279,12 +279,12 @@ class BLEManager: NSObject, CBPeripheralDelegate, MqttClientProxyManagerDelegate
manager.schedule()
}
lastConnectionError = "🚨 \(e.localizedDescription)"
Logger.services.error("🚨 [BLE] Disconnected: \(peripheral.name ?? "Unknown", privacy: .public) Error Code: \(errorCode, privacy: .public) Error: \(e.localizedDescription, privacy: .public)")
Logger.services.error("🚨 [BLE] Disconnected: \(peripheral.name ?? "Unknown".localized, privacy: .public) Error Code: \(errorCode, privacy: .public) Error: \(e.localizedDescription, privacy: .public)")
}
} else {
// Disconnected without error which indicates user intent to disconnect
// Happens when swiping to disconnect
Logger.services.info("ℹ️ [BLE] Disconnected: \(peripheral.name ?? "Unknown", privacy: .public): User Initiated Disconnect")
Logger.services.info("ℹ️ [BLE] Disconnected: \(peripheral.name ?? "Unknown".localized, privacy: .public): \(String(describing: "User Initiated Disconnect".localized))")
}
// Start a scan so the disconnected peripheral is moved to the peripherals[] if it is awake
self.startScanning()
Expand Down Expand Up @@ -663,15 +663,15 @@ class BLEManager: NSObject, CBPeripheralDelegate, MqttClientProxyManagerDelegate
}

switch decodedInfo.packet.decoded.portnum {

// Handle Any local only packets we get over BLE
case .unknownApp:
var nowKnown = false

// MyInfo from initial connection
if decodedInfo.myInfo.isInitialized && decodedInfo.myInfo.myNodeNum > 0 {
let myInfo = myInfoPacket(myInfo: decodedInfo.myInfo, peripheralId: self.connectedPeripheral.id, context: context)

if myInfo != nil {
UserDefaults.preferredPeripheralNum = Int(myInfo?.myNodeNum ?? 0)
connectedPeripheral.num = myInfo?.myNodeNum ?? 0
Expand Down Expand Up @@ -890,7 +890,7 @@ class BLEManager: NSObject, CBPeripheralDelegate, MqttClientProxyManagerDelegate
}
}
hopNodes.append(traceRouteHop)

let hopName = hopNode?.user?.longName ?? (node == 4294967295 ? "Repeater" : String(hopNode?.num.toHex() ?? "unknown".localized))
let mqttLabel = hopNode?.viaMqtt ?? false ? "MQTT " : ""
let snrLabel = (traceRouteHop.snr != -32) ? String(traceRouteHop.snr) : "unknown ".localized
Expand All @@ -912,7 +912,7 @@ class BLEManager: NSObject, CBPeripheralDelegate, MqttClientProxyManagerDelegate
/// Add the destination node to the end of the route towards string and the beginning of the route back string
routeString += "\(traceRoute?.node?.user?.longName ?? "unknown".localized) \((traceRoute?.node?.num ?? 0).toHex()) (\(destinationHop.snr != -32 ? String(destinationHop.snr) : "unknown ".localized)dB)"
traceRoute?.routeText = routeString

traceRoute?.hopsBack = Int32(routingMessage.routeBack.count)
// Only if hopStart is set and there is an SNR entry
if decodedInfo.packet.hopStart > 0 && routingMessage.snrBack.count > 0 {
Expand Down Expand Up @@ -946,7 +946,7 @@ class BLEManager: NSObject, CBPeripheralDelegate, MqttClientProxyManagerDelegate
}
}
hopNodes.append(traceRouteHop)

let hopName = hopNode?.user?.longName ?? (node == 4294967295 ? "Repeater" : String(hopNode?.num.toHex() ?? "unknown".localized))
let mqttLabel = hopNode?.viaMqtt ?? false ? "MQTT " : ""
let snrLabel = (traceRouteHop.snr != -32) ? String(traceRouteHop.snr) : "unknown ".localized
Expand Down Expand Up @@ -1954,7 +1954,7 @@ class BLEManager: NSObject, CBPeripheralDelegate, MqttClientProxyManagerDelegate
}
return false
}

public func saveLicensedUser(ham: HamParameters, fromUser: UserEntity, toUser: UserEntity, adminIndex: Int32) -> Int64 {
var adminPacket = AdminMessage()
adminPacket.setHamMode = ham
Expand Down
4 changes: 2 additions & 2 deletions Meshtastic/Persistence/UpdateCoreData.swift
Original file line number Diff line number Diff line change
Expand Up @@ -199,9 +199,9 @@ func upsertNodeInfoPacket (packet: MeshPacket, context: NSManagedObjectContext)
manager.notifications = [
Notification(
id: (UUID().uuidString),
title: "New Node",
title: "New Node".localized,
subtitle: "\(newUser.longName ?? "unknown".localized)",
content: "New Node has been discovered",
content: "New Node has been discovered".localized,
target: "nodes",
path: "meshtastic:///nodes?nodenum=\(newUser.num)"
)
Expand Down
8 changes: 4 additions & 4 deletions Meshtastic/Views/Helpers/LoRaSignalStrengthIndicator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,13 @@ enum LoRaSignalStrength: Int {
var description: String {
switch self {
case .none:
return "None"
return "lora.signal.strength.none".localized
case .bad:
return "Bad"
return "lora.signal.strength.bad".localized
case .fair:
return "Fair"
return "lora.signal.strength.fair".localized
case .good:
return "Good"
return "lora.signal.strength.good".localized
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion Meshtastic/Views/Helpers/MQTTIcon.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ struct MQTTIcon: View {
.symbolRenderingMode(.hierarchical)
}.popover(isPresented: self.$isPopoverOpen, arrowEdge: .bottom, content: {
VStack(spacing: 0.5) {
Text("Topic: " + topic)
Text("Topic: \(topic)".localized)
.padding(20)
Button("close", action: { self.isPopoverOpen = false }).padding([.bottom], 20)
}
Expand Down

0 comments on commit cd7093b

Please sign in to comment.