Skip to content

Commit ebafb0f

Browse files
authored
Merge branch 'main' into brazilian-localization
2 parents 5be971c + 4049e43 commit ebafb0f

22 files changed

Lines changed: 469 additions & 130 deletions

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,8 @@ The following languages are supported because of the following community users!
4040
|Hindi 🇮🇳 |[@KGurpreet](https://github.com/KGurpreet)|Chinese-Simplified 🇨🇳|[@megabitsenmzq](https://github.com/megabitsenmzq)|
4141
|Finnish 🇫🇮 |[@marcusziade](https://github.com/marcusziade)|Chinese-Traditional 🇹🇼|[@itszero](https://github.com/itszero)|
4242
|Ukranian 🇺🇦 |[@gelosi](https://github.com/gelosi)|Japanese 🇯🇵|[@tatsuz0u](https://github.com/tatsuz0u)|
43-
|German 🇩🇪|[@drct](https://github.com/drct)|Brazilian Portuguese 🇧🇷|[@brunomunizaf](https://github.com/brunomunizaf)|
43+
|German 🇩🇪|[@drct](https://github.com/drct)|Dutch 🇳🇱|[@jfversluis](https://github/com/jfversluis)|
44+
|Brazilian Portuguese 🇧🇷|[@brunomunizaf](https://github.com/brunomunizaf)||
4445

4546
Want to add more languages? Simply create a PR with the updated strings file.
4647
## Installation

Xcodes.xcodeproj/project.pbxproj

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
objects = {
88

99
/* Begin PBXBuildFile section */
10+
36741BFD291E4FDB00A85AAE /* DownloadPreferencePane.swift in Sources */ = {isa = PBXBuildFile; fileRef = 36741BFC291E4FDB00A85AAE /* DownloadPreferencePane.swift */; };
11+
36741BFF291E50F500A85AAE /* FileError.swift in Sources */ = {isa = PBXBuildFile; fileRef = 36741BFE291E50F500A85AAE /* FileError.swift */; };
1012
536CFDD2263C94DE00026CE0 /* SignedInView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 536CFDD1263C94DE00026CE0 /* SignedInView.swift */; };
1113
536CFDD4263C9A8000026CE0 /* XcodesSheet.swift in Sources */ = {isa = PBXBuildFile; fileRef = 536CFDD3263C9A8000026CE0 /* XcodesSheet.swift */; };
1214
53CBAB2C263DCC9100410495 /* XcodesAlert.swift in Sources */ = {isa = PBXBuildFile; fileRef = 53CBAB2B263DCC9100410495 /* XcodesAlert.swift */; };
@@ -170,7 +172,9 @@
170172
/* Begin PBXFileReference section */
171173
15FAD1652811D15600B63259 /* hi */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = hi; path = hi.lproj/Localizable.strings; sourceTree = "<group>"; };
172174
25E2FA26284769A00014A318 /* it */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = it; path = it.lproj/Localizable.strings; sourceTree = "<group>"; };
173-
327DF109286ABE6B00D694D5 /* pt-BR */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = "pt-BR"; path = "pt-BR.lproj/Localizable.strings"; sourceTree = "<group>"; };
175+
327DF109286ABE6B00D694D5 /* pt-BR */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = "pt-BR"; path = "pt-BR.lproj/Localizable.strings"; sourceTree = "<group>"; };
176+
36741BFC291E4FDB00A85AAE /* DownloadPreferencePane.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DownloadPreferencePane.swift; sourceTree = "<group>"; };
177+
36741BFE291E50F500A85AAE /* FileError.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FileError.swift; sourceTree = "<group>"; };
174178
4A5AAA1D28118FAD00528958 /* ru */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = ru; path = ru.lproj/Localizable.strings; sourceTree = "<group>"; };
175179
536CFDD1263C94DE00026CE0 /* SignedInView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SignedInView.swift; sourceTree = "<group>"; };
176180
536CFDD3263C9A8000026CE0 /* XcodesSheet.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = XcodesSheet.swift; sourceTree = "<group>"; };
@@ -290,6 +294,7 @@
290294
CAFE4ABB25B7D54B0064FE51 /* UpdatesPreferencePane.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = UpdatesPreferencePane.swift; sourceTree = "<group>"; };
291295
CAFFFED7259CDA5000903F81 /* XcodeListViewRow.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = XcodeListViewRow.swift; sourceTree = "<group>"; };
292296
CAFFFEEE259CEAC400903F81 /* RingProgressViewStyle.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RingProgressViewStyle.swift; sourceTree = "<group>"; };
297+
E2AFDCCA28F024D000864ADD /* nl */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = nl; path = nl.lproj/Localizable.strings; sourceTree = "<group>"; };
293298
E81D7E9F2805250100A205FC /* Collection+.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Collection+.swift"; sourceTree = "<group>"; };
294299
E872EE4F2808D4F100D3DD8B /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/Localizable.strings; sourceTree = "<group>"; };
295300
E87DD6EA25D053FA00D86808 /* Progress+.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Progress+.swift"; sourceTree = "<group>"; };
@@ -457,6 +462,7 @@
457462
CAA858C325A2BE4E00ACF8C0 /* Downloader.swift */,
458463
CABFA9B22592EEEA00380FEE /* Entry+.swift */,
459464
CABFA9A92592EEE900380FEE /* Environment.swift */,
465+
36741BFE291E50F500A85AAE /* FileError.swift */,
460466
CABFA9B82592EEEA00380FEE /* FileManager+.swift */,
461467
CAFBDB942598FE96003DCC5A /* FocusedValues.swift */,
462468
CABFA9AC2592EEE900380FEE /* Foundation.swift */,
@@ -589,6 +595,7 @@
589595
isa = PBXGroup;
590596
children = (
591597
CAFE4AB325B7D3AF0064FE51 /* AdvancedPreferencePane.swift */,
598+
36741BFC291E4FDB00A85AAE /* DownloadPreferencePane.swift */,
592599
CAFE4AAB25B7D2C70064FE51 /* GeneralPreferencePane.swift */,
593600
CAFE4ABB25B7D54B0064FE51 /* UpdatesPreferencePane.swift */,
594601
E8977EA225C11E1500835F80 /* PreferencesView.swift */,
@@ -723,6 +730,7 @@
723730
uk,
724731
fi,
725732
"pt-BR",
733+
nl,
726734
);
727735
mainGroup = CAD2E7952449574E00113D76;
728736
packageReferences = (
@@ -840,6 +848,7 @@
840848
CAA1CB45255A5B60003FD669 /* SignIn2FAView.swift in Sources */,
841849
CABFA9C52592EEEA00380FEE /* FileManager+.swift in Sources */,
842850
CABFA9CD2592EEEA00380FEE /* Foundation.swift in Sources */,
851+
36741BFF291E50F500A85AAE /* FileError.swift in Sources */,
843852
CA9FF8872595607900E47BAF /* InstalledXcode.swift in Sources */,
844853
53CBAB2C263DCC9100410495 /* XcodesAlert.swift in Sources */,
845854
CA42DD6E25AEA8B200BC0B0C /* Logger.swift in Sources */,
@@ -850,6 +859,7 @@
850859
CA9FF84E2595079F00E47BAF /* ScrollingTextView.swift in Sources */,
851860
CABFA9C12592EEEA00380FEE /* Version+.swift in Sources */,
852861
E8D655C0288DD04700A139C2 /* SelectedActionType.swift in Sources */,
862+
36741BFD291E4FDB00A85AAE /* DownloadPreferencePane.swift in Sources */,
853863
CA9FF8522595080100E47BAF /* AcknowledgementsView.swift in Sources */,
854864
CABFA9CE2592EEEA00380FEE /* Version+Xcode.swift in Sources */,
855865
CAFBDB912598FE80003DCC5A /* SelectedXcode.swift in Sources */,
@@ -937,6 +947,7 @@
937947
7CBF284E28606D2C001AA66B /* uk */,
938948
5AA8A6102877EDAD009ECDB0 /* fi */,
939949
327DF109286ABE6B00D694D5 /* pt-BR */,
950+
E2AFDCCA28F024D000864ADD /* nl */,
940951
);
941952
name = Localizable.strings;
942953
sourceTree = "<group>";

Xcodes/Backend/FileError.swift

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
//
2+
// FileError.swift
3+
// Xcodes
4+
//
5+
// Created by Leon Wolf on 06.10.22.
6+
// Copyright © 2022 Robots and Pencils. All rights reserved.
7+
//
8+
9+
import Foundation
10+
import LegibleError
11+
12+
enum FileError: LocalizedError{
13+
case fileNotFound(_ fileName: String)
14+
}
15+
16+
extension FileError {
17+
var errorDescription: String? {
18+
switch self {
19+
case .fileNotFound(let fileName):
20+
return String(format: localizeString("Alert.Uninstall.Error.Message.FileNotFound"), fileName)
21+
}
22+
}
23+
}

Xcodes/Backend/FileManager+.swift

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,11 @@ extension FileManager {
1111
@discardableResult
1212
func trashItem(at url: URL) throws -> URL {
1313
var resultingItemURL: NSURL!
14-
try trashItem(at: url, resultingItemURL: &resultingItemURL)
14+
if fileExists(atPath: url.path) {
15+
try trashItem(at: url, resultingItemURL: &resultingItemURL)
16+
} else {
17+
throw FileError.fileNotFound(url.lastPathComponent)
18+
}
1519
return resultingItemURL as URL
1620
}
17-
}
21+
}

Xcodes/Frontend/Preferences/AdvancedPreferencePane.swift

Lines changed: 9 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,16 @@ import Path
44

55
struct AdvancedPreferencePane: View {
66
@EnvironmentObject var appState: AppState
7-
8-
@AppStorage("dataSource") var dataSource: DataSource = .xcodeReleases
9-
@AppStorage("downloader") var downloader: Downloader = .aria2
107

118
var body: some View {
129
VStack(alignment: .leading, spacing: 20) {
13-
10+
1411
GroupBox(label: Text("InstallDirectory")) {
1512
VStack(alignment: .leading) {
1613
HStack(alignment: .top, spacing: 5) {
1714
Text(appState.installPath).font(.footnote)
18-
.fixedSize(horizontal: false, vertical: true)
19-
.lineLimit(2)
15+
.fixedSize(horizontal: false, vertical: true)
16+
.lineLimit(2)
2017
Button(action: { appState.reveal(path: appState.installPath) }) {
2118
Image(systemName: "arrow.right.circle.fill")
2219
}
@@ -34,7 +31,7 @@ struct AdvancedPreferencePane: View {
3431
panel.directoryURL = URL(fileURLWithPath: appState.installPath)
3532

3633
if panel.runModal() == .OK {
37-
34+
3835
guard let pathURL = panel.url, let path = Path(url: pathURL) else { return }
3936
self.appState.installPath = path.string
4037
}
@@ -50,8 +47,8 @@ struct AdvancedPreferencePane: View {
5047
VStack(alignment: .leading) {
5148
HStack(alignment: .top, spacing: 5) {
5249
Text(appState.localPath).font(.footnote)
53-
.fixedSize(horizontal: false, vertical: true)
54-
.lineLimit(2)
50+
.fixedSize(horizontal: false, vertical: true)
51+
.lineLimit(2)
5552
Button(action: { appState.reveal(path: appState.localPath) }) {
5653
Image(systemName: "arrow.right.circle.fill")
5754
}
@@ -69,7 +66,7 @@ struct AdvancedPreferencePane: View {
6966
panel.directoryURL = URL(fileURLWithPath: appState.localPath)
7067

7168
if panel.runModal() == .OK {
72-
69+
7370
guard let pathURL = panel.url, let path = Path(url: pathURL) else { return }
7471
self.appState.localPath = path.string
7572
}
@@ -102,44 +99,13 @@ struct AdvancedPreferencePane: View {
10299
Toggle("AutomaticallyCreateSymbolicLink", isOn: $appState.createSymLinkOnSelect)
103100
.disabled(appState.createSymLinkOnSelectDisabled)
104101
Text("AutomaticallyCreateSymbolicLinkDescription")
105-
.font(.footnote)
106-
.fixedSize(horizontal: false, vertical: true)
102+
.font(.footnote)
103+
.fixedSize(horizontal: false, vertical: true)
107104
}
108105
.fixedSize(horizontal: false, vertical: true)
109106
}
110107
.groupBoxStyle(PreferencesGroupBoxStyle())
111108

112-
GroupBox(label: Text("DataSource")) {
113-
VStack(alignment: .leading) {
114-
Picker("DataSource", selection: $dataSource) {
115-
ForEach(DataSource.allCases) { dataSource in
116-
Text(dataSource.description)
117-
.tag(dataSource)
118-
}
119-
}
120-
.labelsHidden()
121-
122-
AttributedText(dataSourceFootnote)
123-
}
124-
125-
}
126-
.groupBoxStyle(PreferencesGroupBoxStyle())
127-
128-
GroupBox(label: Text("Downloader")) {
129-
VStack(alignment: .leading) {
130-
Picker("Downloader", selection: $downloader) {
131-
ForEach(Downloader.allCases) { downloader in
132-
Text(downloader.description)
133-
.tag(downloader)
134-
}
135-
}
136-
.labelsHidden()
137-
138-
AttributedText(downloaderFootnote)
139-
}
140-
141-
}
142-
.groupBoxStyle(PreferencesGroupBoxStyle())
143109

144110
GroupBox(label: Text("PrivilegedHelper")) {
145111
VStack(alignment: .leading, spacing: 8) {
@@ -168,32 +134,6 @@ struct AdvancedPreferencePane: View {
168134
.groupBoxStyle(PreferencesGroupBoxStyle())
169135
}
170136
}
171-
172-
private var dataSourceFootnote: NSAttributedString {
173-
let string = localizeString("DataSourceDescription")
174-
let attributedString = NSMutableAttributedString(
175-
string: string,
176-
attributes: [
177-
.font: NSFont.preferredFont(forTextStyle: .footnote, options: [:]),
178-
.foregroundColor: NSColor.labelColor
179-
]
180-
)
181-
attributedString.addAttribute(.link, value: URL(string: "https://xcodereleases.com")!, range: NSRange(string.range(of: "Xcode Releases")!, in: string))
182-
return attributedString
183-
}
184-
185-
private var downloaderFootnote: NSAttributedString {
186-
let string = localizeString("DownloaderDescription")
187-
let attributedString = NSMutableAttributedString(
188-
string: string,
189-
attributes: [
190-
.font: NSFont.preferredFont(forTextStyle: .footnote, options: [:]),
191-
.foregroundColor: NSColor.labelColor
192-
]
193-
)
194-
attributedString.addAttribute(.link, value: URL(string: "https://github.com/aria2/aria2")!, range: NSRange(string.range(of: "aria2")!, in: string))
195-
return attributedString
196-
}
197137
}
198138

199139
struct AdvancedPreferencePane_Previews: PreviewProvider {
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
import AppleAPI
2+
import SwiftUI
3+
4+
struct DownloadPreferencePane: View {
5+
@EnvironmentObject var appState: AppState
6+
7+
@AppStorage("dataSource") var dataSource: DataSource = .xcodeReleases
8+
@AppStorage("downloader") var downloader: Downloader = .aria2
9+
10+
var body: some View {
11+
VStack(alignment: .leading) {
12+
GroupBox(label: Text("DataSource")) {
13+
VStack(alignment: .leading) {
14+
Picker("DataSource", selection: $dataSource) {
15+
ForEach(DataSource.allCases) { dataSource in
16+
Text(dataSource.description)
17+
.tag(dataSource)
18+
}
19+
}
20+
.labelsHidden()
21+
22+
AttributedText(dataSourceFootnote)
23+
}
24+
25+
}
26+
.groupBoxStyle(PreferencesGroupBoxStyle())
27+
28+
GroupBox(label: Text("Downloader")) {
29+
VStack(alignment: .leading) {
30+
Picker("Downloader", selection: $downloader) {
31+
ForEach(Downloader.allCases) { downloader in
32+
Text(downloader.description)
33+
.tag(downloader)
34+
}
35+
}
36+
.labelsHidden()
37+
38+
AttributedText(downloaderFootnote)
39+
}
40+
41+
}
42+
.groupBoxStyle(PreferencesGroupBoxStyle())
43+
44+
}
45+
}
46+
47+
private var dataSourceFootnote: NSAttributedString {
48+
let string = localizeString("DataSourceDescription")
49+
let attributedString = NSMutableAttributedString(
50+
string: string,
51+
attributes: [
52+
.font: NSFont.preferredFont(forTextStyle: .footnote, options: [:]),
53+
.foregroundColor: NSColor.labelColor
54+
]
55+
)
56+
attributedString.addAttribute(.link, value: URL(string: "https://xcodereleases.com")!, range: NSRange(string.range(of: "Xcode Releases")!, in: string))
57+
return attributedString
58+
}
59+
60+
private var downloaderFootnote: NSAttributedString {
61+
let string = localizeString("DownloaderDescription")
62+
let attributedString = NSMutableAttributedString(
63+
string: string,
64+
attributes: [
65+
.font: NSFont.preferredFont(forTextStyle: .footnote, options: [:]),
66+
.foregroundColor: NSColor.labelColor
67+
]
68+
)
69+
attributedString.addAttribute(.link, value: URL(string: "https://github.com/aria2/aria2")!, range: NSRange(string.range(of: "aria2")!, in: string))
70+
return attributedString
71+
}
72+
}
73+
74+
struct DownloadPreferencePane_Previews: PreviewProvider {
75+
static var previews: some View {
76+
Group {
77+
GeneralPreferencePane()
78+
.environmentObject(AppState())
79+
.frame(maxWidth: 500)
80+
}
81+
}
82+
}

Xcodes/Frontend/Preferences/PreferencesView.swift

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,11 @@ struct PreferencesView: View {
2121
Label("Updates", systemImage: "arrow.triangle.2.circlepath.circle")
2222
}
2323
.tag(Tabs.updates)
24+
DownloadPreferencePane()
25+
.environmentObject(appState)
26+
.tabItem {
27+
Label("Downloads", systemImage: "icloud.and.arrow.down")
28+
}
2429
AdvancedPreferencePane()
2530
.environmentObject(appState)
2631
.tabItem {

0 commit comments

Comments
 (0)