Localize unknown

This commit is contained in:
Garth Vander Houwen 2022-12-30 17:04:53 -08:00
parent 1a1cd719a2
commit 7c7bcda7c6
13 changed files with 40 additions and 64 deletions

View file

@ -291,7 +291,7 @@ class BLEManager: NSObject, CBPeripheralDelegate, ObservableObject {
guard (connectedPeripheral!.peripheral.state == CBPeripheralState.connected) else { return }
MeshLogger.log(" Requesting Device Metadata for \(connectedPeripheral!.peripheral.name ?? "Unknown")")
MeshLogger.log("🛎 Requesting Device Metadata for \(connectedPeripheral!.peripheral.name ?? NSLocalizedString("unknown", comment: "Unknown"))")
var adminPacket = AdminMessage()
adminPacket.getDeviceMetadataRequest = true
var meshPacket: MeshPacket = MeshPacket()
@ -348,7 +348,7 @@ class BLEManager: NSObject, CBPeripheralDelegate, ObservableObject {
invalidVersion = true
return
} else {
MeshLogger.log(" Issuing Want Config to \(connectedPeripheral!.peripheral.name ?? "Unknown")")
MeshLogger.log(" Issuing Want Config to \(connectedPeripheral!.peripheral.name ?? NSLocalizedString("unknown", comment: "Unknown"))")
//BLE Characteristics discovered, issue wantConfig
var toRadio: ToRadio = ToRadio()
configNonce += 1
@ -437,9 +437,9 @@ class BLEManager: NSObject, CBPeripheralDelegate, ObservableObject {
if myInfo != nil {
connectedPeripheral.num = myInfo!.myNodeNum
connectedPeripheral.firmwareVersion = myInfo?.firmwareVersion ?? "Unknown"
connectedPeripheral.name = myInfo?.bleName ?? "Unknown"
connectedPeripheral.longName = myInfo?.bleName ?? "Unknown"
connectedPeripheral.firmwareVersion = myInfo?.firmwareVersion ?? NSLocalizedString("unknown", comment: "Unknown")
connectedPeripheral.name = myInfo?.bleName ?? NSLocalizedString("unknown", comment: "Unknown")
connectedPeripheral.longName = myInfo?.bleName ?? NSLocalizedString("unknown", comment: "Unknown")
}
}
}
@ -453,7 +453,7 @@ class BLEManager: NSObject, CBPeripheralDelegate, ObservableObject {
if self.connectedPeripheral != nil && self.connectedPeripheral.num == nodeInfo!.num {
if nodeInfo!.user != nil {
connectedPeripheral.shortName = nodeInfo?.user?.shortName ?? "????"
connectedPeripheral.longName = nodeInfo?.user?.longName ?? "Unknown"
connectedPeripheral.longName = nodeInfo?.user?.longName ?? NSLocalizedString("unknown", comment: "Unknown")
}
}
}
@ -612,7 +612,7 @@ class BLEManager: NSObject, CBPeripheralDelegate, ObservableObject {
if preferredPeripheral != nil && preferredPeripheral?.peripheral != nil {
connectTo(peripheral: preferredPeripheral!.peripheral)
}
MeshLogger.log("🚫 Message Send Failed, not properly connected to \(preferredPeripheral?.name ?? "Unknown")")
MeshLogger.log("🚫 Message Send Failed, not properly connected to \(preferredPeripheral?.name ?? NSLocalizedString("unknown", comment: "Unknown"))")
success = false
} else if message.count < 1 {
@ -685,7 +685,7 @@ class BLEManager: NSObject, CBPeripheralDelegate, ObservableObject {
let binaryData: Data = try! toRadio.serializedData()
MeshLogger.log("📲 New messageId \(newMessage.messageId) sent to \(newMessage.toUser?.longName! ?? "Unknown")")
MeshLogger.log("📲 New messageId \(newMessage.messageId) sent to \(newMessage.toUser?.longName! ?? NSLocalizedString("unknown", comment: "Unknown"))")
if connectedPeripheral!.peripheral.state == CBPeripheralState.connected {
connectedPeripheral.peripheral.writeValue(binaryData, for: TORADIO_characteristic, type: .withResponse)
do {
@ -991,7 +991,7 @@ class BLEManager: NSObject, CBPeripheralDelegate, ObservableObject {
meshPacket.decoded = dataMessage
let messageDescription = "Saved Channel \(channel.index) for \(toUser.longName ?? "Unknown")"
let messageDescription = "Saved Channel \(channel.index) for \(toUser.longName ?? NSLocalizedString("unknown", comment: "Unknown"))"
if sendAdminMessageToRadio(meshPacket: meshPacket, adminDescription: messageDescription, fromUser: fromUser, toUser: toUser) {
@ -1110,7 +1110,7 @@ class BLEManager: NSObject, CBPeripheralDelegate, ObservableObject {
dataMessage.payload = try! adminPacket.serializedData()
dataMessage.portnum = PortNum.adminApp
meshPacket.decoded = dataMessage
let messageDescription = "Saved User Config for \(toUser.longName ?? "Unknown")"
let messageDescription = "Saved User Config for \(toUser.longName ?? NSLocalizedString("unknown", comment: "Unknown"))"
if sendAdminMessageToRadio(meshPacket: meshPacket, adminDescription: messageDescription, fromUser: fromUser, toUser: toUser) {
return Int64(meshPacket.id)
@ -1133,7 +1133,7 @@ class BLEManager: NSObject, CBPeripheralDelegate, ObservableObject {
dataMessage.payload = try! adminPacket.serializedData()
dataMessage.portnum = PortNum.adminApp
meshPacket.decoded = dataMessage
let messageDescription = "Saved Bluetooth Config for \(toUser.longName ?? "Unknown")"
let messageDescription = "Saved Bluetooth Config for \(toUser.longName ?? NSLocalizedString("unknown", comment: "Unknown"))"
if sendAdminMessageToRadio(meshPacket: meshPacket, adminDescription: messageDescription, fromUser: fromUser, toUser: toUser) {
return Int64(meshPacket.id)
@ -1158,7 +1158,7 @@ class BLEManager: NSObject, CBPeripheralDelegate, ObservableObject {
dataMessage.portnum = PortNum.adminApp
meshPacket.decoded = dataMessage
let messageDescription = "Saved Device Config for \(toUser.longName ?? "Unknown")"
let messageDescription = "Saved Device Config for \(toUser.longName ?? NSLocalizedString("unknown", comment: "Unknown"))"
if sendAdminMessageToRadio(meshPacket: meshPacket, adminDescription: messageDescription, fromUser: fromUser, toUser: toUser) {
@ -1183,7 +1183,7 @@ class BLEManager: NSObject, CBPeripheralDelegate, ObservableObject {
dataMessage.payload = try! adminPacket.serializedData()
dataMessage.portnum = PortNum.adminApp
meshPacket.decoded = dataMessage
let messageDescription = "Saved Display Config for \(toUser.longName ?? "Unknown")"
let messageDescription = "Saved Display Config for \(toUser.longName ?? NSLocalizedString("unknown", comment: "Unknown"))"
if sendAdminMessageToRadio(meshPacket: meshPacket, adminDescription: messageDescription, fromUser: fromUser, toUser: toUser) {
return Int64(meshPacket.id)
@ -1207,7 +1207,7 @@ class BLEManager: NSObject, CBPeripheralDelegate, ObservableObject {
dataMessage.payload = try! adminPacket.serializedData()
dataMessage.portnum = PortNum.adminApp
meshPacket.decoded = dataMessage
let messageDescription = "Saved LoRa Config for \(toUser.longName ?? "Unknown")"
let messageDescription = "Saved LoRa Config for \(toUser.longName ?? NSLocalizedString("unknown", comment: "Unknown"))"
if sendAdminMessageToRadio(meshPacket: meshPacket, adminDescription: messageDescription, fromUser: fromUser, toUser: toUser) {
return Int64(meshPacket.id)
@ -1235,7 +1235,7 @@ class BLEManager: NSObject, CBPeripheralDelegate, ObservableObject {
meshPacket.decoded = dataMessage
let messageDescription = "Saved Position Config for \(toUser.longName ?? "Unknown")"
let messageDescription = "Saved Position Config for \(toUser.longName ?? NSLocalizedString("unknown", comment: "Unknown"))"
if sendAdminMessageToRadio(meshPacket: meshPacket, adminDescription: messageDescription, fromUser: fromUser, toUser: toUser) {
@ -1264,7 +1264,7 @@ class BLEManager: NSObject, CBPeripheralDelegate, ObservableObject {
meshPacket.decoded = dataMessage
let messageDescription = "Saved WiFi Config for \(toUser.longName ?? "Unknown")"
let messageDescription = "Saved WiFi Config for \(toUser.longName ?? NSLocalizedString("unknown", comment: "Unknown"))"
if sendAdminMessageToRadio(meshPacket: meshPacket, adminDescription: messageDescription, fromUser: fromUser, toUser: toUser) {
@ -1292,7 +1292,7 @@ class BLEManager: NSObject, CBPeripheralDelegate, ObservableObject {
meshPacket.decoded = dataMessage
let messageDescription = "Saved Canned Message Module Config for \(toUser.longName ?? "Unknown")"
let messageDescription = "Saved Canned Message Module Config for \(toUser.longName ?? NSLocalizedString("unknown", comment: "Unknown"))"
if sendAdminMessageToRadio(meshPacket: meshPacket, adminDescription: messageDescription, fromUser: fromUser, toUser: toUser) {
@ -1321,7 +1321,7 @@ class BLEManager: NSObject, CBPeripheralDelegate, ObservableObject {
meshPacket.decoded = dataMessage
let messageDescription = "💾 Saved Canned Message Module Messages for \(toUser.longName ?? "Unknown")"
let messageDescription = "💾 Saved Canned Message Module Messages for \(toUser.longName ?? NSLocalizedString("unknown", comment: "Unknown"))"
if sendAdminMessageToRadio(meshPacket: meshPacket, adminDescription: messageDescription, fromUser: fromUser, toUser: toUser) {
@ -1412,7 +1412,7 @@ class BLEManager: NSObject, CBPeripheralDelegate, ObservableObject {
dataMessage.portnum = PortNum.adminApp
meshPacket.decoded = dataMessage
let messageDescription = "Saved External Notification Module Config for \(toUser.longName ?? "Unknown")"
let messageDescription = "Saved External Notification Module Config for \(toUser.longName ?? NSLocalizedString("unknown", comment: "Unknown"))"
if sendAdminMessageToRadio(meshPacket: meshPacket, adminDescription: messageDescription, fromUser: fromUser, toUser: toUser) {
return Int64(meshPacket.id)
}
@ -1438,7 +1438,7 @@ class BLEManager: NSObject, CBPeripheralDelegate, ObservableObject {
meshPacket.decoded = dataMessage
let messageDescription = "Saved WiFi Config for \(toUser.longName ?? "Unknown")"
let messageDescription = "Saved WiFi Config for \(toUser.longName ?? NSLocalizedString("unknown", comment: "Unknown"))"
if sendAdminMessageToRadio(meshPacket: meshPacket, adminDescription: messageDescription, fromUser: fromUser, toUser: toUser) {
@ -1466,7 +1466,7 @@ class BLEManager: NSObject, CBPeripheralDelegate, ObservableObject {
meshPacket.decoded = dataMessage
let messageDescription = "Saved Range Test Module Config for \(toUser.longName ?? "Unknown")"
let messageDescription = "Saved Range Test Module Config for \(toUser.longName ?? NSLocalizedString("unknown", comment: "Unknown"))"
if sendAdminMessageToRadio(meshPacket: meshPacket, adminDescription: messageDescription, fromUser: fromUser, toUser: toUser) {
@ -1494,7 +1494,7 @@ class BLEManager: NSObject, CBPeripheralDelegate, ObservableObject {
dataMessage.portnum = PortNum.adminApp
meshPacket.decoded = dataMessage
let messageDescription = "Saved Serial Module Config for \(toUser.longName ?? "Unknown")"
let messageDescription = "Saved Serial Module Config for \(toUser.longName ?? NSLocalizedString("unknown", comment: "Unknown"))"
if sendAdminMessageToRadio(meshPacket: meshPacket, adminDescription: messageDescription, fromUser: fromUser, toUser: toUser) {
return Int64(meshPacket.id)
}
@ -1518,7 +1518,7 @@ class BLEManager: NSObject, CBPeripheralDelegate, ObservableObject {
dataMessage.portnum = PortNum.adminApp
meshPacket.decoded = dataMessage
let messageDescription = "Saved Telemetry Module Config for \(toUser.longName ?? "Unknown")"
let messageDescription = "Saved Telemetry Module Config for \(toUser.longName ?? NSLocalizedString("unknown", comment: "Unknown"))"
if sendAdminMessageToRadio(meshPacket: meshPacket, adminDescription: messageDescription, fromUser: fromUser, toUser: toUser) {
return Int64(meshPacket.id)
}

View file

@ -1366,12 +1366,12 @@ func textMessageAppPacket(packet: MeshPacket, connectedNode: Int64, context: NSM
manager.notifications = [
Notification(
id: ("notification.id.\(newMessage.messageId)"),
title: "\(newMessage.fromUser?.longName ?? "Unknown")",
title: "\(newMessage.fromUser?.longName ?? NSLocalizedString("unknown", comment: "Unknown"))",
subtitle: "AKA \(newMessage.fromUser?.shortName ?? "???")",
content: messageText)
]
manager.schedule()
MeshLogger.log("💬 iOS Notification Scheduled for text message from \(newMessage.fromUser?.longName ?? "Unknown")")
MeshLogger.log("💬 iOS Notification Scheduled for text message from \(newMessage.fromUser?.longName ?? NSLocalizedString("unknown", comment: "Unknown"))")
} else if newMessage.fromUser != nil && newMessage.toUser == nil {
let fetchMyInfoRequest: NSFetchRequest<NSFetchRequestResult> = NSFetchRequest.init(entityName: "MyInfoEntity")
@ -1390,12 +1390,12 @@ func textMessageAppPacket(packet: MeshPacket, connectedNode: Int64, context: NSM
manager.notifications = [
Notification(
id: ("notification.id.\(newMessage.messageId)"),
title: "\(newMessage.fromUser?.longName ?? "Unknown")",
title: "\(newMessage.fromUser?.longName ?? NSLocalizedString("unknown", comment: "Unknown"))",
subtitle: "AKA \(newMessage.fromUser?.shortName ?? "???")",
content: messageText)
]
manager.schedule()
MeshLogger.log("💬 iOS Notification Scheduled for text message from \(newMessage.fromUser?.longName ?? "Unknown")")
MeshLogger.log("💬 iOS Notification Scheduled for text message from \(newMessage.fromUser?.longName ?? NSLocalizedString("unknown", comment: "Unknown"))")
}
}
} catch {

View file

@ -39,10 +39,10 @@ struct Connect: View {
if node != nil {
Text(bleManager.connectedPeripheral.longName).font(.title2)
}
Text("ble.name").font(.caption)+Text(": \(bleManager.connectedPeripheral.peripheral.name ?? "Unknown")")
Text("ble.name").font(.caption)+Text(": \(bleManager.connectedPeripheral.peripheral.name ?? NSLocalizedString("unknown", comment: "Unknown"))")
.font(.caption).foregroundColor(Color.gray)
if node != nil {
Text("firmware.version").font(.caption)+Text(": \(node?.myInfo?.firmwareVersion ?? "Unknown")")
Text("firmware.version").font(.caption)+Text(": \(node?.myInfo?.firmwareVersion ?? NSLocalizedString("unknown", comment: "Unknown"))")
.font(.caption).foregroundColor(Color.gray)
}
if bleManager.isSubscribed {
@ -101,7 +101,7 @@ struct Connect: View {
Text("Num: \(String(node!.num))")
Text("Short Name: \(node?.user?.shortName ?? "????")")
Text("Long Name: \(node?.user?.longName ?? "Unknown")")
Text("Long Name: \(node?.user?.longName ?? NSLocalizedString("unknown", comment: "Unknown"))")
Text("Max Channels: \(String(node?.myInfo?.maxChannels ?? 0))")
Text("Bitrate: \(String(format: "%.2f", node?.myInfo?.bitrate ?? 0.00))")
Text("BLE RSSI: \(bleManager.connectedPeripheral.rssi)")

View file

@ -124,7 +124,7 @@ private extension MapView {
if (node.positions?.count ?? 0) > 0 && (node.positions!.lastObject as! PositionEntity).coordinate != nil {
let annotation = PositionAnnotation()
annotation.coordinate = (node.positions!.lastObject as! PositionEntity).coordinate!
annotation.title = node.user?.longName ?? "Unknown"
annotation.title = node.user?.longName ?? NSLocalizedString("unknown", comment: "Unknown")
annotation.shortName = node.user?.shortName?.uppercased() ?? "???"
view.addAnnotation(annotation)

View file

@ -118,20 +118,6 @@ public struct MapView: UIViewRepresentable {
mapView.delegate = context.coordinator
mapView.register(PositionAnnotationView.self, forAnnotationViewWithReuseIdentifier: NSStringFromClass(PositionAnnotationView.self))
/*Timer.scheduledTimer(withTimeInterval: 10, repeats: true) { timer in
for node in self.locationNodes {
// try and get the last position
if (node.positions?.count ?? 0) > 0 && (node.positions!.lastObject as! PositionEntity).coordinate != nil {
let annotation = PositionAnnotation()
annotation.coordinate = (node.positions!.lastObject as! PositionEntity).coordinate!
annotation.title = node.user?.longName ?? "Unknown"
annotation.shortName = node.user?.shortName?.uppercased() ?? "???"
mapView.addAnnotation(annotation)
}
}
}*/
return mapView
}
@ -229,18 +215,6 @@ public struct MapView: UIViewRepresentable {
} else {
shouldMoveRegion = true
}
/*for node in self.locationNodes {
// try and get the last position
if (node.positions?.count ?? 0) > 0 && (node.positions!.lastObject as! PositionEntity).coordinate != nil {
let annotation = PositionAnnotation()
annotation.coordinate = (node.positions!.lastObject as! PositionEntity).coordinate!
annotation.title = node.user?.longName ?? "Unknown"
annotation.shortName = node.user?.shortName?.uppercased() ?? "???"
mapView.addAnnotation(annotation)
}
}*/
var displayedNodes: [Int64] = []
for position in self.positions {
@ -250,7 +224,7 @@ public struct MapView: UIViewRepresentable {
let annotation = PositionAnnotation()
annotation.coordinate = position.coordinate!
annotation.title = position.nodePosition!.user?.longName ?? "Unknown"
annotation.title = position.nodePosition!.user?.longName ?? NSLocalizedString("unknown", comment: "Unknown")
annotation.shortName = position.nodePosition!.user?.shortName?.uppercased() ?? "???"
mapView.addAnnotation(annotation)

View file

@ -355,7 +355,7 @@ struct ChannelMessageList: View {
ToolbarItem(placement: .principal) {
HStack {
CircleText(text: String(channel.index), color: .accentColor, circleSize: 44, fontSize: 30).fixedSize()
Text(String(channel.name ?? "Unknown").camelCaseToWords()).font(.headline)
Text(String(channel.name ?? NSLocalizedString("unknown", comment: "Unknown")).camelCaseToWords()).font(.headline)
}
}
ToolbarItem(placement: .navigationBarTrailing) {

View file

@ -151,7 +151,7 @@ struct Contacts: View {
.padding(.trailing, 5)
VStack {
HStack {
Text(user.longName ?? "Unknown").font(.headline)
Text(user.longName ?? NSLocalizedString("unknown", comment: "Unknown")).font(.headline)
Spacer()
if user.messageList.count > 0 {
VStack (alignment: .trailing) {

View file

@ -354,7 +354,7 @@ struct UserMessageList: View {
ToolbarItem(placement: .principal) {
HStack {
CircleText(text: user.shortName ?? "???", color: .accentColor, circleSize: 44, fontSize: 14).fixedSize()
Text(user.longName ?? "Unknown").font(.headline)
Text(user.longName ?? NSLocalizedString("unknown", comment: "Unknown")).font(.headline)
}
}
ToolbarItem(placement: .navigationBarTrailing) {

View file

@ -404,7 +404,7 @@ struct NodeDetail: View {
.offset( y:-40)
}
.edgesIgnoringSafeArea([.leading, .trailing])
.navigationBarTitle((node.user != nil) ? String(node.user!.longName ?? "Unknown") : "Unknown", displayMode: .inline)
.navigationBarTitle(String(node.user?.longName ?? NSLocalizedString("unknown", comment: "Unknown")), displayMode: .inline)
.padding(.bottom, 10)
.navigationBarItems(trailing:

View file

@ -39,7 +39,7 @@ struct NodeList: View {
CircleText(text: node.user?.shortName ?? "???", color: .accentColor, circleSize: 52, fontSize: 16, brightness: 0.1)
.padding(.trailing, 5)
VStack(alignment: .leading) {
Text(node.user?.longName ?? "Unknown").font(.headline)
Text(node.user?.longName ?? NSLocalizedString("unknown", comment: "Unknown")).font(.headline)
if connected {
HStack(alignment: .bottom) {
Image(systemName: "repeat.circle.fill")

View file

@ -29,7 +29,7 @@ struct AdminMessageList: View {
HStack {
Text("\(am.adminDescription ?? "Unknown") - \(Date(timeIntervalSince1970: TimeInterval(am.messageTimestamp)), style: .date) \(Date(timeIntervalSince1970: TimeInterval(am.messageTimestamp)).formattedDate(format: "h:mm:ss a"))")
Text("\(am.adminDescription ?? NSLocalizedString("unknown", comment: "Unknown")) - \(Date(timeIntervalSince1970: TimeInterval(am.messageTimestamp)), style: .date) \(Date(timeIntervalSince1970: TimeInterval(am.messageTimestamp)).formattedDate(format: "h:mm:ss a"))")
.font(.caption)
if am.receivedACK {

View file

@ -196,6 +196,7 @@
"telemetry.config"="Telemetrie Einstellungen";
"timeout"="Zeitlimit erreicht";
"twitter"="Twitter";
"unknown"="Unknown";
"unknown.age"="Unbekanntes alter";
"unset"="Unset";
"update.firmware"="Update Your Firmware";

View file

@ -196,6 +196,7 @@
"telemetry.config"="Telemetry Config";
"timeout"="timeout";
"twitter"="Twitter";
"unknown"="Unknown";
"unknown.age"="Unknown Age";
"unset"="Unset";
"update.firmware"="Update Your Firmware";