1
0
mirror of https://github.com/nicoverbruggen/phpmon.git synced 2025-08-07 12:00:09 +02:00

👌 Improved alerts, localization

This commit is contained in:
2022-06-05 03:03:00 +02:00
parent 94df551b4b
commit fbf2158488
4 changed files with 33 additions and 7 deletions

View File

@ -32,7 +32,9 @@ struct HomebrewService: Decodable, Equatable {
.decode([HomebrewService].self, from: data)
.filter({ return filter.contains($0.name) })
completion(services)
DispatchQueue.main.async {
completion(services)
}
}
}
}

View File

@ -164,8 +164,9 @@ extension MainMenu {
preset.textDescription
)
)
.withPrimary(text: "alert.revert_description.ok".localized, action: { _ in
.withPrimary(text: "alert.revert_description.ok".localized, action: { alert in
self.performRollback()
alert.close(with: .OK)
})
.withSecondary(text: "alert.revert_description.cancel".localized)
.show()

View File

@ -21,27 +21,42 @@ struct Preset: Codable {
configuration = "configuration"
}
/**
What the preset does, in text form. Used to display what's going on.
*/
var textDescription: String {
var text = ""
if self.version != nil {
text += "Switches to PHP \(self.version!).\n"
text += "alert.preset_description.switcher_version".localized(self.version!)
}
if !self.extensions.isEmpty {
text += "\nApplies the following extensions:\n"
// Show a subsection header
text += "alert.preset_description.applying_extensions".localized
}
for (ext, extValue) in self.extensions {
text += "\(ext): \(extValue ? "enabled" : "disabled") \n"
// An extension is either enabled or disabled
let status = extValue
? "alert.preset_description.enabled".localized
: "alert.preset_description.disabled".localized
text += "\(ext): \(status)\n"
}
if !self.configuration.isEmpty {
text += "\nApplies the following configuration values:\n"
// Extra spacing if the previous section was extensions
if !self.extensions.isEmpty {
text += "\n"
}
// Show a subsection header
text += "alert.preset_description.applying_config".localized
}
for (key, value) in self.configuration {
text += "\(key)=\(value ?? "(empty)") \n"
// A value is either displayed, or the value is "(empty)"
text += "\(key)=\(value ?? "alert.preset_description.empty".localized) \n"
}
return text

View File

@ -323,6 +323,14 @@ For optimal support of the latest versions of PHP and proper version switching,
You can do this by running `composer global update` in your terminal. After that, run `valet install` again. For best results, restart PHP Monitor after that.";
// Preset text description
"alert.preset_description.switcher_version" = "Switches to PHP %@.\n\n";
"alert.preset_description.applying_extensions" = "Applies the following extensions:\n";
"alert.preset_description.applying_config" = "Applies the following configuration values:\n";
"alert.preset_description.enabled" = "enabled";
"alert.preset_description.disabled" = "disabled";
"alert.preset_description.empty" = "(empty)";
// PHP version unavailable
"alert.php_switch_unavailable.title" = "Unsupported PHP version";
"alert.php_switch_unavailable.subtitle" = "PHP Monitor can't switch to PHP %@, as it may not be installed or available. Applying this preset has been cancelled.";