Files
bitchat/bitchat/ViewModels/ChatBluetoothAlertPolicy.swift
T
jackandClaude Fable 5 9cbfd131da i18n: add English defaultValue fallback to key-only localized strings so no language shows raw keys
Non-en languages are each missing ~138 of 336 catalog keys, so a key
absent from that language's table renders as the raw dot-key on device
(no English fallback). This adds English defaultValues so every miss
resolves to English instead of a raw key.

- Class (a): 217 String(localized: "dot.key") calls missing defaultValue
  now carry defaultValue: "<en value>" pulled verbatim from the catalog
  (format specifiers preserved).
- Class (b): 41 SwiftUI LocalizedStringKey literals (Text/Button/alert/
  confirmationDialog/TextField) wrapped as
  Text(String(localized: "key", defaultValue: "en")) so they resolve to
  English too. Existing comments folded into the resolved String.

No catalog or en values changed; Swift source only. Both schemes build.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-06 23:58:29 +02:00

36 lines
1.7 KiB
Swift

import CoreBluetooth
import Foundation
struct ChatBluetoothAlertUpdate: Equatable {
let isPresented: Bool
let message: String?
}
enum ChatBluetoothAlertPolicy {
static func update(for state: CBManagerState) -> ChatBluetoothAlertUpdate {
switch state {
case .poweredOff:
ChatBluetoothAlertUpdate(
isPresented: true,
message: String(localized: "content.alert.bluetooth_required.off", defaultValue: "bluetooth is turned off. please turn on bluetooth in settings to use bitchat.", comment: "Message shown when Bluetooth is turned off")
)
case .unauthorized:
ChatBluetoothAlertUpdate(
isPresented: true,
message: String(localized: "content.alert.bluetooth_required.permission", defaultValue: "bitchat needs bluetooth permission to connect with nearby devices. please enable bluetooth access in settings.", comment: "Message shown when Bluetooth permission is missing")
)
case .unsupported:
ChatBluetoothAlertUpdate(
isPresented: true,
message: String(localized: "content.alert.bluetooth_required.unsupported", defaultValue: "this device does not support bluetooth. bitchat requires bluetooth to function.", comment: "Message shown when the device lacks Bluetooth support")
)
case .poweredOn:
ChatBluetoothAlertUpdate(isPresented: false, message: "")
case .unknown, .resetting:
ChatBluetoothAlertUpdate(isPresented: false, message: nil)
@unknown default:
ChatBluetoothAlertUpdate(isPresented: false, message: nil)
}
}
}