Skip to content

Commit

Permalink
Update localization
Browse files Browse the repository at this point in the history
  • Loading branch information
milanvarady committed Jan 8, 2025
1 parent 41e1a30 commit a71a51d
Show file tree
Hide file tree
Showing 44 changed files with 667 additions and 201 deletions.
2 changes: 1 addition & 1 deletion Applite/AppliteApp.swift
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ struct AppliteApp: App {
}
.windowResizability(.contentSize)

Window("Uninstall \(Bundle.main.appName)", id: "uninstall-self") {
Window("Uninstall Applite", id: "uninstall-self") {
UninstallSelfView()
.padding()
.preferredColorScheme(selectedColorScheme)
Expand Down
6 changes: 0 additions & 6 deletions Applite/Extensions/BundleExtension.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,6 @@
import Foundation

extension Bundle {
var appName: String {
object(forInfoDictionaryKey: "CFBundleDisplayName") as? String ??
object(forInfoDictionaryKey: "CFBundleName") as? String ??
""
}

var version: String {
return infoDictionary?["CFBundleShortVersionString"] as? String ?? "N/A"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ 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 \(Bundle.main.appName) 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.")
// Network error
case _ where completeOutput.contains("Could not resolve host"):
String(localized: "Couldn't download app. No internet connection, or host is unreachable.")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,19 @@
//

import Foundation
import SwiftUI

extension CaskManager {
// URLs
private static let cacheDirectory = URL.cachesDirectory
.appendingPathComponent(Bundle.main.appName, conformingTo: .directory)
.appendingPathComponent("Applite", conformingTo: .directory)

private static let caskCacheURL = URL.cachesDirectory
.appendingPathComponent(Bundle.main.appName, conformingTo: .directory)
.appendingPathComponent("Applite", conformingTo: .directory)
.appendingPathComponent("cask.json", conformingTo: .json)

private static let analyicsCacheURL = URL.cachesDirectory
.appendingPathComponent(Bundle.main.appName, conformingTo: .directory)
.appendingPathComponent("Applite", conformingTo: .directory)
.appendingPathComponent("caskAnalytics.json", conformingTo: .json)

/// Gathers all necessary information and combines them to a list of ``Cask`` objects
Expand Down Expand Up @@ -256,7 +257,7 @@ extension CaskManager {

categoryViewModels.append(
CategoryViewModel(
name: category.id,
name: LocalizedStringKey(category.id),
sfSymbol: category.sfSymbol,
casks: casks,
casksCoupled: chunkedCasks
Expand Down
3 changes: 2 additions & 1 deletion Applite/Model/Cask Models/Cask Manager/CaskManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

import Foundation
import OSLog
import SwiftUI

typealias CaskId = String
typealias BrewAnalyticsDictionary = [CaskId: Int]
Expand Down Expand Up @@ -39,7 +40,7 @@ final class CaskManager: ObservableObject {
do {
let categories = try loadCategoryJSON()
let categoryViewModels = categories.map {
CategoryViewModel(name: $0.id, sfSymbol: $0.sfSymbol, casks: [], casksCoupled: [])
CategoryViewModel(name: LocalizedStringKey($0.id), sfSymbol: $0.sfSymbol, casks: [], casksCoupled: [])
}

self.categories = categoryViewModels
Expand Down
10 changes: 7 additions & 3 deletions Applite/Model/Categories/CategoryViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,17 @@
// Created by Milán Várady on 2025.01.01.
//

import Foundation
import SwiftUI

struct CategoryViewModel: Identifiable, Equatable, Hashable {
let name: String
let name: LocalizedStringKey
let sfSymbol: String
let casks: [Cask]
let casksCoupled: [[Cask]]

var id: String { name }
var id: String { sfSymbol }

func hash(into hasher: inout Hasher) {
hasher.combine(sfSymbol)
}
}
4 changes: 2 additions & 2 deletions Applite/Utilities/Other/BrewPaths.swift
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,12 @@ struct BrewPaths {

/// Brew directory when installing brew separately into Application Support
static let appBrewDirectory = URL.applicationSupportDirectory
.appendingPathComponent(Bundle.main.appName, isDirectory: true)
.appendingPathComponent("Applite", isDirectory: true)
.appendingPathComponent("homebrew", isDirectory: true)

/// Brew exectuable path when installing brew separately into Application Support
static let appBrewExetutable = URL.applicationSupportDirectory
.appendingPathComponent(Bundle.main.appName, isDirectory: true)
.appendingPathComponent("Applite", isDirectory: true)
.appendingPathComponent("homebrew", isDirectory: true)
.appendingPathComponent("bin", isDirectory: true)
.appendingPathComponent("brew")
Expand Down
8 changes: 4 additions & 4 deletions Applite/Utilities/Other/UninstallSelf.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@ func uninstallSelf(deleteBrewCache: Bool) async throws {

// Delete related files and cache
let command = """
rm -r "$HOME/Library/Application Support/\(Bundle.main.appName)";
rm -r "$HOME/Library/Application Support/Applite";
rm -r "$HOME/Library/Application Support/\(Bundle.main.bundleIdentifier!)";
rm -r $HOME/Library/Containers/\(Bundle.main.bundleIdentifier!);
rm -r $HOME/Library/Caches/\(Bundle.main.appName);
rm -r $HOME/Library/Caches/Applite;
rm -r $HOME/Library/Caches/\(Bundle.main.bundleIdentifier!);
rm -r $HOME/Library/\(Bundle.main.appName);
rm -r $HOME/Library/Applite;
rm -r $HOME/Library/Preferences/*\(Bundle.main.bundleIdentifier!)*.plist;
rm -r "$HOME/Library/Saved Application State/\(Bundle.main.bundleIdentifier!).savedState";
rm -r $HOME/Library/SyncedPreferences/\(Bundle.main.bundleIdentifier!)*.plist;
Expand All @@ -56,6 +56,6 @@ func uninstallSelf(deleteBrewCache: Bool) async throws {
// Quit the app and remove it
let process = Process()
process.launchPath = "/bin/bash"
process.arguments = ["-c", "osascript -e 'tell application \"\(Bundle.main.appName)\" to quit' && sleep 2 && rm -rf \"\(Bundle.main.bundlePath)\" && defaults write \(Bundle.main.bundleIdentifier!) setupComplete 0"]
process.arguments = ["-c", "osascript -e 'tell application \"Applite\" to quit' && sleep 2 && rm -rf \"\(Bundle.main.bundlePath)\" && defaults write \(Bundle.main.bundleIdentifier!) setupComplete 0"]
process.launch()
}
2 changes: 1 addition & 1 deletion Applite/Views/App Views/App View/AppView+ActionsView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ extension AppView {

case .failed(let output):
HStack {
Text("Error")
Text("Error", comment: "Cask action failed (e.g. installation failed)")
.foregroundStyle(.red)

Button {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ extension AppView {
.font(.system(size: 14))
.buttonStyle(.bordered)
.clipShape(Capsule())
.alert("\(Bundle.main.appName) couldn't open \(cask.info.name)", isPresented: $showAppNotFoundAlert) {}
.alert("Applite couldn't open \(cask.info.name)", isPresented: $showAppNotFoundAlert) {}

if deleteButton {
UninstallButton(cask: cask)
Expand Down
4 changes: 2 additions & 2 deletions Applite/Views/App Views/AppliteAppView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ struct AppliteAppView: View {

// Name and description
VStack(alignment: .leading) {
Text("Applite")
Text("Applite", comment: "Applite app card title")
.font(.system(size: 16, weight: .bold))

Text("This app")
Text("This app", comment: "Applite app card description")
.foregroundColor(.secondary)
}

Expand Down
4 changes: 2 additions & 2 deletions Applite/Views/Commands.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ struct CommandsMenu: Commands {
SidebarCommands()

CommandGroup(replacing: .appInfo) {
Button("About \(Bundle.main.appName)") {
Button("About Applite") {
NSApplication.shared.orderFrontStandardAboutPanel(
options: [
NSApplication.AboutPanelOptionKey.credits: NSAttributedString(
Expand All @@ -41,7 +41,7 @@ struct CommandsMenu: Commands {
}

CheckForUpdatesView(updater: updaterController.updater) {
Text("Check for Updates...")
Text("Check for Updates...", comment: "Check for update menu bar item")
}

Divider()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@
import SwiftUI

extension BrewPathSelectorView {
func getPathDescription(for option: BrewPaths.PathOption) -> String {
func getPathDescription(for option: BrewPaths.PathOption) -> LocalizedStringKey {
switch option {
case .appPath:
return "\(Bundle.main.appName)'s installation"
return "Applite's installation"

case .defaultAppleSilicon:
return "Apple Silicon Mac"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import SwiftUI
extension BrewPathSelectorView {
func pathOption(_ option: BrewPaths.PathOption, showPath: Bool = true) -> some View {
HStack {
Text("\(getPathDescription(for: option))")
Text(getPathDescription(for: option))

if showPath {
Text("(\(BrewPaths.getBrewExectuablePath(for: option, shellFriendly: false)))")
Expand Down
2 changes: 1 addition & 1 deletion Applite/Views/Content View/ContentView+SidebarViews.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ extension ContentView {

Section("Categories") {
ForEach(caskManager.categories) { category in
Label(LocalizedStringKey(category.name), systemImage: category.sfSymbol)
Label(category.name, systemImage: category.sfSymbol)
.tag(SidebarItem.appCategory(category: category))
}
}
Expand Down
2 changes: 1 addition & 1 deletion Applite/Views/Detail Views/ActiveTasksView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ struct ActiveTasksView: View {
ScrollView {
VStack {
if caskManager.activeTasks.isEmpty {
Text("No Active Tasks")
Text("No Active Tasks", comment: "No active tasks available message")
.font(.title)
} else {
AppGridView(casks: caskManager.activeTasks.map { $0.cask }, appRole: .update)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ extension AppMigrationView {

var body: some View {
VStack(alignment: .leading) {
Text("Export")
Text("Export", comment: "App migration export card title")
.font(.appliteSmallTitle)

HStack {
Expand All @@ -45,7 +45,7 @@ extension AppMigrationView {
}
.padding(.bottom, 10)

Text("Export all apps currently installed by \(Bundle.main.appName) to a file.")
Text("Export all apps currently installed by Appname to a file.", comment: "App Migration export card description")

Spacer()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ extension AppMigrationView {

var body: some View {
VStack(alignment: .leading) {
Text("Import")
Text("Import", comment: "App Migration import card title")
.font(.appliteSmallTitle)

HStack {
Expand All @@ -39,7 +39,10 @@ extension AppMigrationView {
}
.padding(.bottom, 10)

Text("**Tip:** You can also import apps from a Brewfile. However, only casks will be installed, other items like formulae and taps will be skipped.")
Text(
"**Tip:** You can also import apps from a Brewfile. However, only casks will be installed, other items like formulae and taps will be skipped.",
comment: "App Migration import card tip"
)

Spacer()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,14 @@ struct AppMigrationView: View {

var titleAndDescription: some View {
VStack(alignment: .leading) {
Text("App Migration")
Text("App Migration", comment: "App Migration view title")
.font(.appliteMediumTitle)
.padding(.bottom, 2)

Text("Export all of your currently installed apps to a file. Import the file to another device to install them all. Useful when setting up a new Mac.")
Text(
"Export all of your currently installed apps to a file. Import the file to another device to install them all. Useful when setting up a new Mac.",
comment: "App migration view description"
)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ extension BrewManagementView {

var body: some View {
VStack(alignment: .leading) {
Text("Actions")
Text("Actions", comment: "Brew Management view action section title")
.font(.appliteSmallTitle)

HStack {
Expand All @@ -52,8 +52,8 @@ extension BrewManagementView {
paddig: cardPadding,
actionSuccessful: $reinstallDone,
remarks: [
.init(title: "Note", color: .blue, remark: "This will (re)install \(Bundle.main.appName)'s Homebrew installation at: ~/Library/Application Support/\(Bundle.main.appName)/homebrew"),
.init(title: "Warning", color: .orange, remark: "After reinstalling, all currently installed apps will be unlinked from \(Bundle.main.appName). They won't be deleted, but you won't be able to update or uninstall them via \(Bundle.main.appName).")
.init(title: "Note", color: .blue, remark: "This will (re)install Applite's Homebrew installation at: `~/Library/Application Support/Applite/homebrew`"),
.init(title: "Warning", color: .orange, remark: "After reinstalling, all currently installed apps will be unlinked from Applite. They won't be deleted, but you won't be able to update or uninstall them via Applite.")
]
) {
reinstallButton
Expand All @@ -65,7 +65,7 @@ extension BrewManagementView {
// Progress indicator
if modifyingBrew {
HStack {
Text("In progress...")
Text("In progress...", comment: "Brew Management view progress indicator")
.bold()

SmallProgressView()
Expand Down Expand Up @@ -189,9 +189,9 @@ extension BrewManagementView {
Button("Cancel", role: .cancel) { }
} message: {
if isAppBrewInstalled {
Text("All currently installed apps will be unlinked from \(Bundle.main.appName).")
Text("All currently installed apps will be unlinked from Applite.", comment: "Brew reinstallation alert warning")
} else {
Text("A new Homebrew installation will be installed into ~/Library/Application Support/\(Bundle.main.appName)")
Text("A new Homebrew installation will be installed into `~/Library/Application Support/Applite`", comment: "Brew installation alert notice")
}
}
.alert("Reinstall failed", isPresented: $reinstallFailed, actions: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ extension BrewManagementView {

var body: some View {
VStack(alignment: .leading) {
Text("Info")
Text("Info", comment: "Brew Management view info section title")
.font(.appliteSmallTitle)

HStack {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,14 @@ struct BrewManagementView: View {

var titleAndDescription: some View {
VStack(alignment: .leading) {
Text("Manage Homebrew")
Text("Manage Homebrew", comment: "Manage Homebrew view title")
.font(.appliteMediumTitle)
.padding(.bottom, 2)

Text("This application uses the [Homebrew](https://brew.sh/) (brew for short) package manager to download apps. Homebrew is a free and open source command line utility that can download useful developer tools as well as desktop applications.")
Text(
"This application uses the [Homebrew](https://brew.sh/) (brew for short) package manager to download apps. Homebrew is a free and open source command line utility that can download useful developer tools as well as desktop applications.",
comment: "Manage Homebrew view description"
)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ extension DiscoverSectionView {
Image(systemName: category.sfSymbol)
.font(.system(size: fontSize))

Text(LocalizedStringKey(category.name))
Text(category.name)
.font(.system(size: fontSize, weight: .bold))

Button("See All") {
Expand Down
2 changes: 1 addition & 1 deletion Applite/Views/Detail Views/Discover/DiscoverView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ struct DiscoverView: View {

var body: some View {
LazyVStack(alignment: .leading) {
Text("Discover")
Text("Discover", comment: "Discover view title")
.font(.appliteLargeTitle)
.padding(.bottom)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@ extension DownloadView {
Image(systemName: "magnifyingglass")
.font(.appliteMediumTitle)

Text("\"\(searchText)\" didn't match any app. Either it's not available in the Homebrew catalog or you misspelled it.")
Text(
"\"\(searchText)\" didn't match any app. Either it's not available in the Homebrew catalog or you misspelled it.",
comment: "Empty search results message"
)
.font(.system(size: 20))
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@ extension DownloadView {
Menu {
Picker("Sort by", selection: $sortBy) {
ForEach(SortingOptions.allCases) { option in
Text(LocalizedStringKey(option.description))
Text(option.description)
.tag(option)
}
}
.pickerStyle(.inline)

Toggle(isOn: $hideUnpopularApps) {
Text("Hide apps with few downloads")
Text("Hide apps with few downloads", comment: "Few downloads search filter")
}
} label: {
Label("Search Sorting Options", systemImage: "slider.horizontal.3")
Expand Down
Loading

0 comments on commit a71a51d

Please sign in to comment.