Skip to content

Commit

Permalink
Fix localization issues and export strings for translation
Browse files Browse the repository at this point in the history
Changelog-Fixed: Fix localization issues and export strings for translation
Signed-off-by: Terry Yiu <[email protected]>
Signed-off-by: William Casarin <[email protected]>
  • Loading branch information
tyiu authored and jb55 committed Sep 24, 2023
1 parent 9f15688 commit eb901a4
Show file tree
Hide file tree
Showing 11 changed files with 254 additions and 77 deletions.
65 changes: 42 additions & 23 deletions damus/Components/Status/UserStatusSheet.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,29 +7,48 @@

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"

var expiration: Date? {
enum StatusDuration: CustomStringConvertible, CaseIterable {
case never
case thirty_mins
case hour
case four_hours
case day
case week

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"
}
}

Expand Down Expand Up @@ -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()
Expand All @@ -121,7 +140,7 @@ struct UserStatusSheet: View {

dismiss()
}, label: {
Text("Save")
Text("Save", comment: "Save button text for saving profile status settings.")
})
.buttonStyle(GradientButtonStyle())
}
Expand Down
2 changes: 1 addition & 1 deletion damus/Views/Buttons/GradientFollowButton.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ struct GradientFollowButton: View {
Button(action: {
follow_state = perform_follow_btn_action(follow_state, target: target)
}) {
Text("\(follow_btn_txt(follow_state, follows_you: follows_you))")
Text(follow_btn_txt(follow_state, follows_you: follows_you))
.foregroundColor(follow_state == .unfollows ? .white : grayTextColor)
.font(.callout)
.fontWeight(.medium)
Expand Down
2 changes: 1 addition & 1 deletion damus/Views/FollowingView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ struct FollowHashtagView: View {
HStack {
SingleCharacterAvatar(character: "#")

Text("#\(hashtag.hashtag)")
Text(verbatim: "#\(hashtag.hashtag)")
.bold()
}
.onTapGesture {
Expand Down
2 changes: 1 addition & 1 deletion damus/Views/Relays/RelayConfigView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ struct RelayConfigView: View {

if recommended.count > 0 {
VStack {
Text("Recommended relays")
Text("Recommended relays", comment: "Title for view of recommended relays.")
.foregroundStyle(DamusLightGradient.gradient)
.padding(10)
.background {
Expand Down
2 changes: 1 addition & 1 deletion damus/Views/Relays/RelayPicView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ struct FailedRelayImage: View {

var body: some View {
let abbrv = String(url?.host()?.first?.uppercased() ?? "R")
Text("\(abbrv)")
Text(abbrv)
.font(.system(size: 40, weight: .bold))
}
}
Expand Down
6 changes: 3 additions & 3 deletions damus/Views/Relays/RelayStatusView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ struct RelayStatusView: View {
var body: some View {
Group {
if connection.isConnecting {
Text("Connecting")
Text("Connecting", comment: "Relay status label that indicates a relay is connecting.")
.font(.caption)
.frame(height: 20)
.padding(.horizontal, 10)
Expand All @@ -25,7 +25,7 @@ struct RelayStatusView: View {
.stroke(DamusColors.warningBorder, lineWidth: 1)
)
} else if connection.isConnected {
Text("Online")
Text("Online", comment: "Relay status label that indicates a relay is connected.")
.font(.caption)
.frame(height: 20)
.padding(.horizontal, 10)
Expand All @@ -37,7 +37,7 @@ struct RelayStatusView: View {
.stroke(DamusColors.successBorder, lineWidth: 1)
)
} else {
Text("Error")
Text("Error", comment: "Relay status label that indicates a relay had an error when connecting")
.font(.caption)
.frame(height: 20)
.padding(.horizontal, 10)
Expand Down
10 changes: 4 additions & 6 deletions damus/Views/Settings/AppearanceSettingsView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,8 @@ struct AppearanceSettingsView: View {

var FontSize: some View {
VStack(alignment: .leading) {
Slider(value: $settings.font_size, in: 0.5...2.0, step: 0.1) {
Text("Font Size")
}
.padding()
Slider(value: $settings.font_size, in: 0.5...2.0, step: 0.1)
.padding()

// Sample text to show how the font size would look
ResizedEventPreview(damus_state: damus_state, settings: settings)
Expand All @@ -37,7 +35,7 @@ struct AppearanceSettingsView: View {

var body: some View {
Form {
Section("Font Size") {
Section(NSLocalizedString("Font Size", comment: "Section label for font size settings.")) {
FontSize
}

Expand All @@ -49,7 +47,7 @@ struct AppearanceSettingsView: View {
.toggleStyle(.switch)
}

Section(header: Text("User Statuses")) {
Section(header: Text("User Statuses", comment: "Section header for user profile status settings.")) {
Toggle(NSLocalizedString("Show general statuses", comment: "Settings toggle for enabling general user statuses"), isOn: $settings.show_general_statuses)
.toggleStyle(.switch)

Expand Down
Loading

0 comments on commit eb901a4

Please sign in to comment.