Add Apple translation popovers for notes for iOS 17.4+ and macOS 14.4+

Changelog-Added: Add Apple translation popovers for notes for iOS 17.4+ and macOS 14.4+
This commit is contained in:
2024-06-21 00:11:18 -04:00
committed by Daniel D’Aquino
parent 51ee4046a0
commit 2a19d5d831
4 changed files with 65 additions and 22 deletions

View File

@@ -38,7 +38,13 @@ enum TranslationService: String, CaseIterable, Identifiable, StringCodable {
var model: Model {
switch self {
case .none:
return .init(tag: self.rawValue, displayName: NSLocalizedString("none_translation_service", value: "None", comment: "Dropdown option for selecting no translation service."))
let displayName: String
if TranslationService.isAppleTranslationPopoverSupported {
displayName = NSLocalizedString("apple_translation_service", value: "Apple", comment: "Dropdown option for selecting Apple as a translation service.")
} else {
displayName = NSLocalizedString("none_translation_service", value: "None", comment: "Dropdown option for selecting no translation service.")
}
return .init(tag: self.rawValue, displayName: displayName)
case .purple:
return .init(tag: self.rawValue, displayName: NSLocalizedString("Damus Purple", comment: "Dropdown option for selecting Damus Purple as a translation service."))
case .libretranslate:
@@ -51,4 +57,12 @@ enum TranslationService: String, CaseIterable, Identifiable, StringCodable {
return .init(tag: self.rawValue, displayName: NSLocalizedString("translate.nostr.wine (DeepL, Pay with BTC)", comment: "Dropdown option for selecting translate.nostr.wine as the translation service."))
}
}
static var isAppleTranslationPopoverSupported: Bool {
if #available(iOS 17.4, macOS 14.4, *) {
return true
} else {
return false
}
}
}