Add base localization infrastructure and externalize strings (#670)

* Add base localization infrastructure and externalize strings

* Add Spanish localization scaffolding with translations

* Add machine translations for expanded locales

---------

Co-authored-by: jack <jackjackbits@users.noreply.github.com>
This commit is contained in:
jack
2025-09-24 15:12:42 +02:00
committed by GitHub
co-authored by jack
parent de906cb97c
commit f5caa1751a
58 changed files with 4482 additions and 276 deletions
+18 -3
View File
@@ -76,6 +76,21 @@ final class LocationNotesManager: ObservableObject {
private var subscriptionID: String?
private let dependencies: LocationNotesDependencies
private enum Strings {
static let noRelays = NSLocalizedString(
"location_notes.error.no_relays",
comment: "Shown when no geo relays are available near the selected location"
)
static func failedToSend(_ detail: String) -> String {
let format = NSLocalizedString(
"location_notes.error.failed_to_send",
comment: "Shown when a location note fails to send"
)
return String(format: format, detail)
}
}
init(geohash: String, dependencies: LocationNotesDependencies = .live) {
self.geohash = geohash.lowercased()
self.dependencies = dependencies
@@ -120,7 +135,7 @@ final class LocationNotesManager: ObservableObject {
subscriptionID = nil
initialLoadComplete = true
state = .noRelays
errorMessage = "No geo relays available near this location. Try again soon."
errorMessage = Strings.noRelays
SecureLogger.warning("LocationNotesManager: no geo relays for geohash=\(geohash)", category: .session)
return
}
@@ -158,7 +173,7 @@ final class LocationNotesManager: ObservableObject {
let relays = dependencies.relayLookup(geohash, TransportConfig.nostrGeoRelayCount)
guard !relays.isEmpty else {
state = .noRelays
errorMessage = "No geo relays available near this location. Try again soon."
errorMessage = Strings.noRelays
SecureLogger.warning("LocationNotesManager: send blocked, no geo relays for geohash=\(geohash)", category: .session)
return
}
@@ -184,7 +199,7 @@ final class LocationNotesManager: ObservableObject {
self.errorMessage = nil
} catch {
SecureLogger.error("LocationNotesManager: failed to send note: \(error)", category: .session)
errorMessage = "Failed to send note. \(error.localizedDescription)"
errorMessage = Strings.failedToSend(error.localizedDescription)
}
}
+50 -5
View File
@@ -115,15 +115,60 @@ enum EncryptionStatus: Equatable {
var description: String {
switch self {
case .none:
return "Encryption failed"
return L10n.string(
"encryption.status.failed",
comment: "Status text when encryption failed"
)
case .noHandshake:
return "Not encrypted"
return L10n.string(
"encryption.status.not_encrypted",
comment: "Status text when no encryption handshake happened"
)
case .noiseHandshaking:
return "Establishing encryption..."
return L10n.string(
"encryption.status.establishing",
comment: "Status text when encryption is being established"
)
case .noiseSecured:
return "Encrypted"
return L10n.string(
"encryption.status.secured",
comment: "Status text when encryption is secured but not verified"
)
case .noiseVerified:
return "Encrypted & Verified"
return L10n.string(
"encryption.status.verified",
comment: "Status text when encryption is verified"
)
}
}
var accessibilityDescription: String {
switch self {
case .none:
return L10n.string(
"encryption.accessibility.failed",
comment: "Accessibility text when encryption failed"
)
case .noHandshake:
return L10n.string(
"encryption.accessibility.not_encrypted",
comment: "Accessibility text when encryption is not established"
)
case .noiseHandshaking:
return L10n.string(
"encryption.accessibility.establishing",
comment: "Accessibility text when encryption is being established"
)
case .noiseSecured:
return L10n.string(
"encryption.accessibility.secured",
comment: "Accessibility text when encryption is secured"
)
case .noiseVerified:
return L10n.string(
"encryption.accessibility.verified",
comment: "Accessibility text when encryption is verified"
)
}
}
}