From 5d583114bb045669113aeb11e64724a007852c8a Mon Sep 17 00:00:00 2001 From: Fernando Bunn Date: Wed, 30 Oct 2024 23:19:02 +0000 Subject: [PATCH] Update copy for AI Chat preferences --- DuckDuckGo/Common/Localizables/UserText.swift | 4 ++++ .../Preferences/Model/AIChatPreferences.swift | 4 ++++ .../Preferences/View/PreferencesAIChat.swift | 18 +++++++++++++++++- 3 files changed, 25 insertions(+), 1 deletion(-) diff --git a/DuckDuckGo/Common/Localizables/UserText.swift b/DuckDuckGo/Common/Localizables/UserText.swift index 078c18e253..5b4b20b0c2 100644 --- a/DuckDuckGo/Common/Localizables/UserText.swift +++ b/DuckDuckGo/Common/Localizables/UserText.swift @@ -369,6 +369,10 @@ struct UserText { static let aiChatShowInApplicationMenuToggle = NSLocalizedString("ai-chat.show-in-application-menu.toggle", value: "Show “New AI Chat” in File and application menus", comment: "Show AI Chat in application menus") + static let aiChatPreferencesCaptionWithLinkMarkdown = NSLocalizedString("ai-chat.preferences.caption.link.markdown", value: "AI Chat is an optional feature available at [duck.ai](https://duck.ai) that lets you have private conversations with popular 3rd-party AI chat models. Your chats are not used to train chat models.", comment: "Ai Chat preferences explanation with a markdown link. Do not translate what's inside [] and ()") + + static let aiChatPreferencesCaptionWithLinkFallback = NSLocalizedString("ai-chat.preferences.caption.link.fallback", value: "AI Chat is an optional feature available at duck.ai that lets you have private conversations with popular 3rd-party AI chat models. Your chats are not used to train chat models.", comment: "Ai Chat preferences explanation") + static let aiChatPreferencesCaption = NSLocalizedString("ai-chat.preferences.caption", value: "Launch AI Chat faster by adding shortcuts to your browser toolbar or menu", comment: "Ai Chat preferences explanation") static let aiChatPreferencesLearnMoreButton = NSLocalizedString("ai-chat.preferences.learn-more", value: "Learn More", comment: "AI Chat preferences button to learn more about it") diff --git a/DuckDuckGo/Preferences/Model/AIChatPreferences.swift b/DuckDuckGo/Preferences/Model/AIChatPreferences.swift index d9fadda8d0..ae247634a3 100644 --- a/DuckDuckGo/Preferences/Model/AIChatPreferences.swift +++ b/DuckDuckGo/Preferences/Model/AIChatPreferences.swift @@ -78,4 +78,8 @@ final class AIChatPreferences: ObservableObject { @MainActor func openLearnMoreLink() { WindowControllersManager.shared.show(url: learnMoreURL, source: .ui, newTab: true) } + + @MainActor func openAIChatLink() { + AIChatTabOpener.openAIChatTab() + } } diff --git a/DuckDuckGo/Preferences/View/PreferencesAIChat.swift b/DuckDuckGo/Preferences/View/PreferencesAIChat.swift index 4cce8719f1..ad4193c9a0 100644 --- a/DuckDuckGo/Preferences/View/PreferencesAIChat.swift +++ b/DuckDuckGo/Preferences/View/PreferencesAIChat.swift @@ -30,7 +30,23 @@ extension Preferences { TextMenuTitle(UserText.aiChat) PreferencePaneSubSection { VStack(alignment: .leading, spacing: 1) { - TextMenuItemCaption(UserText.aiChatPreferencesCaption) + if #available(macOS 12, *) { + // Use Markdown for macOS 12 and newer + // .init is required for markdown to be correctly parsed from NSLocalizedString + Text(.init(UserText.aiChatPreferencesCaptionWithLinkMarkdown)) + .environment(\.openURL, OpenURLAction { _ in + model.openAIChatLink() + return .handled + }) + .tint(Color(.linkBlue)) + .frame(maxWidth: .infinity, alignment: .leading) + .fixMultilineScrollableText() + .foregroundColor(Color(.greyText)) + } else { + // Fallback for earlier macOS versions + TextMenuItemCaption(UserText.bookmarksBarPromptMessageFallback) + } + TextButton(UserText.aiChatPreferencesLearnMoreButton) { model.openLearnMoreLink() }