use local text for more strings

This commit is contained in:
Satindar Dhillon 2023-01-19 17:36:50 -08:00
parent 125f6a2dea
commit 3af4308202
24 changed files with 83 additions and 108 deletions

View file

@ -281,7 +281,7 @@ public struct ShareExtensionView: View {
extensionContext?.completeRequest(returningItems: [], completionHandler: nil)
},
label: {
Label("Read Later", systemImage: "text.book.closed.fill")
Label(LocalText.readLaterGeneric, systemImage: "text.book.closed.fill")
.padding(16)
.frame(maxWidth: .infinity, maxHeight: .infinity)
}
@ -378,7 +378,7 @@ public struct ShareExtensionView: View {
}
viewState = .mainView
}
}, label: { Text("Cancel") })
}, label: { Text(LocalText.cancelGeneric) })
.frame(maxWidth: .infinity, alignment: .leading)
.opacity(viewState == .viewingHighlight ? 0.0 : 1.0)
// Don't show viewState when viewing the highlight
@ -399,7 +399,7 @@ public struct ShareExtensionView: View {
}
}
}
}, label: { Text("Done").bold() })
}, label: { Text(LocalText.doneGeneric).bold() })
.frame(maxWidth: .infinity, alignment: .trailing)
}
.padding(8)
@ -559,7 +559,7 @@ struct ApplyLabelsListView: View {
label: {
HStack {
Image(systemName: "plus.circle.fill").foregroundColor(.green)
Text("Create a new Label").foregroundColor(.appGrayTextContrast)
Text(LocalText.createLabelMessage).foregroundColor(.appGrayTextContrast)
Spacer()
}
}

View file

@ -84,7 +84,7 @@ struct HighlightsListView: View {
var dismissButton: some View {
Button(
action: { presentationMode.wrappedValue.dismiss() },
label: { Text("Done").foregroundColor(.appGrayTextContrast) }
label: { Text(LocalText.doneGeneric).foregroundColor(.appGrayTextContrast) }
)
}

View file

@ -419,7 +419,7 @@ import Views
}
self.itemToRemove = nil
}
Button("Cancel", role: .cancel) { self.itemToRemove = nil }
Button(LocalText.cancelGeneric, role: .cancel) { self.itemToRemove = nil }
}
}
}
@ -507,7 +507,7 @@ import Views
}
self.itemToRemove = nil
}
Button("Cancel", role: .cancel) { self.itemToRemove = nil }
Button(LocalText.cancelGeneric, role: .cancel) { self.itemToRemove = nil }
}
}
}
@ -559,3 +559,42 @@ struct LinkDestination: View {
}
}
}
// TODO: move everything below this to another file
extension LinkedItemFilter {
var displayName: String {
switch self {
case .inbox:
return LocalText.inboxGeneric
case .readlater:
return LocalText.readLaterGeneric
case .newsletters:
return LocalText.newslettersGeneric
case .recommended:
return "Recommended"
case .all:
return LocalText.allGeneric
case .archived:
return LocalText.archivedGeneric
case .hasHighlights:
return LocalText.highlightedGeneric
case .files:
return LocalText.filesGeneric
}
}
}
public extension LinkedItemSort {
var displayName: String {
switch self {
case .newest:
return LocalText.newestGeneric
case .oldest:
return LocalText.oldestGeneric
case .recentlyRead:
return LocalText.recentlyReadGeneric
case .recentlyPublished:
return LocalText.recentlyPublishedGeneric
}
}
}

View file

@ -96,10 +96,10 @@ import Views
placement: .toolbar
) {
if viewModel.searchTerm.isEmpty {
Text("Inbox").searchCompletion("in:inbox ")
Text("All").searchCompletion("in:all ")
Text("Archived").searchCompletion("in:archive ")
Text("Files").searchCompletion("type:file ")
Text(LocalText.inboxGeneric).searchCompletion("in:inbox ")
Text(LocalText.allGeneric).searchCompletion("in:all ")
Text(LocalText.archivedGeneric).searchCompletion("in:archive ")
Text(LocalText.filesGeneric).searchCompletion("type:file ")
}
}
.onChange(of: viewModel.searchTerm) { _ in
@ -137,7 +137,7 @@ import Views
}
}
}
Button("Cancel", role: .cancel) { self.itemToRemove = nil }
Button(LocalText.cancelGeneric, role: .cancel) { self.itemToRemove = nil }
}
.sheet(item: $viewModel.itemUnderLabelEdit) { item in
ApplyLabelsView(mode: .item(item), onSave: nil)

View file

@ -47,7 +47,7 @@ struct ApplyLabelsView: View {
label: {
HStack {
Image(systemName: "plus.circle.fill").foregroundColor(.green)
Text("Create a new Label").foregroundColor(.appGrayTextContrast)
Text(LocalText.createLabelMessage).foregroundColor(.appGrayTextContrast)
Spacer()
}
}
@ -124,7 +124,7 @@ struct ApplyLabelsView: View {
var cancelButton: some View {
Button(
action: { presentationMode.wrappedValue.dismiss() },
label: { Text("Cancel").foregroundColor(.appGrayTextContrast) }
label: { Text(LocalText.cancelGeneric).foregroundColor(.appGrayTextContrast) }
)
}

View file

@ -54,7 +54,7 @@ struct FilterByLabelsView: View {
ToolbarItem(placement: .navigationBarLeading) {
Button(
action: { presentationMode.wrappedValue.dismiss() },
label: { Text("Cancel").foregroundColor(.appGrayTextContrast) }
label: { Text(LocalText.cancelGeneric).foregroundColor(.appGrayTextContrast) }
)
}
ToolbarItem(placement: .navigationBarTrailing) {
@ -63,7 +63,7 @@ struct FilterByLabelsView: View {
onSave?(viewModel.selectedLabels, viewModel.negatedLabels)
presentationMode.wrappedValue.dismiss()
},
label: { Text("Done").foregroundColor(.appGrayTextContrast) }
label: { Text(LocalText.doneGeneric).foregroundColor(.appGrayTextContrast) }
)
}
}

View file

@ -10,8 +10,6 @@ struct LabelsView: View {
@State private var showDeleteConfirmation = false
@State private var labelToRemove: LinkedItemLabel?
let footerText = "Use labels to create curated collections of links."
var body: some View {
Group {
#if os(iOS)
@ -37,7 +35,7 @@ struct LabelsView: View {
}
self.labelToRemove = nil
}
Button("Cancel", role: .cancel) { self.labelToRemove = nil }
Button(LocalText.cancelGeneric, role: .cancel) { self.labelToRemove = nil }
}
.sheet(isPresented: $viewModel.showCreateLabelModal) {
CreateLabelView(viewModel: viewModel)
@ -47,13 +45,13 @@ struct LabelsView: View {
private var innerBody: some View {
Group {
Section(footer: Text(footerText)) {
Section(footer: Text(LocalText.labelsPurposeDescription)) {
Button(
action: { viewModel.showCreateLabelModal = true },
label: {
HStack {
Image(systemName: "plus.circle.fill").foregroundColor(.green)
Text("Create a new Label").foregroundColor(.appGrayTextContrast)
Text(LocalText.createLabelMessage).foregroundColor(.appGrayTextContrast)
Spacer()
}
}
@ -169,7 +167,7 @@ struct CreateLabelView: View {
var cancelCreateLabelButton: some View {
Button(
action: { viewModel.showCreateLabelModal = false },
label: { Text("Cancel").foregroundColor(.appGrayTextContrast) }
label: { Text(LocalText.cancelGeneric).foregroundColor(.appGrayTextContrast) }
)
}

View file

@ -184,7 +184,7 @@ struct LinkItemDetailView: View {
Button("Remove Link", role: .destructive) {
viewModel.handleDeleteAction(dataService: dataService)
}
Button("Cancel", role: .cancel, action: {})
Button(LocalText.cancelGeneric, role: .cancel, action: {})
}
.sheet(isPresented: $showTitleEdit) {
if let item = viewModel.item {

View file

@ -104,7 +104,7 @@ struct LinkedItemMetadataEditView: View {
ToolbarItem(placement: .barLeading) {
Button(
action: { presentationMode.wrappedValue.dismiss() },
label: { Text("Cancel").foregroundColor(.appGrayTextContrast) }
label: { Text(LocalText.cancelGeneric).foregroundColor(.appGrayTextContrast) }
)
}
}
@ -125,7 +125,7 @@ struct LinkedItemMetadataEditView: View {
Button(
action: { presentationMode.wrappedValue.dismiss() },
label: { Text("Cancel").foregroundColor(.appGrayTextContrast) }
label: { Text(LocalText.cancelGeneric).foregroundColor(.appGrayTextContrast) }
)
}
}

View file

@ -37,7 +37,6 @@ import Views
struct NewsletterEmailsView: View {
@EnvironmentObject var dataService: DataService
@StateObject var viewModel = NewsletterEmailsViewModel()
let footerText = "Add PDFs to your library, or subscribe to newsletters using an Omnivore email address."
var body: some View {
Group {
@ -57,7 +56,7 @@ struct NewsletterEmailsView: View {
private var innerBody: some View {
Group {
Section(footer: Text(footerText)) {
Section(footer: Text(LocalText.newslettersDescription)) {
Button(
action: {
Task { await viewModel.createEmail(dataService: dataService) }
@ -65,7 +64,7 @@ struct NewsletterEmailsView: View {
label: {
HStack {
Image(systemName: "plus.circle.fill").foregroundColor(.green)
Text("Create a new email address")
Text(LocalText.createNewEmailMessage)
Spacer()
}
}
@ -96,6 +95,6 @@ struct NewsletterEmailsView: View {
}
}
}
.navigationTitle("Emails")
.navigationTitle(LocalText.emailsGeneric)
}
}

View file

@ -83,11 +83,11 @@ struct ProfileView: View {
}
NavigationLink(destination: NewsletterEmailsView()) {
Text("Emails")
Text(LocalText.emailsGeneric)
}
NavigationLink(destination: SubscriptionsView()) {
Text("Subscriptions")
Text(LocalText.subscriptionsGeneric)
}
NavigationLink(destination: GroupsView()) {
@ -113,7 +113,7 @@ struct ProfileView: View {
Text("Push Notifications")
}
NavigationLink(destination: TextToSpeechView()) {
Text("Text to Speech")
Text(LocalText.textToSpeechGeneric)
}
}
#endif
@ -122,19 +122,19 @@ struct ProfileView: View {
NavigationLink(
destination: BasicWebAppView.privacyPolicyWebView(baseURL: dataService.appEnvironment.webAppBaseURL)
) {
Text("Privacy Policy")
Text(LocalText.privacyPolicyGeneric)
}
NavigationLink(
destination: BasicWebAppView.termsConditionsWebView(baseURL: dataService.appEnvironment.webAppBaseURL)
) {
Text("Terms and Conditions")
Text(LocalText.termsAndConditionsGeneric)
}
#if os(iOS)
Button(
action: { DataService.showIntercomMessenger?() },
label: { Text("Feedback") }
label: { Text(LocalText.feedbackGeneric) }
)
#endif
}
@ -143,10 +143,10 @@ struct ProfileView: View {
NavigationLink(
destination: ManageAccountView()
) {
Text("Manage Account")
Text(LocalText.manageAccountGeneric)
}
Text("Logout")
Text(LocalText.logoutGeneric)
.onTapGesture {
showLogoutConfirmation = true
}

View file

@ -104,7 +104,7 @@ struct CreateRecommendationGroupView: View {
.navigationBarItems(leading:
Button(action: {
viewModel.showCreateSheet = false
}, label: { Text("Cancel") }),
}, label: { Text(LocalText.cancelGeneric) }),
trailing: nextButton)
}
}

View file

@ -115,7 +115,7 @@ struct SubscriptionsView: View {
viewModel.subscriptionNameToCancel = nil
}
}
.navigationTitle("Subscriptions")
.navigationTitle(LocalText.subscriptionsGeneric)
}
}

View file

@ -18,7 +18,7 @@
}
innerBody
}
}.navigationTitle("Text to Speech")
}.navigationTitle(LocalText.textToSpeechGeneric)
}
private var innerBody: some View {

View file

@ -211,7 +211,7 @@ struct RecommendToView: View {
.navigationViewStyle(.stack)
.navigationBarItems(leading: Button(action: {
dismiss()
}, label: { Text("Cancel") }),
}, label: { Text(LocalText.cancelGeneric) }),
trailing: nextButton)
.task {
await viewModel.loadGroups(dataService: dataService)

View file

@ -292,7 +292,7 @@ struct WebReaderContainerView: View {
presentationMode.wrappedValue.dismiss()
#endif
}
Button("Cancel", role: .cancel, action: {})
Button(LocalText.cancelGeneric, role: .cancel, action: {})
}
.sheet(isPresented: $showLabelsModal) {
ApplyLabelsView(mode: .item(item), onSave: { _ in showLabelsModal = false })

View file

@ -72,7 +72,7 @@ struct WelcomeView: View {
Text("By signing up, you agree to Omnivores\n")
+ Text("Terms of Service").underline()
+ Text(" and ")
+ Text("Privacy Policy").underline()
+ Text(LocalText.privacyPolicyGeneric).underline()
}
.font(.appSubheadline)
.confirmationDialog("", isPresented: $showTermsLinks, titleVisibility: .hidden) {

View file

@ -12,27 +12,6 @@ public enum LinkedItemFilter: String, CaseIterable {
}
public extension LinkedItemFilter {
var displayName: String {
switch self {
case .inbox:
return "Inbox"
case .readlater:
return "Read Later"
case .newsletters:
return "Newsletters"
case .recommended:
return "Recommended"
case .all:
return "All"
case .archived:
return "Archived"
case .hasHighlights:
return "Highlighted"
case .files:
return "Files"
}
}
var queryString: String {
switch self {
case .inbox:

View file

@ -8,19 +8,6 @@ public enum LinkedItemSort: String, CaseIterable {
}
public extension LinkedItemSort {
var displayName: String {
switch self {
case .newest:
return "Newest"
case .oldest:
return "Oldest"
case .recentlyRead:
return "Recently Read"
case .recentlyPublished:
return "Recently Published"
}
}
var queryString: String {
switch self {
case .newest:

View file

@ -26,7 +26,7 @@ public struct HighlightAnnotationSheet: View {
public var body: some View {
VStack {
HStack {
Button("Cancel", action: onCancel)
Button(LocalText.cancelGeneric, action: onCancel)
Spacer()
Label("Note", systemImage: "note.text")
Spacer()

View file

@ -201,7 +201,7 @@ public enum WebFont: String, CaseIterable {
// ToolbarItem(placement: .barTrailing) {
// Button(
// action: dismissAction,
// label: { Text("Done").foregroundColor(.appGrayTextContrast).padding() }
// label: { Text(LocalText.doneGeneric).foregroundColor(.appGrayTextContrast).padding() }
// )
// }
// }

View file

@ -49,30 +49,3 @@ public enum LocalText {
public static let labelsPurposeDescription = localText(key: "labels.purpose.description")
public static let noCurrentSubscriptionsMessage = localText(key: "no.current.subscriptions.message")
}
// "emails.generic" = "Emails";
// "subscriptions.generic" = "Subscriptions";
// "textToSpeech.generic" = "Subscriptions";
// "privacy.policy.generic" = "Privacy Policy";
// "termsAndConditions.generic" = "Terms and Conditions";
// "feedback.generic" = "Feedback";
// "manageAccount.generic" = "Manage Account";
// "logout.generic" = "Logout";
// "done.generic" = "Done";
// "cancel.generic" = "Cancel";
// "inbox.generic" = "Inbox";
// "readLater.generic" = "Read Later";
// "newsletters.generic" = "Newsletters";
// "all.generic" = "All";
// "archived.generic" = "Archived";
// "highlighted.generic" = "Highlighted";
// "files.generic" = "Files";
// "newest.generic" = "Newest";
// "oldest.generic" = "Oldest";
// "recentlyRead.generic" = "Recently Read";
// "recentlyPublished.generic" = "Recently Published";
// "create.label.message" = "Create a new Label";
// "create.new.email.message" = "Create a new email address";
// "newsletters.description" = "Add PDFs to your library, or subscribe to newsletters using an Omnivore email address.";
// "labels.purpose.description" = "Use labels to create curated collections of links.";
// "no.current.subscriptions.message" = "You have no current Subscriptions.";

View file

@ -17,7 +17,7 @@
"labels.generic" = "Labels";
"emails.generic" = "Emails";
"subscriptions.generic" = "Subscriptions";
"subscriptions.generic" = "Text to Speech";
"textToSpeech.generic" = "Subscriptions";
"privacy.policy.generic" = "Privacy Policy";
"termsAndConditions.generic" = "Terms and Conditions";

View file

@ -51,7 +51,7 @@ public struct SearchBar: View {
self.isFocused = false
},
label: {
Text("Cancel")
Text(LocalText.cancelGeneric)
}
)
.padding(.trailing, 10)