chore: use i18n strings for report flow

This commit is contained in:
CMK 2022-05-11 21:10:10 +08:00
parent 11762100eb
commit 70a6e11d30
12 changed files with 38 additions and 37 deletions

View File

@ -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
}()

View File

@ -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),
]

View File

@ -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 = "Whats 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 = "Whats wrong with @\(username)?"
reportReasonViewModel.headline = L10n.Scene.Report.StepOne.whatsWrongWithThisUsername(username)
} else {
reportReasonViewModel.headline = "Whats wrong with this account?"
reportReasonViewModel.headline = L10n.Scene.Report.StepOne.whatsWrongWithThisAccount
}
} // end Task
}

View File

@ -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))
}

View File

@ -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 dont like it"
return L10n.Scene.Report.StepOne.iDontLikeIt
case .spam:
return "Its spam"
return L10n.Scene.Report.StepOne.itsSpam
case .violateRule:
return "It violates server rules"
return L10n.Scene.Report.StepOne.itViolatesServerRules
case .other:
return "Its 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
}
}

View File

@ -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 dont 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 wont see their posts or reblogs in your home feed. They wont know theyve 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 theyve 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(

View File

@ -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, well look into this." : "Dont 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

View File

@ -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 dont like it",
title: L10n.Scene.Report.StepTwo.iJustDonTLikeIt,
isSelect: viewModel.isDislike
)
.background(

View File

@ -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

View File

@ -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(

View File

@ -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(

View File

@ -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) {