Fix localization issues and export strings for translation
Changelog-Fixed: Fix localization issues and export strings for translation Signed-off-by: Terry Yiu <git@tyiu.xyz> Signed-off-by: William Casarin <jb55@jb55.com>
This commit is contained in:
@@ -26,7 +26,8 @@ struct EventDetailBar: View {
|
||||
HStack {
|
||||
if bar.boosts > 0 {
|
||||
NavigationLink(value: Route.Reposts(reposts: RepostsModel(state: state, target: target))) {
|
||||
let noun = Text(verbatim: repostsCountString(bar.boosts)).foregroundColor(.gray)
|
||||
let nounString = pluralizedString(key: "reposts_count", count: bar.boosts)
|
||||
let noun = Text(nounString).foregroundColor(.gray)
|
||||
Text("\(Text(verbatim: bar.boosts.formatted()).font(.body.bold())) \(noun)", 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())
|
||||
@@ -34,7 +35,8 @@ struct EventDetailBar: View {
|
||||
|
||||
if bar.likes > 0 && !state.settings.onlyzaps_mode {
|
||||
NavigationLink(value: Route.Reactions(reactions: ReactionsModel(state: state, target: target))) {
|
||||
let noun = Text(verbatim: reactionsCountString(bar.likes)).foregroundColor(.gray)
|
||||
let nounString = pluralizedString(key: "reactions_count", count: bar.likes)
|
||||
let noun = Text(nounString).foregroundColor(.gray)
|
||||
Text("\(Text(verbatim: bar.likes.formatted()).font(.body.bold())) \(noun)", 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())
|
||||
@@ -42,7 +44,8 @@ struct EventDetailBar: View {
|
||||
|
||||
if bar.zaps > 0 {
|
||||
NavigationLink(value: Route.Zaps(target: .note(id: target, author: target_pk))) {
|
||||
let noun = Text(verbatim: zapsCountString(bar.zaps)).foregroundColor(.gray)
|
||||
let nounString = pluralizedString(key: "zaps_count", count: bar.zaps)
|
||||
let noun = Text(nounString).foregroundColor(.gray)
|
||||
Text("\(Text(verbatim: bar.zaps.formatted()).font(.body.bold())) \(noun)", 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())
|
||||
@@ -51,21 +54,6 @@ struct EventDetailBar: View {
|
||||
}
|
||||
}
|
||||
|
||||
func repostsCountString(_ count: Int, locale: Locale = Locale.current) -> String {
|
||||
let format = localizedStringFormat(key: "reposts_count", locale: locale)
|
||||
return String(format: format, locale: locale, count)
|
||||
}
|
||||
|
||||
func reactionsCountString(_ count: Int, locale: Locale = Locale.current) -> String {
|
||||
let format = localizedStringFormat(key: "reactions_count", locale: locale)
|
||||
return String(format: format, locale: locale, count)
|
||||
}
|
||||
|
||||
func zapsCountString(_ count: Int, locale: Locale = Locale.current) -> String {
|
||||
let format = localizedStringFormat(key: "zaps_count", locale: locale)
|
||||
return String(format: format, locale: locale, count)
|
||||
}
|
||||
|
||||
struct EventDetailBar_Previews: PreviewProvider {
|
||||
static var previews: some View {
|
||||
EventDetailBar(state: test_damus_state(), target: "", target_pk: "")
|
||||
|
||||
@@ -9,7 +9,7 @@ import SwiftUI
|
||||
|
||||
struct ContextButton: View {
|
||||
var body: some View {
|
||||
Text(/*@START_MENU_TOKEN@*/"Hello, World!"/*@END_MENU_TOKEN@*/)
|
||||
Text(verbatim: /*@START_MENU_TOKEN@*/"Hello, World!"/*@END_MENU_TOKEN@*/)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -134,11 +134,11 @@ struct EventShell_Previews: PreviewProvider {
|
||||
static var previews: some View {
|
||||
VStack {
|
||||
EventShell(state: test_damus_state(), event: test_event, options: [.no_action_bar]) {
|
||||
Text("Hello")
|
||||
Text(verbatim: "Hello")
|
||||
}
|
||||
|
||||
EventShell(state: test_damus_state(), event: test_event, options: [.no_action_bar, .wide]) {
|
||||
Text("Hello")
|
||||
Text(verbatim: "Hello")
|
||||
}
|
||||
}
|
||||
.frame(height: 300)
|
||||
|
||||
@@ -30,7 +30,8 @@ struct LongformPreviewBody: View {
|
||||
}
|
||||
|
||||
func Words(_ words: Int) -> Text {
|
||||
Text(verbatim: words.description) + Text(verbatim: " ") + Text("Words")
|
||||
let wordCount = pluralizedString(key: "word_count", count: words)
|
||||
return Text(wordCount)
|
||||
}
|
||||
|
||||
var body: some View {
|
||||
@@ -45,8 +46,13 @@ struct LongformPreviewBody: View {
|
||||
|
||||
var Main: some View {
|
||||
VStack(alignment: .leading, spacing: 10) {
|
||||
Text(event.title ?? "Untitled")
|
||||
.font(.title)
|
||||
if let title = event.title {
|
||||
Text(title)
|
||||
.font(.title)
|
||||
} else {
|
||||
Text("Untitled", comment: "Text indicating that the long-form note title is untitled.")
|
||||
.font(.title)
|
||||
}
|
||||
|
||||
Text(event.summary ?? "")
|
||||
.foregroundColor(.gray)
|
||||
|
||||
@@ -80,11 +80,6 @@ class ScriptModel: ObservableObject {
|
||||
}
|
||||
}
|
||||
|
||||
func imports_string(_ count: Int, locale: Locale = Locale.current) -> String {
|
||||
let format = localizedStringFormat(key: "imports_count", locale: locale)
|
||||
return String(format: format, locale: locale, count)
|
||||
}
|
||||
|
||||
struct LoadScript: View {
|
||||
let pool: RelayPool
|
||||
|
||||
@@ -95,7 +90,8 @@ struct LoadScript: View {
|
||||
VStack {
|
||||
let imports = script.script.imports()
|
||||
|
||||
let nounText = Text(verbatim: imports_string(imports.count)).font(.title)
|
||||
let nounString = pluralizedString(key: "imports_count", count: imports.count)
|
||||
let nounText = Text(nounString).font(.title)
|
||||
Text("\(Text(verbatim: imports.count.formatted())) \(nounText)", comment: "Sentence composed of 2 variables to describe how many imports were performed from loading a NostrScript. In source English, the first variable is the number of imports, and the second variable is 'Import' or 'Imports'.")
|
||||
|
||||
ForEach(imports.indices, id: \.self) { ind in
|
||||
|
||||
@@ -203,7 +203,7 @@ struct NoteContentView: View {
|
||||
InvoiceView(our_pubkey: damus_state.pubkey, invoice: inv, settings: damus_state.settings)
|
||||
}
|
||||
case .media(let media):
|
||||
Text("media \(media.url.absoluteString)")
|
||||
Text(verbatim: "media \(media.url.absoluteString)")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,21 +31,6 @@ func follow_btn_txt(_ fs: FollowState, follows_you: Bool) -> String {
|
||||
}
|
||||
}
|
||||
|
||||
func followersCountString(_ count: Int, locale: Locale = Locale.current) -> String {
|
||||
let format = localizedStringFormat(key: "followers_count", locale: locale)
|
||||
return String(format: format, locale: locale, count)
|
||||
}
|
||||
|
||||
func followingCountString(_ count: Int, locale: Locale = Locale.current) -> String {
|
||||
let format = localizedStringFormat(key: "following_count", locale: locale)
|
||||
return String(format: format, locale: locale, count)
|
||||
}
|
||||
|
||||
func relaysCountString(_ count: Int, locale: Locale = Locale.current) -> String {
|
||||
let format = localizedStringFormat(key: "relays_count", locale: locale)
|
||||
return String(format: format, locale: locale, count)
|
||||
}
|
||||
|
||||
func followedByString(_ friend_intersection: [String], profiles: Profiles, locale: Locale = Locale.current) -> String {
|
||||
let bundle = bundleForLocale(locale: locale)
|
||||
let names: [String] = friend_intersection.prefix(3).map {
|
||||
@@ -379,8 +364,9 @@ struct ProfileView: View {
|
||||
.foregroundColor(.gray)
|
||||
} else {
|
||||
let followerCount = followers.count!
|
||||
let noun_text = Text(verbatim: followersCountString(followerCount)).font(.subheadline).foregroundColor(.gray)
|
||||
Text("\(Text(verbatim: followerCount.formatted()).font(.subheadline.weight(.medium))) \(noun_text)", 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'.")
|
||||
let nounString = pluralizedString(key: "followers_count", count: followerCount)
|
||||
let nounText = Text(verbatim: nounString).font(.subheadline).foregroundColor(.gray)
|
||||
Text("\(Text(verbatim: followerCount.formatted()).font(.subheadline.weight(.medium))) \(nounText)", 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'.")
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -405,7 +391,7 @@ struct ProfileView: View {
|
||||
let following_model = FollowingModel(damus_state: damus_state, contacts: contacts)
|
||||
NavigationLink(value: Route.Following(following: following_model)) {
|
||||
HStack {
|
||||
let noun_text = Text(verbatim: "\(followingCountString(profile.following))").font(.subheadline).foregroundColor(.gray)
|
||||
let noun_text = Text(verbatim: "\(pluralizedString(key: "following_count", count: profile.following))").font(.subheadline).foregroundColor(.gray)
|
||||
Text("\(Text(verbatim: profile.following.formatted()).font(.subheadline.weight(.medium))) \(noun_text)", 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'.")
|
||||
}
|
||||
}
|
||||
@@ -428,7 +414,8 @@ 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 noun_text = Text(verbatim: relaysCountString(relays.keys.count)).font(.subheadline).foregroundColor(.gray)
|
||||
let noun_string = pluralizedString(key: "relays_count", count: relays.keys.count)
|
||||
let noun_text = Text(noun_string).font(.subheadline).foregroundColor(.gray)
|
||||
let relay_text = Text("\(Text(verbatim: relays.keys.count.formatted()).font(.subheadline.weight(.medium))) \(noun_text)", 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(value: Route.RelayConfig) {
|
||||
|
||||
@@ -44,7 +44,7 @@ struct SearchView: View {
|
||||
}
|
||||
}
|
||||
|
||||
enum DescribedSearch {
|
||||
enum DescribedSearch: CustomStringConvertible {
|
||||
case hashtag(String)
|
||||
case unknown
|
||||
|
||||
|
||||
@@ -39,11 +39,6 @@ func get_zap_amount_items(_ default_zap_amt: Int) -> [ZapAmountItem] {
|
||||
return entries
|
||||
}
|
||||
|
||||
func satsString(_ count: Int, locale: Locale = Locale.current) -> String {
|
||||
let format = localizedStringFormat(key: "sats", locale: locale)
|
||||
return String(format: format, locale: locale, count)
|
||||
}
|
||||
|
||||
struct CustomizeZapView: View {
|
||||
let state: DamusState
|
||||
let target: ZapTarget
|
||||
@@ -138,7 +133,8 @@ struct CustomizeZapView: View {
|
||||
model.custom_amount_sats = nil
|
||||
}
|
||||
}
|
||||
Text(verbatim: satsString(model.custom_amount_sats ?? 0))
|
||||
let noun = pluralizedString(key: "sats", count: model.custom_amount_sats ?? 0)
|
||||
Text(noun)
|
||||
.font(.system(size: 18, weight: .heavy))
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user