Skip to content

Commit

Permalink
Refactor String identifiers (#920)
Browse files Browse the repository at this point in the history
- Group all views under "views.*"
- Split global strings into actions and nouns
- Use underscores
- Clean up unused

Fixes #835
  • Loading branch information
keeshux authored Nov 23, 2024
1 parent 3e2823c commit f13a292
Show file tree
Hide file tree
Showing 71 changed files with 735 additions and 776 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ extension AboutCoordinator {
LinksView()

default:
Text(Strings.Global.noSelection)
Text(Strings.Global.Nouns.noSelection)
.themeEmptyMessage()
}
}
Expand Down Expand Up @@ -124,7 +124,7 @@ extension AboutCoordinator {
}

default:
Text(Strings.Global.noSelection)
Text(Strings.Global.Nouns.noSelection)
.themeEmptyMessage()
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,11 @@ private extension AboutContentView {
.themeSection(header: Strings.Views.About.Sections.resources)
Section {
linkContent(.diagnostics)
Text(Strings.Global.version)
Text(Strings.Global.Nouns.version)
.themeTrailingValue(BundleConfiguration.mainVersionString)
}
}
.navigationTitle(Strings.Global.settings)
.navigationTitle(Strings.Global.Nouns.settings)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ struct AboutContentView<LinkContent, AboutDestination, LogDestination>: View whe
.themeNavigationStack(closable: false, path: $path)
.toolbar {
ToolbarItem(placement: .confirmationAction) {
Button(Strings.Global.ok) {
Button(Strings.Global.Nouns.ok) {
dismiss()
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,24 +52,24 @@ struct AddProfileMenu: View {
private extension AddProfileMenu {
var newProfileButton: some View {
Button {
let profile = profileManager.new(withName: Strings.Entities.Profile.Name.new)
let profile = profileManager.new(withName: Strings.Placeholders.Profile.name)
onNewProfile(profile)
} label: {
ThemeImageLabel(Strings.Views.Profiles.Toolbar.newProfile, .profileEdit)
ThemeImageLabel(Strings.Views.App.Toolbar.newProfile, .profileEdit)
}
}

var importProfileButton: some View {
Button {
isImporting = true
} label: {
ThemeImageLabel(Strings.Views.Profiles.Toolbar.importProfile.withTrailingDots, .profileImport)
ThemeImageLabel(Strings.Views.App.Toolbar.importProfile.withTrailingDots, .profileImport)
}
}

var migrateProfilesButton: some View {
Button(action: onMigrateProfiles) {
ThemeImageLabel(Strings.Views.Profiles.Toolbar.migrateProfiles.withTrailingDots, .profileMigrate)
ThemeImageLabel(Strings.Views.App.Toolbar.migrateProfiles.withTrailingDots, .profileMigrate)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ private extension InstalledProfileView {
}

var nameView: some View {
Text(profile?.name ?? Strings.Views.Profiles.Rows.notInstalled)
Text(profile?.name ?? Strings.Views.App.Rows.notInstalled)
.font(.title2)
.fontWeight(theme.relevantWeight)
.themeTruncating(.tail)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ struct ProfileAttributesView: View {
case .tv:
return (
isRemoteImportingEnabled ? .tvOn : .tvOff,
Strings.Modules.General.Rows.appleTv(Strings.Unlocalized.appleTV)
Strings.Modules.General.Rows.appletv(Strings.Unlocalized.appleTV)
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ struct ProfileCardView: View {
.font(.headline)
.themeTruncating()

Text(preview.subtitle ?? Strings.Views.Profiles.Rows.noModules)
Text(preview.subtitle ?? Strings.Views.App.Rows.noModules)
.multilineTextAlignment(.leading)
.font(.subheadline)
.foregroundStyle(.secondary)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,8 @@ private extension ProfileContainerView {
InteractiveCoordinator(style: .modal, manager: interactiveManager) {
errorHandler.handle(
$0,
title: Strings.Global.connection,
message: Strings.Views.Profiles.Errors.tunnel
title: Strings.Global.Nouns.connection,
message: Strings.Views.App.Errors.tunnel
)
}
.presentationDetents([.medium])
Expand All @@ -122,10 +122,10 @@ private struct ContainerModifier: ViewModifier {
isEmpty: !profileManager.hasProfiles,
emptyContent: {
VStack(spacing: 16) {
Text(Strings.Views.Profiles.Folders.noProfiles)
Text(Strings.Views.App.Folders.noProfiles)
.themeEmptyMessage(fullScreen: false)

Button(Strings.Views.Profiles.Folders.NoProfiles.migrate) {
Button(Strings.Views.App.Folders.NoProfiles.migrate) {
flow?.onMigrateProfiles()
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ private extension ProfileContextMenu {
},
label: {
ThemeImageLabel(
$0 ? Strings.Global.enable : Strings.Global.disable,
$0 ? Strings.Global.Actions.enable : Strings.Global.Actions.disable,
$0 ? .tunnelEnable : .tunnelDisable
)
}
Expand All @@ -89,7 +89,7 @@ private extension ProfileContextMenu {
profile?
.selectedProvider
.map { _ in
Button(Strings.Ui.ProfileContext.connectTo) {
Button(Strings.Views.App.ProfileContext.connectTo) {
flow?.onEditProviderEntity(profile!)
}
}
Expand All @@ -104,7 +104,7 @@ private extension ProfileContextMenu {
flow?.onPurchaseRequired($0)
},
label: {
ThemeImageLabel(Strings.Global.restart, .tunnelRestart)
ThemeImageLabel(Strings.Global.Actions.restart, .tunnelRestart)
}
)
}
Expand All @@ -113,7 +113,7 @@ private extension ProfileContextMenu {
Button {
flow?.onEditProfile(preview)
} label: {
ThemeImageLabel(Strings.Global.edit.withTrailingDots, .profileEdit)
ThemeImageLabel(Strings.Global.Actions.edit.withTrailingDots, .profileEdit)
}
}

Expand All @@ -123,7 +123,7 @@ private extension ProfileContextMenu {
preview: preview,
errorHandler: errorHandler
) {
ThemeImageLabel(Strings.Global.duplicate, .contextDuplicate)
ThemeImageLabel(Strings.Global.Actions.duplicate, .contextDuplicate)
}
}

Expand All @@ -132,7 +132,7 @@ private extension ProfileContextMenu {
profileManager: profileManager,
preview: preview
) {
ThemeImageLabel(Strings.Global.remove, .contextRemove)
ThemeImageLabel(Strings.Global.Actions.remove, .contextRemove)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ struct ProfileDuplicateButton<Label>: View where Label: View {
} catch {
errorHandler.handle(
error,
title: Strings.Global.duplicate,
message: Strings.Views.Profiles.Errors.duplicate(preview.name)
title: Strings.Global.Actions.duplicate,
message: Strings.Views.App.Errors.duplicate(preview.name)
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ struct ProfileGridView: View, Routable, TunnelInstallationProviding {
}
}
}
.themeGridHeader(title: Strings.Views.Profiles.Folders.default)
.themeGridHeader(title: Strings.Views.App.Folders.default)
}
.padding(.horizontal)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ struct ProfileImporterModifier: ViewModifier {
handleResult(.success($0))
}
.alert(
Strings.Views.Profiles.Toolbar.importProfile,
Strings.Views.App.Toolbar.importProfile,
isPresented: $importer.isPresentingPassphrase,
presenting: importer.nextURL,
actions: actions,
Expand All @@ -79,7 +79,7 @@ private extension ProfileImporterModifier {
)
}
}
Button(Strings.Global.cancel, role: .cancel) {
Button(Strings.Global.Actions.cancel, role: .cancel) {
importer.cancelImport()
}
}
Expand All @@ -100,8 +100,8 @@ private extension ProfileImporterModifier {
} catch {
await errorHandler.handle(
error,
title: Strings.Views.Profiles.Toolbar.importProfile,
message: Strings.Views.Profiles.Errors.import
title: Strings.Views.App.Toolbar.importProfile,
message: Strings.Views.App.Errors.import
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ struct ProfileListView: View, Routable, TunnelInstallationProviding {
}
}
}
.themeSection(header: Strings.Views.Profiles.Folders.default)
.themeSection(header: Strings.Views.App.Folders.default)
}
.themeForm()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ struct TunnelRestartButton<Label>: View where Label: View {
} catch {
errorHandler.handle(
error,
title: Strings.Global.connection,
message: Strings.Views.Profiles.Errors.tunnel
title: Strings.Global.Nouns.connection,
message: Strings.Views.App.Errors.tunnel
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,24 +66,24 @@ private extension AppMenu {
}

var showToggle: some View {
Button(Strings.Global.show) {
Button(Strings.Global.Actions.show) {
settings.isVisible = true
}
}

var loginToggle: some View {
Toggle(Strings.Views.Settings.launchesOnLogin, isOn: $settings.launchesOnLogin)
Toggle(Strings.Views.Preferences.launchesOnLogin, isOn: $settings.launchesOnLogin)
}

var keepToggle: some View {
Toggle(Strings.Views.Settings.keepsInMenu, isOn: $settings.keepsInMenu)
Toggle(Strings.Views.Preferences.keepsInMenu, isOn: $settings.keepsInMenu)
}

var profilesList: some View {
Group {
ForEach(profileManager.previews, id: \.id, content: profileToggle)
}
.themeSection(header: Strings.Views.Profiles.Folders.default)
.themeSection(header: Strings.Views.App.Folders.default)
}

func profileToggle(for preview: ProfilePreview) -> some View {
Expand Down Expand Up @@ -112,14 +112,14 @@ private extension AppMenu {
}

var aboutButton: some View {
Button(Strings.Global.about.withTrailingDots) {
Button(Strings.Global.Nouns.about.withTrailingDots) {
NSApp.activate(ignoringOtherApps: true)
NSApp.orderFrontStandardAboutPanel(self)
}
}

var quitButton: some View {
Button(Strings.AppMenu.Items.quit(BundleConfiguration.mainDisplayName)) {
Button(Strings.Views.AppMenu.Items.quit(BundleConfiguration.mainDisplayName)) {
NSApp.terminate(self)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ struct DiagnosticsView: View {
.themeForm()
.navigationTitle(Strings.Views.Diagnostics.title)
.alert(Strings.Views.Diagnostics.ReportIssue.title, isPresented: $isPresentingUnableToEmail) {
Button(Strings.Global.ok, role: .cancel) {
Button(Strings.Global.Nouns.ok, role: .cancel) {
isPresentingUnableToEmail = false
}
} message: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,10 @@ private extension MigrateButton {
var title: String {
switch step {
case .initial, .fetching, .fetched:
return Strings.Views.Migrate.Items.migrate
return Strings.Views.Migration.Items.migrate

case .migrating, .migrated:
return Strings.Global.done
return Strings.Global.Nouns.done
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ private extension MigrateContentView.ListView {
}

var messageView: some View {
Text(Strings.Views.Migrate.Sections.Main.header(Strings.Unlocalized.appName))
Text(Strings.Views.Migration.Sections.Main.header(Strings.Unlocalized.appName))
.padding([.top, .leading, .trailing])
}

Expand Down Expand Up @@ -98,7 +98,7 @@ private extension MigrateContentView.ListView {
}
.listStyle(.plain)
.disabled(!step.canSelect)
.themeEmpty(if: isEmpty, message: Strings.Views.Migrate.noProfiles)
.themeEmpty(if: isEmpty, message: Strings.Views.Migration.noProfiles)
}

func isIncludedBinding(for profileId: UUID) -> Binding<Bool> {
Expand Down Expand Up @@ -142,7 +142,7 @@ private extension MigrateContentView.ListView {
var body: some View {
HStack {
if isEditing {
Button(Strings.Global.cancel) {
Button(Strings.Global.Actions.cancel) {
isEditing = false
}
}
Expand All @@ -165,7 +165,7 @@ private extension MigrateContentView.ListView {
}

var title: String {
isEditing ? Strings.Views.Migrate.Items.discard : Strings.Global.edit
isEditing ? Strings.Views.Migration.Items.discard : Strings.Global.Actions.edit
}

var role: ButtonRole? {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,18 +61,18 @@ private extension MigrateContentView.TableView {
}

var messageView: some View {
Text(Strings.Views.Migrate.Sections.Main.header(Strings.Unlocalized.appName))
Text(Strings.Views.Migration.Sections.Main.header(Strings.Unlocalized.appName))
.padding([.top, .leading, .trailing])
}

var profilesForm: some View {
Form {
Table(profiles) {
TableColumn(Strings.Global.name) {
TableColumn(Strings.Global.Nouns.name) {
Text($0.name)
.foregroundStyle(statuses.style(for: $0.id))
}
TableColumn(Strings.Global.lastUpdate) {
TableColumn(Strings.Global.Nouns.lastUpdate) {
Text($0.timestamp)
.foregroundStyle(statuses.style(for: $0.id))
}
Expand All @@ -98,7 +98,7 @@ private extension MigrateContentView.TableView {
}
.disabled(!step.canSelect)
.themeForm()
.themeEmpty(if: isEmpty, message: Strings.Views.Migrate.noProfiles)
.themeEmpty(if: isEmpty, message: Strings.Views.Migration.noProfiles)
}

func isIncludedBinding(for profileId: UUID) -> Binding<Bool> {
Expand Down
Loading

0 comments on commit f13a292

Please sign in to comment.