Skip to content

Commit 8157ace

Browse files
committed
修改翻译指南
顺便改了下代码
1 parent 8f31283 commit 8157ace

File tree

3 files changed

+8
-14
lines changed

3 files changed

+8
-14
lines changed

tools/download.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
[返回主页](/README.md) | [Back to Main Page](/en/README.md)
1+
[返回主页](../README.md) / [Back to Main Page](../en/README.md)
22

33
# Videos
44

tools/main.swift

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ enum ResourceType: String, CustomStringConvertible {
2121
case readingAssignment = "Reading Assignment"
2222
case programmingProject = "Programming Project"
2323

24-
static let all: [ResourceType] = [.video, .slides, .demoCode, .readingAssignment, .programmingProject]
24+
static let all: LazyCollection<[ResourceType]> = [.video, .slides, .demoCode, .readingAssignment, .programmingProject].lazy
2525

2626
var description: String {
2727
switch self {
@@ -44,14 +44,8 @@ struct Resource: CustomStringConvertible {
4444

4545
if rawType.contains("video") {
4646
type = .video
47-
} else if title.contains("Reading Assignment") {
48-
type = .readingAssignment
49-
} else if title.contains("Programming Project") {
50-
type = .programmingProject
51-
} else if title.contains("Demo Code") {
52-
type = .demoCode
53-
} else if title.contains("Slides") {
54-
type = .slides
47+
} else if let resType = ResourceType.all.first(where: { title.contains($0.rawValue) }) {
48+
type = resType
5549
} else {
5650
fatalError("Unknown Raw Type")
5751
}
@@ -132,19 +126,19 @@ class ParsingDelegate: NSObject, XMLParserDelegate {
132126
}
133127

134128
func parserDidEndDocument(_ parser: XMLParser) {
135-
let sorted = ResourceType.all.map { type in
129+
let sorted = ResourceType.all.map { [resources] type in
136130
resources.filter { $0.type == type } .sorted { $0.index < $1.index }
137131
}
138132

139-
var out = "[返回主页](/README.md) | [Back to Main Page](/en/README.md)\n\n"
133+
var out = "[返回主页](../README.md) / [Back to Main Page](../en/README.md)\n\n"
140134
for (index, type) in ResourceType.all.enumerated() {
141135
if sorted[index].count > 0 {
142136
out += "# \(type)\n\n"
143137
+ "\(sorted[index].reduce("") { "\($0)\($1)\n" })\n"
144138
}
145139
}
146140

147-
let cwd = CommandLine.arguments.first { $0.contains("main.swift") } ?? FileManager.default.currentDirectoryPath
141+
let cwd = CommandLine.arguments.first { $0.contains(#file) } ?? FileManager.default.currentDirectoryPath
148142
let url = URL(fileURLWithPath: cwd).deletingLastPathComponent().appendingPathComponent("download.md")
149143
do {
150144
try out.write(to: url, atomically: true, encoding: .utf8)

translation-instructions.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
1. 请大家翻译和校对的时候尽量对照原视频,结合上下文,不要望文生义
66
2. 如保持英文顺序会影响中文理解,为保证行文流畅,应采用理解优先原则
7-
3. 在非讲师 Paul Hegarty 的对话前,请加 `-` 来区分。如:Question? -Is it ...
7+
3. 当说话的人变更时,请加 `>>` 来区分。如:Question? >> Is it? >> Yes.
88
4. 出现 Okay,All Right 等语气词,请结合上下文选择合适的翻译,或省略不翻
99
5. 学生提问的部分如果听不清楚,字幕也不全([INAUDIBLE]),但是老师回答时候把问题复述了一遍,字幕可译为 `-[学生提问]`
1010
6. 出现 [COUGH][LAUGH][NOISE][BLANK_AUDIO][INAUDIBLE] 等,请自行把握,可结合上下文选择省略不翻译

0 commit comments

Comments
 (0)