Skip to content

Commit

Permalink
Decouple error strings from views
Browse files Browse the repository at this point in the history
  • Loading branch information
keeshux committed Nov 27, 2024
1 parent 9bb116b commit 1c3f698
Show file tree
Hide file tree
Showing 8 changed files with 17 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ private extension ProfileContainerView {
errorHandler.handle(
$0,
title: interactiveManager.editor.profile.name,
message: Strings.Views.App.Errors.tunnel
message: Strings.Errors.App.tunnel
)
}
.presentationDetents([.medium])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ struct ProfileDuplicateButton<Label>: View where Label: View {
errorHandler.handle(
error,
title: Strings.Global.Actions.duplicate,
message: Strings.Views.App.Errors.duplicate(preview.name)
message: Strings.Errors.App.duplicate(preview.name)
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ private extension ProfileImporterModifier {
await errorHandler.handle(
error,
title: Strings.Views.App.Toolbar.importProfile,
message: Strings.Views.App.Errors.import
message: Strings.Errors.App.import
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ struct TunnelRestartButton<Label>: View where Label: View {
errorHandler.handle(
error,
title: profile.name,
message: Strings.Views.App.Errors.tunnel
message: Strings.Errors.App.tunnel
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ private extension ProfileView {
errorHandler.handle(
$0,
title: interactiveManager.editor.profile.name,
message: Strings.Views.App.Errors.tunnel
message: Strings.Errors.App.tunnel
)
}
.font(.body)
Expand Down
22 changes: 8 additions & 14 deletions Passepartout/Library/Sources/UILibrary/L10n/SwiftGen+Strings.swift
Original file line number Diff line number Diff line change
Expand Up @@ -96,14 +96,22 @@ public enum Strings {
public enum App {
/// Unable to complete operation.
public static let `default` = Strings.tr("Localizable", "errors.app.default", fallback: "Unable to complete operation.")
/// Unable to duplicate profile '%@'.
public static func duplicate(_ p1: Any) -> String {
return Strings.tr("Localizable", "errors.app.duplicate", String(describing: p1), fallback: "Unable to duplicate profile '%@'.")
}
/// Unable to fetch products, please retry later.
public static let emptyProducts = Strings.tr("Localizable", "errors.app.empty_products", fallback: "Unable to fetch products, please retry later.")
/// Profile name is empty.
public static let emptyProfileName = Strings.tr("Localizable", "errors.app.empty_profile_name", fallback: "Profile name is empty.")
/// Unable to import profiles.
public static let `import` = Strings.tr("Localizable", "errors.app.import", fallback: "Unable to import profiles.")
/// Module %@ is malformed. %@
public static func malformedModule(_ p1: Any, _ p2: Any) -> String {
return Strings.tr("Localizable", "errors.app.malformed_module", String(describing: p1), String(describing: p2), fallback: "Module %@ is malformed. %@")
}
/// Unable to execute tunnel operation.
public static let tunnel = Strings.tr("Localizable", "errors.app.tunnel", fallback: "Unable to execute tunnel operation.")
public enum Passepartout {
/// Routing module can only be enabled together with a connection.
public static let connectionModuleRequired = Strings.tr("Localizable", "errors.app.passepartout.connection_module_required", fallback: "Routing module can only be enabled together with a connection.")
Expand All @@ -128,10 +136,6 @@ public enum Strings {
/// No provider selected.
public static let providerRequired = Strings.tr("Localizable", "errors.app.passepartout.provider_required", fallback: "No provider selected.")
}
public enum Provider {
/// No provider selected.
public static let `required` = Strings.tr("Localizable", "errors.app.provider.required", fallback: "No provider selected.")
}
}
public enum Tunnel {
/// Auth failed
Expand Down Expand Up @@ -570,16 +574,6 @@ public enum Strings {
}
}
public enum App {
public enum Errors {
/// Unable to duplicate profile '%@'.
public static func duplicate(_ p1: Any) -> String {
return Strings.tr("Localizable", "views.app.errors.duplicate", String(describing: p1), fallback: "Unable to duplicate profile '%@'.")
}
/// Unable to import profiles.
public static let `import` = Strings.tr("Localizable", "views.app.errors.import", fallback: "Unable to import profiles.")
/// Unable to execute tunnel operation.
public static let tunnel = Strings.tr("Localizable", "views.app.errors.tunnel", fallback: "Unable to execute tunnel operation.")
}
public enum Folders {
/// My profiles
public static let `default` = Strings.tr("Localizable", "views.app.folders.default", fallback: "My profiles")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,6 @@
"views.app.toolbar.import_profile" = "Import profile";
"views.app.toolbar.migrate_profiles" = "Migrate profiles";
"views.app.tv.header" = "Open %@ on your iOS or macOS device and enable the \"%@\" toggle of a profile to make it appear here.";
"views.app.errors.tunnel" = "Unable to execute tunnel operation.";
"views.app.errors.duplicate" = "Unable to duplicate profile '%@'.";
"views.app.errors.import" = "Unable to import profiles.";

"views.app.profile_context.connect_to" = "Connect to";

Expand Down Expand Up @@ -329,10 +326,12 @@
// MARK: Global (App errors)

"errors.app.default" = "Unable to complete operation.";
"errors.app.duplicate" = "Unable to duplicate profile '%@'.";
"errors.app.empty_products" = "Unable to fetch products, please retry later.";
"errors.app.empty_profile_name" = "Profile name is empty.";
"errors.app.import" = "Unable to import profiles.";
"errors.app.malformed_module" = "Module %@ is malformed. %@";
"errors.app.provider.required" = "No provider selected.";
"errors.app.tunnel" = "Unable to execute tunnel operation.";

// MARK: Global (PassepartoutKit errors)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ private extension TunnelToggleButton {
errorHandler.handle(
error,
title: profile.name,
message: Strings.Views.App.Errors.tunnel
message: Strings.Errors.App.tunnel
)
}
}
Expand Down

0 comments on commit 1c3f698

Please sign in to comment.