From c4861679697148d88d142be798053b6226f5e0e9 Mon Sep 17 00:00:00 2001 From: Satindar Dhillon Date: Wed, 25 Jan 2023 10:59:38 -0800 Subject: [PATCH] use more LocalText --- .../App/Views/Profile/ManageAccountView.swift | 8 ++++---- .../Views/Profile/NewsletterEmailsView.swift | 2 +- .../Sources/App/Views/Profile/ProfileView.swift | 2 +- .../Profile/PushNotificationDevicesView.swift | 4 ++-- .../Profile/PushNotificationSettingsView.swift | 12 +++--------- .../Views/Profile/RecommendationGroupView.swift | 17 ++++++++--------- .../Profile/RecommendationGroupsView.swift | 16 ++++------------ .../App/Views/WebReader/RecommendToView.swift | 4 +--- .../Sources/Views/CommunityModal.swift | 12 ++++++------ .../PushNotificationPrimerView.swift | 8 ++++---- 10 files changed, 34 insertions(+), 51 deletions(-) diff --git a/apple/OmnivoreKit/Sources/App/Views/Profile/ManageAccountView.swift b/apple/OmnivoreKit/Sources/App/Views/Profile/ManageAccountView.swift index e3db2601e..020909470 100644 --- a/apple/OmnivoreKit/Sources/App/Views/Profile/ManageAccountView.swift +++ b/apple/OmnivoreKit/Sources/App/Views/Profile/ManageAccountView.swift @@ -35,18 +35,18 @@ struct ManageAccountView: View { action: { showDeleteAccountConfirmation = true }, - label: { Text("Delete Account") } + label: { Text(LocalText.manageAccountDelete) } ) Button( action: { dataService.resetCoreData() }, - label: { Text("Reset Data Cache") } + label: { Text(LocalText.manageAccountResetCache) } ) .alert(isPresented: $showDeleteAccountConfirmation) { Alert( - title: Text("Are you sure you want to delete your account? This action can't be undone."), - primaryButton: .destructive(Text("Delete Account")) { + title: Text(LocalText.manageAccountConfirmDeleteMessage), + primaryButton: .destructive(Text(LocalText.manageAccountDelete)) { Task { await viewModel.deleteAccount(dataService: dataService, authenticator: authenticator) } diff --git a/apple/OmnivoreKit/Sources/App/Views/Profile/NewsletterEmailsView.swift b/apple/OmnivoreKit/Sources/App/Views/Profile/NewsletterEmailsView.swift index ffd878a3a..b6f9ada3b 100644 --- a/apple/OmnivoreKit/Sources/App/Views/Profile/NewsletterEmailsView.swift +++ b/apple/OmnivoreKit/Sources/App/Views/Profile/NewsletterEmailsView.swift @@ -73,7 +73,7 @@ struct NewsletterEmailsView: View { } if !viewModel.emails.isEmpty { - Section(header: Text("Existing Emails (Tap to copy)")) { + Section(header: Text(LocalText.newsletterEmailsExisting)) { ForEach(viewModel.emails) { newsletterEmail in Button( action: { diff --git a/apple/OmnivoreKit/Sources/App/Views/Profile/ProfileView.swift b/apple/OmnivoreKit/Sources/App/Views/Profile/ProfileView.swift index 57620e2fe..9cf579550 100644 --- a/apple/OmnivoreKit/Sources/App/Views/Profile/ProfileView.swift +++ b/apple/OmnivoreKit/Sources/App/Views/Profile/ProfileView.swift @@ -152,7 +152,7 @@ struct ProfileView: View { } .alert(isPresented: $showLogoutConfirmation) { Alert( - title: Text("Are you sure you want to logout?"), + title: Text(LocalText.profileConfirmLogoutMessage), primaryButton: .destructive(Text("Confirm")) { authenticator.logout(dataService: dataService) }, diff --git a/apple/OmnivoreKit/Sources/App/Views/Profile/PushNotificationDevicesView.swift b/apple/OmnivoreKit/Sources/App/Views/Profile/PushNotificationDevicesView.swift index 00c90617c..b334cea50 100644 --- a/apple/OmnivoreKit/Sources/App/Views/Profile/PushNotificationDevicesView.swift +++ b/apple/OmnivoreKit/Sources/App/Views/Profile/PushNotificationDevicesView.swift @@ -60,9 +60,9 @@ struct PushNotificationDevicesView: View { private var innerBody: some View { List { - Section(header: Text("Registered device tokens (swipe to remove)")) { + Section(header: Text(LocalText.devicesTokensTitle)) { ForEach(viewModel.devices) { device in - Text("Created: \(createdStr(device))") + Text("\(LocalText.devicesCreated)\(createdStr(device))") .swipeActions(edge: .trailing) { Button( role: .destructive, diff --git a/apple/OmnivoreKit/Sources/App/Views/Profile/PushNotificationSettingsView.swift b/apple/OmnivoreKit/Sources/App/Views/Profile/PushNotificationSettingsView.swift index afd361772..330291138 100644 --- a/apple/OmnivoreKit/Sources/App/Views/Profile/PushNotificationSettingsView.swift +++ b/apple/OmnivoreKit/Sources/App/Views/Profile/PushNotificationSettingsView.swift @@ -69,19 +69,13 @@ struct PushNotificationSettingsView: View { private var innerBody: some View { Group { Section { - Toggle(isOn: $viewModel.desiredNotificationsEnabled, label: { Text("Notifications Enabled") }) + Toggle(isOn: $viewModel.desiredNotificationsEnabled, label: { Text(LocalText.notificationsEnabled) }) }.onChange(of: viewModel.desiredNotificationsEnabled) { _ in viewModel.tryUpdateToDesired(dataService: dataService) } - Section { - Text(""" - Enabling push notifications gives Omnivore device permission to send notifications, \ - but you are in charge of which notifications are sent. - - Push notifications are triggered using your \ - [account rules](https://omnivore.app/settings/rules) which you can edit online. - """) + Section { // TODO: double check this text + Text("\(LocalText.notificationsExplainer)\n\(LocalText.notificationsTriggerExplainer)") .accentColor(.blue) } diff --git a/apple/OmnivoreKit/Sources/App/Views/Profile/RecommendationGroupView.swift b/apple/OmnivoreKit/Sources/App/Views/Profile/RecommendationGroupView.swift index f91c64577..c076ce392 100644 --- a/apple/OmnivoreKit/Sources/App/Views/Profile/RecommendationGroupView.swift +++ b/apple/OmnivoreKit/Sources/App/Views/Profile/RecommendationGroupView.swift @@ -109,7 +109,7 @@ struct RecommendationGroupView: View { if let shareLink = URL(string: viewModel.recommendationGroup.inviteUrl) { return AnyView(ShareSheet(activityItems: [shareLink])) } else { - return AnyView(Text("Error copying invite URL")) + return AnyView(Text(LocalText.clubsErrorCopying)) } } @@ -127,9 +127,9 @@ struct RecommendationGroupView: View { private var membersSection: some View { Section("Members") { - if !viewModel.recommendationGroup.canSeeMembers { + if !viewModel.recommendationGroup.canSeeMembers { // TODO: might need to fix text here Text(""" - The admin of this club does not allow viewing all members. + \(LocalText.clubsAdminDenyViewing) [Learn more about clubs](https://blog.omnivore.app/p/dca38ba4-8a74-42cc-90ca-d5ffa5d075cc) """) @@ -142,10 +142,9 @@ struct RecommendationGroupView: View { imageURL: member.profileImageURL != nil ? URL(string: member.profileImageURL!) : nil )) } - } else { + } else { // TODO: fix link text to use translation Text(""" - This club does not have any members. Add users to your club by sending - them the invite link. + \(LocalText.clubsNoMembers) [Learn more about clubs](https://blog.omnivore.app/p/dca38ba4-8a74-42cc-90ca-d5ffa5d075cc) """) @@ -160,7 +159,7 @@ struct RecommendationGroupView: View { } return AnyView(Button(action: { viewModel.showLeaveGroup = true - }, label: { Text("Leave Club") }) + }, label: { Text(LocalText.clubsLeave) }) .accentColor(.red)) } @@ -196,8 +195,8 @@ struct RecommendationGroupView: View { } .alert(isPresented: $viewModel.showLeaveGroup) { Alert( - title: Text("Are you sure you want to leave this club? No data will be deleted, but you will stop receiving recommendations from the club."), - primaryButton: .destructive(Text("Leave Club")) { + title: Text(Localtext.clubsLeaveConfirm), + primaryButton: .destructive(Text(LocalText.clubsLeave)) { Task { let success = await viewModel.leaveGroup(dataService: dataService) if success { diff --git a/apple/OmnivoreKit/Sources/App/Views/Profile/RecommendationGroupsView.swift b/apple/OmnivoreKit/Sources/App/Views/Profile/RecommendationGroupsView.swift index 0df891584..701510ca1 100644 --- a/apple/OmnivoreKit/Sources/App/Views/Profile/RecommendationGroupsView.swift +++ b/apple/OmnivoreKit/Sources/App/Views/Profile/RecommendationGroupsView.swift @@ -72,7 +72,7 @@ struct CreateRecommendationGroupView: View { var body: some View { NavigationView { Form { - TextField("Name", text: $name, prompt: Text("Club Name")) + TextField("Name", text: $name, prompt: Text(Localtext.clubsName)) Section("Club Rules") { Toggle("Only admins can post", isOn: $viewModel.onlyAdminCanPost) @@ -143,7 +143,7 @@ struct GroupsView: View { label: { HStack { Image(systemName: "plus.circle.fill").foregroundColor(.green) - Text("Create a new club") + Text(LocalText.clubsCreate) Spacer() } } @@ -152,7 +152,7 @@ struct GroupsView: View { if !viewModel.isLoading { if viewModel.recommendationGroups.count > 0 { - Section(header: Text("Your clubs")) { + Section(header: Text(LocalText.clubsYours)) { ForEach(viewModel.recommendationGroups) { recommendationGroup in let vm = RecommendationsGroupViewModel(recommendationGroup: recommendationGroup) NavigationLink( @@ -164,15 +164,7 @@ struct GroupsView: View { } } else { Section { - Text(""" - You are not a member of any clubs. - Create a new club and send the invite link to your friends get started. - - During the beta you are limited to creating three clubs, and each club - can have a maximum of twelve users. - - [Learn more about clubs](https://blog.omnivore.app/p/dca38ba4-8a74-42cc-90ca-d5ffa5d075cc) - """) + Text(LocalText.clubsNotAMemberMessage) .accentColor(.blue) } } diff --git a/apple/OmnivoreKit/Sources/App/Views/WebReader/RecommendToView.swift b/apple/OmnivoreKit/Sources/App/Views/WebReader/RecommendToView.swift index 80ecc315a..e5baeeb32 100644 --- a/apple/OmnivoreKit/Sources/App/Views/WebReader/RecommendToView.swift +++ b/apple/OmnivoreKit/Sources/App/Views/WebReader/RecommendToView.swift @@ -163,9 +163,7 @@ struct RecommendToView: View { List { if !viewModel.isLoading, viewModel.recommendationGroups.count < 1 { Text(""" - You do not have any clubs you can post to. - - Join a club or create your own to start recommending articles. + \(LocalText.clubsNoneJoined) [Learn more about clubs](https://blog.omnivore.app/p/dca38ba4-8a74-42cc-90ca-d5ffa5d075cc) """) diff --git a/apple/OmnivoreKit/Sources/Views/CommunityModal.swift b/apple/OmnivoreKit/Sources/Views/CommunityModal.swift index 9198a93c7..c8a60b06e 100644 --- a/apple/OmnivoreKit/Sources/Views/CommunityModal.swift +++ b/apple/OmnivoreKit/Sources/Views/CommunityModal.swift @@ -54,7 +54,7 @@ public struct CommunityModal: View { public var header: some View { VStack(spacing: 0) { - Text("Help build the Omnivore Community") + Text(LocalText.communityHeadline) .font(.textToSpeechRead) .foregroundColor(Color.appGrayTextContrast) .frame(maxWidth: .infinity, alignment: .leading) @@ -71,10 +71,10 @@ public struct CommunityModal: View { } let links = [ - (title: "Tweet about Omnivore", url: tweetUrl), - (title: "Follow us on Twitter", url: "https://twitter.com/omnivoreapp"), - (title: "Join us on Discord", url: "https://discord.gg/h2z5rppzz9"), - (title: "Star on GitHub", url: "https://github.com/omnivore-app/omnivore") + (title: LocalText.communityTweet, url: tweetUrl), + (title: LocalText.communityFollowTwitter, url: "https://twitter.com/omnivoreapp"), + (title: LocalText.communityJoinDiscord, url: "https://discord.gg/h2z5rppzz9"), + (title: LocalText.communityStarGithub, url: "https://github.com/omnivore-app/omnivore") ] var buttonLinks: some View { @@ -83,7 +83,7 @@ public struct CommunityModal: View { if let scene = UIApplication.shared.connectedScenes.first(where: { $0.activationState == .foregroundActive }) as? UIWindowScene { SKStoreReviewController.requestReview(in: scene) } - }, label: { Text("Review on the AppStore") }) + }, label: { Text(LocalText.communityAppstoreReview) }) .frame(maxWidth: .infinity, alignment: .leading) ForEach(links, id: \.url) { link in diff --git a/apple/OmnivoreKit/Sources/Views/PushNotifications/PushNotificationPrimerView.swift b/apple/OmnivoreKit/Sources/Views/PushNotifications/PushNotificationPrimerView.swift index 6d2f80366..ee2799437 100644 --- a/apple/OmnivoreKit/Sources/Views/PushNotifications/PushNotificationPrimerView.swift +++ b/apple/OmnivoreKit/Sources/Views/PushNotifications/PushNotificationPrimerView.swift @@ -21,12 +21,12 @@ import SwiftUI .smallOmnivoreLogo .resizable() .frame(width: 30, height: 30) - Text("Enable Push Notifications?") + Text(LocalText.notificationsEnable) .font(.appHeadline) } // swiftlint:disable:next line_length - Text("Get notified when newsletter links reach your inbox. Or receive reminders that you set from our share extension.") + Text(LocalText.notificationsGeneralExplainer) .font(.appBody) .multilineTextAlignment(.leading) .lineLimit(nil) @@ -35,8 +35,8 @@ import SwiftUI HStack { Spacer() - Button(action: denyAction, label: { Text("No Thanks") }) - Button(action: acceptAction, label: { Text("Yes Please") }) + Button(action: denyAction, label: { Text(LocalText.notificationsOptionDeny) }) + Button(action: acceptAction, label: { Text(LocalText.notificationsOptionEnable) }) } .buttonStyle(BorderedButtonStyle(color: .appTextDefault)) }