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:
2023-09-24 14:08:18 -04:00
committed by William Casarin
parent 9f15688699
commit eb901a4d84
11 changed files with 253 additions and 76 deletions

View File

@@ -7,30 +7,49 @@
import SwiftUI
enum StatusDuration: String, CaseIterable {
case never = "Never"
case thirty_mins = "30 Minutes"
case hour = "1 Hour"
case four_hours = "4 Hours"
case day = "1 Day"
case week = "1 Week"
enum StatusDuration: CustomStringConvertible, CaseIterable {
case never
case thirty_mins
case hour
case four_hours
case day
case week
var expiration: Date? {
var timeInterval: TimeInterval? {
switch self {
case .never:
return nil
case .thirty_mins:
return Date.now.addingTimeInterval(60 * 30)
return 60 * 30
case .hour:
return Date.now.addingTimeInterval(60 * 60)
return 60 * 60
case .four_hours:
return Date.now.addingTimeInterval(60 * 60 * 4)
return 60 * 60 * 4
case .day:
return Date.now.addingTimeInterval(60 * 60 * 24)
return 60 * 60 * 24
case .week:
return Date.now.addingTimeInterval(60 * 60 * 24 * 7)
return 60 * 60 * 24 * 7
}
}
var expiration: Date? {
guard let timeInterval else {
return nil
}
return Date.now.addingTimeInterval(timeInterval)
}
var description: String {
guard let timeInterval else {
return NSLocalizedString("Never", comment: "Profile status duration setting of never expiring.")
}
let formatter = DateComponentsFormatter()
formatter.unitsStyle = .full
formatter.allowedUnits = [.minute, .hour, .day, .weekOfMonth]
return formatter.string(from: timeInterval) ?? "\(timeInterval) seconds"
}
}
struct UserStatusSheet: View {
@@ -68,43 +87,43 @@ struct UserStatusSheet: View {
var body: some View {
VStack(alignment: .leading, spacing: 20) {
Text("Set Status")
Text("Set Status", comment: "Title of view that allows the user to set their profile status (e.g. working, studying, coding)")
.font(.largeTitle)
TextField(text: status_binding, label: {
Text("📋 Working")
Text("📋 Working", comment: "Placeholder as an example of what the user could set as their profile status.")
})
HStack {
Image("link")
TextField(text: url_binding, label: {
Text("https://example.com")
Text("https://example.com", comment: "Placeholder as an example of what the user could set so that the link is opened when the status is tapped.")
})
}
HStack {
Text("Clear status")
Text("Clear status", comment: "Label to prompt user to select an expiration time for the profile status to clear.")
Spacer()
Picker("Duration", selection: $duration) {
Picker(NSLocalizedString("Duration", comment: "Label for profile status expiration duration picker."), selection: $duration) {
ForEach(StatusDuration.allCases, id: \.self) { d in
Text("\(d.rawValue)")
Text(verbatim: d.description)
.tag(d)
}
}
}
Toggle(isOn: $status.playing_enabled, label: {
Text("Broadcast music playing on Apple Music")
Text("Broadcast music playing on Apple Music", comment: "Toggle to enable or disable broadcasting what music is being played on Apple Music in their profile status.")
})
HStack(alignment: .center) {
Button(action: {
dismiss()
}, label: {
Text("Cancel")
Text("Cancel", comment: "Cancel button text for dismissing profile status settings view.")
})
Spacer()
@@ -121,7 +140,7 @@ struct UserStatusSheet: View {
dismiss()
}, label: {
Text("Save")
Text("Save", comment: "Save button text for saving profile status settings.")
})
.buttonStyle(GradientButtonStyle())
}