Skip to content

Commit

Permalink
Update copy for AI Chat preferences
Browse files Browse the repository at this point in the history
  • Loading branch information
Bunn committed Oct 30, 2024
1 parent ddeaf85 commit 5d58311
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 1 deletion.
4 changes: 4 additions & 0 deletions DuckDuckGo/Common/Localizables/UserText.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand Down
4 changes: 4 additions & 0 deletions DuckDuckGo/Preferences/Model/AIChatPreferences.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
}
18 changes: 17 additions & 1 deletion DuckDuckGo/Preferences/View/PreferencesAIChat.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
Expand Down

0 comments on commit 5d58311

Please sign in to comment.