Skip to content

Commit

Permalink
Translate system default reader
Browse files Browse the repository at this point in the history
  • Loading branch information
Cay-Zhang committed Jul 9, 2023
1 parent 433166a commit 4da136f
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 8 deletions.
25 changes: 23 additions & 2 deletions Shared/FeedView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -106,14 +106,15 @@ extension FeedView {

@ViewBuilder var integrationButton: some View {
if integrations.count == 1, let url = integrationURL(for: integrations[0]) {
Button(integrations[0].rawValue, systemImage: "arrowshape.turn.up.right.fill") {
let label = LocalizedStringKey(integrations[0] == .systemDefaultReader ? "Subscribe" : integrations[0].rawValue)
Button(label, systemImage: "arrowshape.turn.up.right.fill") {
openURL(url)
}
} else {
Menu {
ForEach(integrations) { key in
if let url = integrationURL(for: key) {
Button(key.rawValue) {
Button(LocalizedStringKey(key.rawValue)) {
openURL(url)
}
}
Expand Down Expand Up @@ -171,5 +172,25 @@ struct RSSHubFeedView: FeedView {
struct FeedView_Previews: PreviewProvider {
static var previews: some View {
ContentView_Previews.previews

VStack(spacing: 16) {
ForEach(Integration.Key.allCases.dropFirst()) { key in
HStack(spacing: 8) {
Button(LocalizedStringKey(key.rawValue), systemImage: "arrowshape.turn.up.right.fill") { }

Button(LocalizedStringKey(key.rawValue), systemImage: "arrowshape.turn.up.right.fill") { }
.environment(\.locale, Locale(identifier: "zh-CN"))
}
}

HStack(spacing: 8) {
Button("Subscribe", systemImage: "arrowshape.turn.up.right.fill") { }

Button("Subscribe", systemImage: "arrowshape.turn.up.right.fill") { }
.environment(\.locale, Locale(identifier: "zh-CN"))
}
}.padding(.horizontal, 25)
.buttonStyle(CayButtonStyle(wideContainerWithBackgroundColor: Color(uiColor: .secondarySystemBackground)))
.previewDisplayName("Subscribe Buttons")
}
}
13 changes: 11 additions & 2 deletions Shared/Integration.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import SwiftUI

var wrappedValue: [Key] {
get {
integrationKeys.split(separator: "\n").compactMap { Key(rawValue: String($0)) }
integrationKeys.split(separator: "\n").compactMap { Key(String($0)) }
}
nonmutating set {
integrationKeys = newValue.map(\.rawValue).joined(separator: "\n")
Expand Down Expand Up @@ -102,7 +102,7 @@ import SwiftUI

extension Integration {
enum Key: String, Identifiable, Hashable, CaseIterable {
case systemDefaultReader = "Default"
case systemDefaultReader = "System Default Reader"
case egoReader = "Ego Reader"
case reeder = "Reeder"
case fieryFeeds = "Fiery Feeds"
Expand All @@ -118,6 +118,15 @@ extension Integration {
case freshRSS = "Fresh RSS"

var id: String { rawValue }

init?(_ string: String) {
// previous versions used "Default" to represent the system default reader
if string == "Default" {
self = .systemDefaultReader
return
}
self.init(rawValue: string)
}
}
}

Expand Down
8 changes: 4 additions & 4 deletions Shared/SettingsView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -142,30 +142,30 @@ struct IntegrationSettingsView: View {
switch key {
case .tinyTinyRSS:
VStack(alignment: .leading, spacing: 2.0) {
Text(key.rawValue)
Text(LocalizedStringKey(key.rawValue))
ValidatedTextField("App URL", text: _integrations.$ttrssBaseURLString, validation: validate(urlString:))
.foregroundColor(.secondary)
.keyboardType(.URL)
.disableAutocorrection(true)
}.tag(key)
case .miniflux:
VStack(alignment: .leading, spacing: 2.0) {
Text(key.rawValue)
Text(LocalizedStringKey(key.rawValue))
ValidatedTextField("App URL", text: _integrations.$minifluxBaseURLString, validation: validate(urlString:))
.foregroundColor(.secondary)
.keyboardType(.URL)
.disableAutocorrection(true)
}.tag(key)
case .freshRSS:
VStack(alignment: .leading, spacing: 2.0) {
Text(key.rawValue)
Text(LocalizedStringKey(key.rawValue))
ValidatedTextField("App URL", text: _integrations.$freshRSSBaseURLString, validation: validate(urlString:))
.foregroundColor(.secondary)
.keyboardType(.URL)
.disableAutocorrection(true)
}.tag(key)
default:
Text(key.rawValue).tag(key)
Text(LocalizedStringKey(key.rawValue)).tag(key)
}
}.listRowBackground(rowBackgroundColor)
}.background(backgroundColor?.ignoresSafeArea())
Expand Down
1 change: 1 addition & 0 deletions Shared/en.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
"Settings Section About" = "About";
"Rules" = "Rules";
"Quick Subscriptions" = "Quick Subscriptions";
"System Default Reader" = "System Default Reader";
"Access Control" = "Access Control";
"Prefer Opening URL In App" = "Prefer Opening Links in App";
"Access Key" = "Access Key";
Expand Down
1 change: 1 addition & 0 deletions Shared/zh-Hans.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
"Settings Section About" = "关于";
"Rules" = "规则";
"Quick Subscriptions" = "一键订阅";
"System Default Reader" = "系统默认阅读器";
"Access Control" = "访问控制";
"Prefer Opening URL In App" = "在应用中打开网页";
"Access Key" = "访问密钥";
Expand Down

0 comments on commit 4da136f

Please sign in to comment.