From 98a1b95d1257212e5fc8c98c123f3d4458bbefb4 Mon Sep 17 00:00:00 2001 From: Terry Yiu <963907+tyiu@users.noreply.github.com> Date: Thu, 16 Feb 2023 10:15:38 -0500 Subject: [PATCH] Use Text(verbatim:) to indicate non-translatable strings --- damus/Views/ActionBar/EventActionBar.swift | 4 ++-- damus/Views/ActionBar/EventDetailBar.swift | 6 +++--- damus/Views/ChatView.swift | 4 ++-- damus/Views/ConfigView.swift | 4 ++-- damus/Views/CreateAccountView.swift | 4 ++-- damus/Views/EventDetailView.swift | 2 +- damus/Views/Events/ReplyDescription.swift | 2 +- damus/Views/Events/SelectedEventView.swift | 2 +- damus/Views/Events/TextEvent.swift | 2 +- damus/Views/MentionView.swift | 2 +- damus/Views/PowView.swift | 2 +- damus/Views/ProfileView.swift | 6 +++--- damus/Views/PubkeyView.swift | 2 +- damus/Views/Relays/Detail/RelayPaidDetail.swift | 2 +- 14 files changed, 22 insertions(+), 22 deletions(-) diff --git a/damus/Views/ActionBar/EventActionBar.swift b/damus/Views/ActionBar/EventActionBar.swift index 96700ad5..2d5a6647 100644 --- a/damus/Views/ActionBar/EventActionBar.swift +++ b/damus/Views/ActionBar/EventActionBar.swift @@ -61,7 +61,7 @@ struct EventActionBar: View { } } .accessibilityLabel(NSLocalizedString("Boosts", comment: "Accessibility label for boosts button")) - Text(String("\(bar.boosts > 0 ? "\(bar.boosts)" : "")")) + Text(verbatim: "\(bar.boosts > 0 ? "\(bar.boosts)" : "")") .offset(x: 18) .font(.footnote.weight(.medium)) .foregroundColor(bar.boosted ? Color.green : Color.gray) @@ -76,7 +76,7 @@ struct EventActionBar: View { send_like() } } - Text(String("\(bar.likes > 0 ? "\(bar.likes)" : "")")) + Text(verbatim: "\(bar.likes > 0 ? "\(bar.likes)" : "")") .offset(x: 22) .font(.footnote.weight(.medium)) .foregroundColor(bar.liked ? Color.accentColor : Color.gray) diff --git a/damus/Views/ActionBar/EventDetailBar.swift b/damus/Views/ActionBar/EventDetailBar.swift index 820c9819..062da0f0 100644 --- a/damus/Views/ActionBar/EventDetailBar.swift +++ b/damus/Views/ActionBar/EventDetailBar.swift @@ -26,14 +26,14 @@ struct EventDetailBar: View { HStack { if bar.boosts > 0 { NavigationLink(destination: RepostsView(damus_state: state, model: RepostsModel(state: state, target: target))) { - Text("\(Text(String("\(bar.boosts)")).font(.body.bold())) \(Text(String(format: NSLocalizedString("reposts_count", comment: "Part of a larger sentence to describe how many reposts there are."), bar.boosts)).foregroundColor(.gray))", comment: "Sentence composed of 2 variables to describe how many reposts. In source English, the first variable is the number of reposts, and the second variable is 'Repost' or 'Reposts'.") + Text("\(Text(verbatim: "\(bar.boosts)").font(.body.bold())) \(Text(String(format: NSLocalizedString("reposts_count", comment: "Part of a larger sentence to describe how many reposts there are."), bar.boosts)).foregroundColor(.gray))", comment: "Sentence composed of 2 variables to describe how many reposts. In source English, the first variable is the number of reposts, and the second variable is 'Repost' or 'Reposts'.") } .buttonStyle(PlainButtonStyle()) } if bar.likes > 0 { NavigationLink(destination: ReactionsView(damus_state: state, model: ReactionsModel(state: state, target: target))) { - Text("\(Text(String("\(bar.likes)")).font(.body.bold())) \(Text(String(format: NSLocalizedString("reactions_count", comment: "Part of a larger sentence to describe how many reactions there are on a post."), bar.likes)).foregroundColor(.gray))", comment: "Sentence composed of 2 variables to describe how many reactions there are on a post. In source English, the first variable is the number of reactions, and the second variable is 'Reaction' or 'Reactions'.") + Text("\(Text(verbatim: "\(bar.likes)").font(.body.bold())) \(Text(String(format: NSLocalizedString("reactions_count", comment: "Part of a larger sentence to describe how many reactions there are on a post."), bar.likes)).foregroundColor(.gray))", comment: "Sentence composed of 2 variables to describe how many reactions there are on a post. In source English, the first variable is the number of reactions, and the second variable is 'Reaction' or 'Reactions'.") } .buttonStyle(PlainButtonStyle()) } @@ -41,7 +41,7 @@ struct EventDetailBar: View { if bar.zaps > 0 { let dst = ZapsView(state: state, target: .note(id: target, author: target_pk)) NavigationLink(destination: dst) { - Text("\(Text(String("\(bar.zaps)")).font(.body.bold())) \(Text(String(format: NSLocalizedString("zaps_count", comment: "Part of a larger sentence to describe how many zap payments there are on a post."), bar.boosts)).foregroundColor(.gray))", comment: "Sentence composed of 2 variables to describe how many zap payments there are on a post. In source English, the first variable is the number of zap payments, and the second variable is 'Zap' or 'Zaps'.") + Text("\(Text(verbatim: "\(bar.zaps)").font(.body.bold())) \(Text(String(format: NSLocalizedString("zaps_count", comment: "Part of a larger sentence to describe how many zap payments there are on a post."), bar.boosts)).foregroundColor(.gray))", comment: "Sentence composed of 2 variables to describe how many zap payments there are on a post. In source English, the first variable is the number of zap payments, and the second variable is 'Zap' or 'Zaps'.") } .buttonStyle(PlainButtonStyle()) } diff --git a/damus/Views/ChatView.swift b/damus/Views/ChatView.swift index 8b519984..f1580a76 100644 --- a/damus/Views/ChatView.swift +++ b/damus/Views/ChatView.swift @@ -63,7 +63,7 @@ struct ChatView: View { } var ReplyDescription: some View { - Text(String("\(reply_desc(profiles: damus_state.profiles, event: event))")) + Text(verbatim: "\(reply_desc(profiles: damus_state.profiles, event: event))") .font(.footnote) .foregroundColor(.gray) .frame(alignment: .leading) @@ -89,7 +89,7 @@ struct ChatView: View { ProfileName(pubkey: event.pubkey, profile: damus_state.profiles.lookup(id: event.pubkey), damus: damus_state, show_friend_confirmed: true) .foregroundColor(colorScheme == .dark ? id_to_color(event.pubkey) : Color.black) //.shadow(color: Color.black, radius: 2) - Text(String("\(format_relative_time(event.created_at))")) + Text(verbatim: "\(format_relative_time(event.created_at))") .foregroundColor(.gray) } } diff --git a/damus/Views/ConfigView.swift b/damus/Views/ConfigView.swift index 497137b9..f2adb061 100644 --- a/damus/Views/ConfigView.swift +++ b/damus/Views/ConfigView.swift @@ -131,7 +131,7 @@ struct ConfigView: View { Section(NSLocalizedString("Default Zap Amount in sats", comment: "Section title for zap configuration")) { - TextField("1000", text: $default_zap_amount) + TextField(String("1000"), text: $default_zap_amount) .keyboardType(.numberPad) .onReceive(Just(default_zap_amount)) { newValue in let filtered = newValue.filter { Set("0123456789").contains($0) } @@ -223,7 +223,7 @@ struct ConfigView: View { let bundleShortVersion = Bundle.main.infoDictionary?["CFBundleShortVersionString"] as! String let bundleVersion = Bundle.main.infoDictionary?["CFBundleVersion"] as! String Section(NSLocalizedString("Version", comment: "Section title for displaying the version number of the Damus app.")) { - Text(String("\(bundleShortVersion) (\(bundleVersion))")) + Text(verbatim: "\(bundleShortVersion) (\(bundleVersion))") } } } diff --git a/damus/Views/CreateAccountView.swift b/damus/Views/CreateAccountView.swift index 3505ad8c..3be10a38 100644 --- a/damus/Views/CreateAccountView.swift +++ b/damus/Views/CreateAccountView.swift @@ -36,14 +36,14 @@ struct CreateAccountView: View { HStack(alignment: .top) { VStack { - Text(String(" ")) + Text(verbatim: " ") .foregroundColor(.white) } VStack { SignupForm { FormLabel(NSLocalizedString("Username", comment: "Label to prompt username entry.")) HStack(spacing: 0.0) { - Text(String("@")) + Text(verbatim: "@") .foregroundColor(.white) .padding(.leading, -25.0) diff --git a/damus/Views/EventDetailView.swift b/damus/Views/EventDetailView.swift index 9960e487..d4e3ed12 100644 --- a/damus/Views/EventDetailView.swift +++ b/damus/Views/EventDetailView.swift @@ -10,7 +10,7 @@ import SwiftUI struct EventDetailView: View { var body: some View { - Text(String("EventDetailView")) + Text(verbatim: "EventDetailView") } } diff --git a/damus/Views/Events/ReplyDescription.swift b/damus/Views/Events/ReplyDescription.swift index 70d8b3ba..db618b94 100644 --- a/damus/Views/Events/ReplyDescription.swift +++ b/damus/Views/Events/ReplyDescription.swift @@ -13,7 +13,7 @@ struct ReplyDescription: View { let profiles: Profiles var body: some View { - Text(String("\(reply_desc(profiles: profiles, event: event))")) + Text(verbatim: "\(reply_desc(profiles: profiles, event: event))") .font(.footnote) .foregroundColor(.gray) .frame(maxWidth: .infinity, alignment: .leading) diff --git a/damus/Views/Events/SelectedEventView.swift b/damus/Views/Events/SelectedEventView.swift index 242a63d8..ad85d104 100644 --- a/damus/Views/Events/SelectedEventView.swift +++ b/damus/Views/Events/SelectedEventView.swift @@ -35,7 +35,7 @@ struct SelectedEventView: View { BuilderEventView(damus: damus, event_id: mention.ref.id) } - Text(String("\(format_date(event.created_at))")) + Text(verbatim: "\(format_date(event.created_at))") .padding(.top, 10) .font(.footnote) .foregroundColor(.gray) diff --git a/damus/Views/Events/TextEvent.swift b/damus/Views/Events/TextEvent.swift index 14046097..2c6889f6 100644 --- a/damus/Views/Events/TextEvent.swift +++ b/damus/Views/Events/TextEvent.swift @@ -33,7 +33,7 @@ struct TextEvent: View { HStack(alignment: .center) { EventProfileName(pubkey: pubkey, profile: profile, damus: damus, show_friend_confirmed: true, size: .normal) - Text(String("\(format_relative_time(event.created_at))")) + Text(verbatim: "\(format_relative_time(event.created_at))") .foregroundColor(.gray) Spacer() diff --git a/damus/Views/MentionView.swift b/damus/Views/MentionView.swift index e8e8fc50..8d043f28 100644 --- a/damus/Views/MentionView.swift +++ b/damus/Views/MentionView.swift @@ -17,7 +17,7 @@ struct MentionView: View { let pk = bech32_pubkey(mention.ref.ref_id) ?? mention.ref.ref_id PubkeyView(pubkey: pk, relay: mention.ref.relay_id) case .event: - Text(String("< e >")) + Text(verbatim: "< e >") //EventBlockView(pubkey: mention.ref.ref_id, relay: mention.ref.relay_id) } } diff --git a/damus/Views/PowView.swift b/damus/Views/PowView.swift index 2f56c7b9..549444ca 100644 --- a/damus/Views/PowView.swift +++ b/damus/Views/PowView.swift @@ -11,7 +11,7 @@ import SwiftUI func PowView(_ mpow: Int?) -> some View { let pow = mpow ?? 0 - return Text(String("\(pow)")) + return Text(verbatim: "\(pow)") .font(.callout) .foregroundColor(calculate_pow_color(pow)) } diff --git a/damus/Views/ProfileView.swift b/damus/Views/ProfileView.swift index 1be8b605..f0d4d547 100644 --- a/damus/Views/ProfileView.swift +++ b/damus/Views/ProfileView.swift @@ -318,7 +318,7 @@ struct ProfileView: View { .foregroundColor(.gray) } else { let followerCount = followers.count! - Text("\(Text(String("\(followerCount)")).font(.subheadline.weight(.medium))) \(Text(String(format: NSLocalizedString("followers_count", comment: "Part of a larger sentence to describe how many people are following a user."), followerCount)).font(.subheadline).foregroundColor(.gray))", comment: "Sentence composed of 2 variables to describe how many people are following a user. In source English, the first variable is the number of followers, and the second variable is 'Follower' or 'Followers'.") + Text("\(Text(verbatim: "\(followerCount)").font(.subheadline.weight(.medium))) \(Text(String(format: NSLocalizedString("followers_count", comment: "Part of a larger sentence to describe how many people are following a user."), followerCount)).font(.subheadline).foregroundColor(.gray))", comment: "Sentence composed of 2 variables to describe how many people are following a user. In source English, the first variable is the number of followers, and the second variable is 'Follower' or 'Followers'.") } } } @@ -344,7 +344,7 @@ struct ProfileView: View { let following_model = FollowingModel(damus_state: damus_state, contacts: contacts) NavigationLink(destination: FollowingView(damus_state: damus_state, following: following_model, whos: profile.pubkey)) { HStack { - Text("\(Text("\(profile.following)", comment: "Number of profiles a user is following.").font(.subheadline.weight(.medium))) \(Text("Following", comment: "Part of a larger sentence to describe how many profiles a user is following.").font(.subheadline).foregroundColor(.gray))", comment: "Sentence composed of 2 variables to describe how many profiles a user is following. In source English, the first variable is the number of profiles being followed, and the second variable is 'Following'.") + Text("\(Text(verbatim: "\(profile.following)").font(.subheadline.weight(.medium))) \(Text("Following", comment: "Part of a larger sentence to describe how many profiles a user is following.").font(.subheadline).foregroundColor(.gray))", comment: "Sentence composed of 2 variables to describe how many profiles a user is following. In source English, the first variable is the number of profiles being followed, and the second variable is 'Following'.") } } .buttonStyle(PlainButtonStyle()) @@ -367,7 +367,7 @@ struct ProfileView: View { if let relays = profile.relays { // Only open relay config view if the user is logged in with private key and they are looking at their own profile. - let relay_text = Text("\(Text("\(relays.keys.count)", comment: "Number of relay servers a user is connected.").font(.subheadline.weight(.medium))) \(Text(String(format: NSLocalizedString("relays_count", comment: "Part of a larger sentence to describe how many relay servers a user is connected."), relays.keys.count)).font(.subheadline).foregroundColor(.gray))", comment: "Sentence composed of 2 variables to describe how many relay servers a user is connected. In source English, the first variable is the number of relay servers, and the second variable is 'Relay' or 'Relays'.") + let relay_text = Text("\(Text(verbatim: "\(relays.keys.count)").font(.subheadline.weight(.medium))) \(Text(String(format: NSLocalizedString("relays_count", comment: "Part of a larger sentence to describe how many relay servers a user is connected."), relays.keys.count)).font(.subheadline).foregroundColor(.gray))", comment: "Sentence composed of 2 variables to describe how many relay servers a user is connected. In source English, the first variable is the number of relay servers, and the second variable is 'Relay' or 'Relays'.") if profile.pubkey == damus_state.pubkey && damus_state.is_privkey_user { NavigationLink(destination: RelayConfigView(state: damus_state)) { relay_text diff --git a/damus/Views/PubkeyView.swift b/damus/Views/PubkeyView.swift index beb835db..7b333b29 100644 --- a/damus/Views/PubkeyView.swift +++ b/damus/Views/PubkeyView.swift @@ -14,7 +14,7 @@ struct PubkeyView: View { var body: some View { let color: Color = id_to_color(pubkey) ZStack { - Text(String("\(abbrev_pubkey(pubkey))")) + Text(verbatim: "\(abbrev_pubkey(pubkey))") .foregroundColor(color) } } diff --git a/damus/Views/Relays/Detail/RelayPaidDetail.swift b/damus/Views/Relays/Detail/RelayPaidDetail.swift index 53f57517..041b4c8a 100644 --- a/damus/Views/Relays/Detail/RelayPaidDetail.swift +++ b/damus/Views/Relays/Detail/RelayPaidDetail.swift @@ -19,7 +19,7 @@ struct RelayPaidDetail: View { Button(action: { openURL(url) }, label: { - Text(String("\(url)")) + Text(verbatim: "\(url)") }) } }