Skip to content

Commit

Permalink
Add localization comments
Browse files Browse the repository at this point in the history
  • Loading branch information
milanvarady committed Jan 8, 2025
1 parent a71a51d commit 0fd4bd4
Show file tree
Hide file tree
Showing 3 changed files with 181 additions and 240 deletions.
2 changes: 1 addition & 1 deletion Applite/Model/Cask Models/Cask Manager/CaskLoadError.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ enum CaskLoadError: LocalizedError {
case .failedToLoadCategoryJSON:
return "Failed to load categories"
case .failedToLoadFromCache:
return "Failed to load app catalog from cache"
return "Failed to load app catalog from cache, check your internet connection"
case .failedToLoadAdditionalInfo:
return "Failed to load additional info"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
//

import Foundation
import SwiftUI

extension CaskManager {
/// Installs the cask
Expand Down Expand Up @@ -50,10 +51,13 @@ extension CaskManager {
let alertMessage = switch completeOutput {
// Already installed
case _ where completeOutput.contains("It seems there is already an App"):
String(localized: "\(cask.info.name) is already installed. If you want to add it to Applite click more options (chevron icon) and press Force Install.")
String(
localized: "\(cask.info.name) is already installed. If you want to add it to Applite click more options (chevron icon) and press Force Install.",
comment: "App already installed alert message (parameter: app name)"
)
// Network error
case _ where completeOutput.contains("Could not resolve host"):
String(localized: "Couldn't download app. No internet connection, or host is unreachable.")
String(localized: "Couldn't download app. No internet connection, or host is unreachable.", comment: "No internet alert message")
default:
error.localizedDescription
}
Expand All @@ -62,7 +66,7 @@ extension CaskManager {
for: cask,
error: error,
output: completeOutput,
alertTitle: "Failed to install \(cask.info.name)",
alertTitle: String(localized: "Failed to install \(cask.info.name)", comment: "Install failure alert title"),
alertMessage: alertMessage
)
return
Expand All @@ -71,7 +75,7 @@ extension CaskManager {
await self.showSuccess(
for: cask,
logMessage: "Successfully installed cask \(cask.id)",
alertTitle: "\(cask.info.name) successfully installed!"
notificationTitle: String(localized: "\(cask.info.name) successfully installed!", comment: "Successful app install notification")
)

// Update state
Expand All @@ -86,7 +90,7 @@ extension CaskManager {
/// - zap: If true the app will be uninstalled completely using the brew --zap flag
func uninstall(_ cask: Cask, zap: Bool = false) {
runTask(for: cask) {
cask.progressState = .busy(withTask: "Uninstalling")
cask.progressState = .busy(withTask: String(localized: "Uninstalling", comment: "Uninstall progress text"))

var arguments: [String] = ["uninstall", "--cask", cask.info.id]

Expand All @@ -104,7 +108,7 @@ extension CaskManager {
for: cask,
error: error,
output: output,
alertTitle: "Failed to uninstall \(cask.info.name)",
alertTitle: String(localized: "Failed to uninstall \(cask.info.name)", comment: "Failed app install alert title"),
alertMessage: error.localizedDescription
)
return
Expand All @@ -113,7 +117,7 @@ extension CaskManager {
await self.showSuccess(
for: cask,
logMessage: "Successfully uninstalled \(cask.info.id)",
alertTitle: "\(cask.info.name) successfully uninstalled"
notificationTitle: String(localized: "\(cask.info.name) successfully uninstalled", comment: "Successful app uninstall notification")
)

// Update state
Expand All @@ -125,7 +129,7 @@ extension CaskManager {
/// Updates the cask
func update(_ cask: Cask) {
runTask(for: cask) {
cask.progressState = .busy(withTask: "Updating")
cask.progressState = .busy(withTask: String(localized: "Updating", comment: "Update progress text"))

var output: String = ""

Expand All @@ -136,7 +140,7 @@ extension CaskManager {
for: cask,
error: error,
output: output,
alertTitle: "Failed to update \(cask.info.name)",
alertTitle: String(localized: "Failed to update \(cask.info.name)", comment: "Failed app update alert title"),
alertMessage: error.localizedDescription
)
return
Expand All @@ -145,7 +149,7 @@ extension CaskManager {
await self.showSuccess(
for: cask,
logMessage: "Successfully updated \(cask.id)",
alertTitle: "\(cask.info.name) successfully updated"
notificationTitle: String(localized: "\(cask.info.name) successfully updated", comment: "Successful app update notification")
)

// Update state
Expand All @@ -156,7 +160,7 @@ extension CaskManager {
/// Reinstalls the cask
func reinstall(_ cask: Cask) {
runTask(for: cask) {
cask.progressState = .busy(withTask: "Reinstalling")
cask.progressState = .busy(withTask: String(localized: "Reinstalling", comment: "Reinstall progress text"))

var output: String = ""

Expand All @@ -167,7 +171,7 @@ extension CaskManager {
for: cask,
error: error,
output: output,
alertTitle: "Failed to reinstall \(cask.info.name)",
alertTitle: String(localized: "Failed to reinstall \(cask.info.name)", comment: "Failed reinstall alert title"),
alertMessage: error.localizedDescription
)
return
Expand All @@ -176,7 +180,7 @@ extension CaskManager {
await self.showSuccess(
for: cask,
logMessage: "Successfully reinstalled \(cask.info.id)",
alertTitle: "\(cask.info.name) successfully reinstalled"
notificationTitle: String(localized: "\(cask.info.name) successfully reinstalled", comment: "Successful reinstall notification")
)
}
}
Expand Down Expand Up @@ -248,7 +252,7 @@ extension CaskManager {
}
}
else if output.contains("Installing") || output.contains("Moving") || output.contains("Linking") {
return .busy(withTask: String(localized: "Installing"))
return .busy(withTask: String(localized: "Installing", comment: "Install progress text"))
}
else if output.contains("successfully installed") {
return .success
Expand All @@ -265,8 +269,8 @@ extension CaskManager {
private func showSuccess(
for cask: Cask,
logMessage: String,
alertTitle: String,
alertMessage: String = ""
notificationTitle: String,
notificationMessage: String = ""
) async {
Self.logger.info("\(logMessage)")

Expand All @@ -275,7 +279,7 @@ extension CaskManager {
try? await Task.sleep(for: .seconds(2))
cask.progressState = .idle

await sendNotification(title: alertTitle, body: alertMessage, reason: .success)
await sendNotification(title: notificationTitle, body: notificationMessage, reason: .success)
}

/// Register failed task
Expand Down
Loading

0 comments on commit 0fd4bd4

Please sign in to comment.