From 4a62d0d1aefb66d91dc34f37f8a2fc7e0ade7d05 Mon Sep 17 00:00:00 2001 From: Balazs Perlaki-Horvath Date: Thu, 28 Mar 2024 23:40:06 +0100 Subject: [PATCH] Make support url brandable --- App/App_macOS.swift | 16 ++++++++++------ Model/Brand.swift | 2 ++ Support/en.lproj/Localizable.strings | 6 ++---- Support/qqq.lproj/Localizable.strings | 2 ++ Views/Settings/Settings.swift | 5 ++++- 5 files changed, 20 insertions(+), 11 deletions(-) diff --git a/App/App_macOS.swift b/App/App_macOS.swift index a6041241..09f1434d 100644 --- a/App/App_macOS.swift +++ b/App/App_macOS.swift @@ -103,13 +103,17 @@ struct RootView: View { } } .safeAreaInset(edge: .bottom) { - Link(destination: URL(string: "donations.url".localized)!) { - HStack { - Image(systemName: "heart") - Text("enum.navigation_item.donations".localized) - .foregroundColor(.primary) + if let url = URL(string: Brand.supportURLString) { + Link(destination: url) { + HStack { + Image(systemName: "heart") + Text("enum.navigation_item.donations".localizedWithFormat(withArgs: Brand.appName)) + .foregroundColor(.primary) + Spacer() + } } - .padding()} + .padding() + } } .frame(minWidth: 150) .toolbar { diff --git a/Model/Brand.swift b/Model/Brand.swift index d367dd91..7fafc74f 100644 --- a/Model/Brand.swift +++ b/Model/Brand.swift @@ -36,6 +36,7 @@ enum Brand { static let welcomeLogoImageName: String = "welcomeLogo" static let aboutText: String = Config.value(for: .aboutText) ?? "settings.about.description".localized static let aboutWebsite: String = Config.value(for: .aboutWebsite) ?? "https://www.kiwix.org" + static let supportURLString: String = Config.value(for: .supportURL) ?? "https://kiwix.org/get-involved/" static var defaultExternalLinkPolicy: ExternalLinkLoadingPolicy { guard let policyString: String = Config.value(for: .externalLinkDefaultPolicy), @@ -66,6 +67,7 @@ enum Config: String { case showSearchSnippetInSettings = "SETTINGS_SHOW_SEARCH_SNIPPET" case aboutText = "CUSTOM_ABOUT_TEXT" case aboutWebsite = "CUSTOM_ABOUT_WEBSITE" + case supportURL = "SUPPORT_URL" static func value(for key: Config) -> T? where T: LosslessStringConvertible { guard let object = Bundle.main.object(forInfoDictionaryKey: key.rawValue) else { diff --git a/Support/en.lproj/Localizable.strings b/Support/en.lproj/Localizable.strings index d6edc9d8..ec835524 100644 --- a/Support/en.lproj/Localizable.strings +++ b/Support/en.lproj/Localizable.strings @@ -167,7 +167,7 @@ "settings.miscellaneous.title" = "Misc"; "settings.miscellaneous.button.feedback" = "Feedback"; "settings.miscellaneous.button.rate_app" = "Rate the App"; -"settings.miscellaneous.button.donate" = "Support Kiwix"; +"settings.miscellaneous.button.donate" = "Support %@"; "settings.miscellaneous.navigation.about" = "About"; "settings.selected_language.title" = "Languages"; "language_selector.name.title" = "Name"; @@ -264,10 +264,8 @@ "enum.navigation_item.new" = "New"; "enum.navigation_item.downloads" = "Downloads"; "enum.navigation_item.settings" = "Settings"; -"enum.navigation_item.donations" = "Support Kiwix"; +"enum.navigation_item.donations" = "Support %@"; "enum.search_result_snippet_mode.disabled" = "Disabled"; "enum.search_result_snippet_mode.paragraph" = "First Paragraph"; "enum.search_result_snippet_mode.sentence" = "First Sentence"; "enum.search_result_snippet_mode.matches" = "Matches"; - -"donations.url" = "https://kiwix.org/get-involved/"; diff --git a/Support/qqq.lproj/Localizable.strings b/Support/qqq.lproj/Localizable.strings index a19da98e..bfa7b48e 100644 --- a/Support/qqq.lproj/Localizable.strings +++ b/Support/qqq.lproj/Localizable.strings @@ -140,6 +140,7 @@ "settings.miscellaneous.button.feedback" = "Button title in settings"; "settings.miscellaneous.button.rate_app" = "Button title in settings"; "settings.miscellaneous.navigation.about" = "Button title in settings opening the about page"; +"settings.miscellaneous.button.donate" = "Button title in settings, opening the external browser to support the app. The App Name being the argument, eg: Support Kiwix" "settings.selected_language.title" = "Label text for language picker in settings"; "language_selector.name.title" = "Table header name in listing the languages and ZIM file count in each language in settings"; "language_selector.count.table.title" = "Table header name in listing the languages and ZIM file count in each language in settings"; @@ -224,6 +225,7 @@ "enum.navigation_item.new" = "Side navigation menu item title"; "enum.navigation_item.downloads" = "Side navigation menu item title"; "enum.navigation_item.settings" = "Side navigation menu item title"; +"enum.navigation_item.donations" = "Side navigation menu item title, with the App Name being the argument, eg: Support Kiwix" "enum.search_result_snippet_mode.disabled" = "Picker option title in settings. Search snippet: Disabled | First Paragraph | First Sentence | Matches"; "enum.search_result_snippet_mode.paragraph" = "Picker option title in settings. Search snippet: Disabled | First Paragraph | First Sentence | Matches"; "enum.search_result_snippet_mode.sentence" = "Picker option title in settings. Search snippet: Disabled | First Paragraph | First Sentence | Matches"; diff --git a/Views/Settings/Settings.swift b/Views/Settings/Settings.swift index 9e20c8da..f4fc0014 100644 --- a/Views/Settings/Settings.swift +++ b/Views/Settings/Settings.swift @@ -228,7 +228,10 @@ struct Settings: View { appStoreID: Brand.appStoreId) UIApplication.shared.open(url) } - Link("settings.miscellaneous.button.donate".localized, destination: URL(string: "donations.url".localized)!) + if let url = URL(string: Brand.supportURLString) { + Link("settings.miscellaneous.button.donate".localizedWithFormat(withArgs: Brand.appName), + destination: url) + } NavigationLink("settings.miscellaneous.navigation.about".localized) { About() } } }