From 70a6e11d30a8dedf442d48b5a593b57dd9766e07 Mon Sep 17 00:00:00 2001 From: CMK Date: Wed, 11 May 2022 21:10:10 +0800 Subject: [PATCH] chore: use i18n strings for report flow --- .../View/DiscoveryIntroBannerView.swift | 3 ++- .../Paging/ProfilePagingViewModel.swift | 2 +- .../Scene/Report/Report/ReportViewModel.swift | 8 ++++---- .../ReportReason/ReportReasonView.swift | 5 ++--- .../ReportReason/ReportReasonViewModel.swift | 19 ++++++++++--------- .../ReportResult/ReportResultView.swift | 15 +++++++-------- .../ReportResult/ReportResultViewModel.swift | 3 ++- .../ReportServerRulesView.swift | 7 +++---- .../ReportServerRulesViewModel.swift | 5 +++-- .../ReportStatusViewModel+Diffable.swift | 2 +- ...eportSupplementaryViewModel+Diffable.swift | 4 ++-- .../View/Control/ActionToolbarContainer.swift | 2 +- 12 files changed, 38 insertions(+), 37 deletions(-) diff --git a/Mastodon/Scene/Discovery/View/DiscoveryIntroBannerView.swift b/Mastodon/Scene/Discovery/View/DiscoveryIntroBannerView.swift index e3e1c454..afc2cb7d 100644 --- a/Mastodon/Scene/Discovery/View/DiscoveryIntroBannerView.swift +++ b/Mastodon/Scene/Discovery/View/DiscoveryIntroBannerView.swift @@ -9,6 +9,7 @@ import os.log import UIKit import Combine import MastodonAsset +import MastodonLocalization public protocol DiscoveryIntroBannerViewDelegate: AnyObject { func discoveryIntroBannerView(_ bannerView: DiscoveryIntroBannerView, closeButtonDidPressed button: UIButton) @@ -26,7 +27,7 @@ public final class DiscoveryIntroBannerView: UIView { let label = UILabel() label.font = UIFontMetrics(forTextStyle: .headline).scaledFont(for: .systemFont(ofSize: 16, weight: .regular)) label.textColor = Asset.Colors.Label.primary.color - label.text = "These are the posts gaining traction in your corner of Mastodon." // TODO: i18n + label.text = L10n.Scene.Discovery.intro label.numberOfLines = 0 return label }() diff --git a/Mastodon/Scene/Profile/Segmented/Paging/ProfilePagingViewModel.swift b/Mastodon/Scene/Profile/Segmented/Paging/ProfilePagingViewModel.swift index e5220ef7..67a0ca93 100644 --- a/Mastodon/Scene/Profile/Segmented/Paging/ProfilePagingViewModel.swift +++ b/Mastodon/Scene/Profile/Segmented/Paging/ProfilePagingViewModel.swift @@ -44,7 +44,7 @@ final class ProfilePagingViewModel: NSObject { let barItems: [TMBarItemable] = { let items = [ TMBarItem(title: L10n.Scene.Profile.SegmentedControl.posts), - TMBarItem(title: L10n.Scene.Profile.SegmentedControl.postsAndReplies), // TODO: i18n + TMBarItem(title: L10n.Scene.Profile.SegmentedControl.postsAndReplies), TMBarItem(title: L10n.Scene.Profile.SegmentedControl.media), TMBarItem(title: L10n.Scene.Profile.SegmentedControl.about), ] diff --git a/Mastodon/Scene/Report/Report/ReportViewModel.swift b/Mastodon/Scene/Report/Report/ReportViewModel.swift index 590aed87..f94a92d3 100644 --- a/Mastodon/Scene/Report/Report/ReportViewModel.swift +++ b/Mastodon/Scene/Report/Report/ReportViewModel.swift @@ -14,6 +14,7 @@ import MastodonSDK import OrderedCollections import os.log import UIKit +import MastodonLocalization class ReportViewModel { @@ -53,8 +54,7 @@ class ReportViewModel { // setup reason viewModel if status != nil { - // TODO: i18n - reportReasonViewModel.headline = "What’s wrong with post?" + reportReasonViewModel.headline = L10n.Scene.Report.StepOne.whatsWrongWithThisPost } else { Task { @MainActor in let managedObjectContext = context.managedObjectContext @@ -63,9 +63,9 @@ class ReportViewModel { return user?.acctWithDomain } if let username = _username { - reportReasonViewModel.headline = "What’s wrong with @\(username)?" + reportReasonViewModel.headline = L10n.Scene.Report.StepOne.whatsWrongWithThisUsername(username) } else { - reportReasonViewModel.headline = "What’s wrong with this account?" + reportReasonViewModel.headline = L10n.Scene.Report.StepOne.whatsWrongWithThisAccount } } // end Task } diff --git a/Mastodon/Scene/Report/ReportReason/ReportReasonView.swift b/Mastodon/Scene/Report/ReportReason/ReportReasonView.swift index 3a8b4579..67e94872 100644 --- a/Mastodon/Scene/Report/ReportReason/ReportReasonView.swift +++ b/Mastodon/Scene/Report/ReportReason/ReportReasonView.swift @@ -15,18 +15,17 @@ struct ReportReasonView: View { @ObservedObject var viewModel: ReportReasonViewModel - // TODO: i18n var body: some View { ScrollView(.vertical) { HStack { VStack(alignment: .leading, spacing: 8) { - Text("Step 1 of 4") + Text(L10n.Scene.Report.StepOne.step1Of4) .foregroundColor(Color(Asset.Colors.Label.secondary.color)) .font(Font(UIFontMetrics(forTextStyle: .largeTitle).scaledFont(for: .systemFont(ofSize: 17, weight: .regular)) as CTFont)) Text(viewModel.headline) .foregroundColor(Color(Asset.Colors.Label.primary.color)) .font(Font(UIFontMetrics(forTextStyle: .largeTitle).scaledFont(for: .systemFont(ofSize: 28, weight: .bold)) as CTFont)) - Text("Select the best match") + Text(L10n.Scene.Report.StepOne.selectTheBestMatch) .foregroundColor(Color(Asset.Colors.Label.secondary.color)) .font(Font(UIFontMetrics(forTextStyle: .largeTitle).scaledFont(for: .systemFont(ofSize: 17, weight: .regular)) as CTFont)) } diff --git a/Mastodon/Scene/Report/ReportReason/ReportReasonViewModel.swift b/Mastodon/Scene/Report/ReportReason/ReportReasonViewModel.swift index b156ea31..91715cba 100644 --- a/Mastodon/Scene/Report/ReportReason/ReportReasonViewModel.swift +++ b/Mastodon/Scene/Report/ReportReason/ReportReasonViewModel.swift @@ -9,6 +9,7 @@ import UIKit import SwiftUI import MastodonAsset import MastodonSDK +import MastodonLocalization final class ReportReasonViewModel: ObservableObject { @@ -17,7 +18,7 @@ final class ReportReasonViewModel: ObservableObject { // input let context: AppContext - @Published var headline = "What's wrong with this account?" + @Published var headline = L10n.Scene.Report.StepOne.whatsWrongWithThisAccount @Published var serverRules: [Mastodon.Entity.Instance.Rule]? @Published var bottomPaddingHeight: CGFloat = .zero @@ -43,26 +44,26 @@ extension ReportReasonViewModel { var title: String { switch self { case .dislike: - return "I don’t like it" + return L10n.Scene.Report.StepOne.iDontLikeIt case .spam: - return "It’s spam" + return L10n.Scene.Report.StepOne.itsSpam case .violateRule: - return "It violates server rules" + return L10n.Scene.Report.StepOne.itViolatesServerRules case .other: - return "It’s something else" + return L10n.Scene.Report.StepOne.itsSomethingElse } } var subtitle: String { switch self { case .dislike: - return "It is not something you want to see" + return L10n.Scene.Report.StepOne.itIsNotSomethingYouWantToSee case .spam: - return "Malicious links, fake engagement, or repetetive replies" + return L10n.Scene.Report.StepOne.maliciousLinksFakeEngagementOrRepetetiveReplies case .violateRule: - return "You are aware that it breaks specific rules" + return L10n.Scene.Report.StepOne.youAreAwareThatItBreaksSpecificRules case .other: - return "The issue does not fit into other categories" + return L10n.Scene.Report.StepOne.theIssueDoesNotFitIntoOtherCategories } } diff --git a/Mastodon/Scene/Report/ReportResult/ReportResultView.swift b/Mastodon/Scene/Report/ReportResult/ReportResultView.swift index dff87e35..7931538f 100644 --- a/Mastodon/Scene/Report/ReportResult/ReportResultView.swift +++ b/Mastodon/Scene/Report/ReportResult/ReportResultView.swift @@ -7,10 +7,10 @@ import UIKit import SwiftUI -import MastodonLocalization import MastodonSDK import MastodonUI import MastodonAsset +import MastodonLocalization import CoreDataStack struct ReportResultView: View { @@ -42,7 +42,6 @@ struct ReportResultView: View { .padding() } - // TODO: i18n var body: some View { ScrollView(.vertical) { HStack { @@ -56,7 +55,7 @@ struct ReportResultView: View { .foregroundColor(Color(Asset.Colors.Label.secondary.color)) .font(Font(UIFontMetrics(forTextStyle: .largeTitle).scaledFont(for: .systemFont(ofSize: 17, weight: .regular)) as CTFont)) } else { - Text(verbatim: "When you see something you don’t like on Mastodon, you can remove the person from your experience.") + Text(verbatim: L10n.Scene.Report.StepFinal.whenYouSeeSomethingYouDontLikeOnMastodonYouCanRemoveThePersonFromYourExperience) .foregroundColor(Color(Asset.Colors.Label.secondary.color)) .font(Font(UIFontMetrics(forTextStyle: .largeTitle).scaledFont(for: .systemFont(ofSize: 17, weight: .regular)) as CTFont)) } @@ -68,7 +67,7 @@ struct ReportResultView: View { VStack(spacing: 32) { // Follow VStack(alignment: .leading, spacing: 4) { - Text("Unfollow @\(viewModel.username)") + Text(L10n.Scene.Report.StepFinal.unfollowUser("@\(viewModel.username)")) .font(.headline) .foregroundColor(Color(Asset.Colors.Label.primary.color)) ReportActionButton( @@ -82,10 +81,10 @@ struct ReportResultView: View { // Mute VStack(alignment: .leading, spacing: 4) { - Text("Mute @\(viewModel.username)") + Text(L10n.Scene.Report.StepFinal.muteUser("@\(viewModel.username)")) .font(.headline) .foregroundColor(Color(Asset.Colors.Label.primary.color)) - Text(verbatim: "You won’t see their posts or reblogs in your home feed. They won’t know they’ve been muted.") + Text(verbatim: L10n.Scene.Report.StepFinal.youWontSeeTheirPostsOrReblogsInYourHomeFeedTheyWontKnowTheyVeBeenMuted) .foregroundColor(Color(Asset.Colors.Label.secondary.color)) .font(Font(UIFontMetrics(forTextStyle: .subheadline).scaledFont(for: .systemFont(ofSize: 13, weight: .regular)) as CTFont)) ReportActionButton( @@ -99,10 +98,10 @@ struct ReportResultView: View { // Block VStack(alignment: .leading, spacing: 4) { - Text("Block @\(viewModel.username)") + Text(L10n.Scene.Report.StepFinal.blockUser("@\(viewModel.username)")) .font(.headline) .foregroundColor(Color(Asset.Colors.Label.primary.color)) - Text(verbatim: "They will no longer be able to follow or see your posts, but they can see if they’ve been blocked.") + Text(verbatim: L10n.Scene.Report.StepFinal.theyWillNoLongerBeAbleToFollowOrSeeYourPostsButTheyCanSeeIfTheyveBeenBlocked) .foregroundColor(Color(Asset.Colors.Label.secondary.color)) .font(Font(UIFontMetrics(forTextStyle: .subheadline).scaledFont(for: .systemFont(ofSize: 13, weight: .regular)) as CTFont)) ReportActionButton( diff --git a/Mastodon/Scene/Report/ReportResult/ReportResultViewModel.swift b/Mastodon/Scene/Report/ReportResult/ReportResultViewModel.swift index ea949a90..67d7475d 100644 --- a/Mastodon/Scene/Report/ReportResult/ReportResultViewModel.swift +++ b/Mastodon/Scene/Report/ReportResult/ReportResultViewModel.swift @@ -14,6 +14,7 @@ import os.log import UIKit import MastodonAsset import MastodonUI +import MastodonLocalization class ReportResultViewModel: ObservableObject { @@ -25,7 +26,7 @@ class ReportResultViewModel: ObservableObject { let isReported: Bool var headline: String { - isReported ? "Thanks for reporting, we’ll look into this." : "Don’t want to see this?" + isReported ? L10n.Scene.Report.reportSentTitle : L10n.Scene.Report.StepFinal.dontWantToSeeThis } @Published var bottomPaddingHeight: CGFloat = .zero @Published var backgroundColor: UIColor = Asset.Scene.Report.background.color diff --git a/Mastodon/Scene/Report/ReportServerRules/ReportServerRulesView.swift b/Mastodon/Scene/Report/ReportServerRules/ReportServerRulesView.swift index e8dcfa88..57406402 100644 --- a/Mastodon/Scene/Report/ReportServerRules/ReportServerRulesView.swift +++ b/Mastodon/Scene/Report/ReportServerRules/ReportServerRulesView.swift @@ -15,18 +15,17 @@ struct ReportServerRulesView: View { @ObservedObject var viewModel: ReportServerRulesViewModel - // TODO: i18n var body: some View { ScrollView(.vertical) { HStack { VStack(alignment: .leading, spacing: 8) { - Text("Step 2 of 4") + Text(L10n.Scene.Report.StepTwo.step2Of4) .foregroundColor(Color(Asset.Colors.Label.secondary.color)) .font(Font(UIFontMetrics(forTextStyle: .largeTitle).scaledFont(for: .systemFont(ofSize: 17, weight: .regular)) as CTFont)) Text(viewModel.headline) .foregroundColor(Color(Asset.Colors.Label.primary.color)) .font(Font(UIFontMetrics(forTextStyle: .largeTitle).scaledFont(for: .systemFont(ofSize: 28, weight: .bold)) as CTFont)) - Text("Select all that apply") + Text(L10n.Scene.Report.StepTwo.selectAllThatApply) .foregroundColor(Color(Asset.Colors.Label.secondary.color)) .font(Font(UIFontMetrics(forTextStyle: .largeTitle).scaledFont(for: .systemFont(ofSize: 17, weight: .regular)) as CTFont)) } @@ -49,7 +48,7 @@ struct ReportServerRulesView: View { } } ReportServerRulesRowView( - title: "I just don’t like it", + title: L10n.Scene.Report.StepTwo.iJustDonTLikeIt, isSelect: viewModel.isDislike ) .background( diff --git a/Mastodon/Scene/Report/ReportServerRules/ReportServerRulesViewModel.swift b/Mastodon/Scene/Report/ReportServerRules/ReportServerRulesViewModel.swift index 1960899a..e0e21f30 100644 --- a/Mastodon/Scene/Report/ReportServerRules/ReportServerRulesViewModel.swift +++ b/Mastodon/Scene/Report/ReportServerRules/ReportServerRulesViewModel.swift @@ -9,6 +9,7 @@ import UIKit import SwiftUI import MastodonAsset import MastodonSDK +import MastodonLocalization final class ReportServerRulesViewModel: ObservableObject { @@ -16,8 +17,8 @@ final class ReportServerRulesViewModel: ObservableObject { // input let context: AppContext - - @Published var headline = "Which rules are being violated?" + + @Published var headline = L10n.Scene.Report.StepTwo.whichRulesAreBeingViolated @Published var serverRules: [Mastodon.Entity.Instance.Rule] = [] @Published var bottomPaddingHeight: CGFloat = .zero diff --git a/Mastodon/Scene/Report/ReportStatus/ReportStatusViewModel+Diffable.swift b/Mastodon/Scene/Report/ReportStatus/ReportStatusViewModel+Diffable.swift index 5bcc2f3d..4610a38d 100644 --- a/Mastodon/Scene/Report/ReportStatus/ReportStatusViewModel+Diffable.swift +++ b/Mastodon/Scene/Report/ReportStatus/ReportStatusViewModel+Diffable.swift @@ -16,7 +16,7 @@ extension ReportStatusViewModel { static let reportItemHeaderContext = ReportItem.HeaderContext( primaryLabelText: L10n.Scene.Report.content1, - secondaryLabelText: "Step 3 of 4" + secondaryLabelText: L10n.Scene.Report.StepThree.step3Of4 ) func setupDiffableDataSource( diff --git a/Mastodon/Scene/Report/ReportSupplementary/ReportSupplementaryViewModel+Diffable.swift b/Mastodon/Scene/Report/ReportSupplementary/ReportSupplementaryViewModel+Diffable.swift index e59617c3..8cbc1624 100644 --- a/Mastodon/Scene/Report/ReportSupplementary/ReportSupplementaryViewModel+Diffable.swift +++ b/Mastodon/Scene/Report/ReportSupplementary/ReportSupplementaryViewModel+Diffable.swift @@ -15,8 +15,8 @@ import MastodonLocalization extension ReportSupplementaryViewModel { static let reportItemHeaderContext = ReportItem.HeaderContext( - primaryLabelText: "Is there anything else we should know?", - secondaryLabelText: "Step 4 of 4" + primaryLabelText: L10n.Scene.Report.StepFour.isThereAnythingElseWeShouldKnow, + secondaryLabelText: L10n.Scene.Report.StepFour.step4Of4 ) func setupDiffableDataSource( diff --git a/MastodonSDK/Sources/MastodonUI/View/Control/ActionToolbarContainer.swift b/MastodonSDK/Sources/MastodonUI/View/Control/ActionToolbarContainer.swift index c3a9b96f..4a5c4485 100644 --- a/MastodonSDK/Sources/MastodonUI/View/Control/ActionToolbarContainer.swift +++ b/MastodonSDK/Sources/MastodonUI/View/Control/ActionToolbarContainer.swift @@ -216,7 +216,7 @@ extension ActionToolbarContainer { public func configureReply(count: Int, isEnabled: Bool) { let title = ActionToolbarContainer.title(from: count) replyButton.setTitle(title, for: .normal) - replyButton.accessibilityLabel = "\(count) reply" // TODO: i18n + replyButton.accessibilityLabel = L10n.Plural.Count.reply(count) } public func configureReblog(count: Int, isEnabled: Bool, isHighlighted: Bool) {