-
Notifications
You must be signed in to change notification settings - Fork 5.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
1335: feat:翻译完 1335 Type Casting⭐️⭐️⭐️⭐️ #1377
base: swift-6-beta-translation
Are you sure you want to change the base?
1335: feat:翻译完 1335 Type Casting⭐️⭐️⭐️⭐️ #1377
Conversation
@Shinolr @brooklyn1999 有空请帮忙 Review Thx! |
(It's assumed that all media items, including all movies and songs, will have a name.) | ||
第一个代码片段定义了一个名为 `MediaItem` 的新基类。 | ||
该类为数字媒体库中出现的任何类型项目提供基本功能。 | ||
具体来说,它声明了一个字符串类型的 `name` 属性和一个 `init(name:)` 初始化器。 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NIT,“初始化器”在已有的翻译中是比较通用的说法了吗?另外String
这种类型关键字的翻译约定是保留还是不保留?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- 初始化器先保留了,最后看组织决定是用“构造器”还是“初始化器”。
- 除非是遇到翻译过来造成不通顺的情况,
String
这种关键字尽量保留吧
and queries the type of each item with a `switch` statement. | ||
Several of the `switch` statement's cases bind their matched value to | ||
a constant of the specified type to enable its value to be printed: | ||
`things` 数组包含两个 `Int` 值、两个 `Double` 值、一个 `String` 值、一个类型为 `(Double, Double)` 的元组、电影 “捉鬼敢死队”, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这里不要直译“电影捉鬼敢死队”,可以是“movie
实例”,名称翻不翻无所谓
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
我觉着这里可以用译名吧,因为原文用的不是字符串的直立引号"",我觉得翻译出来更容易读者理解(和安利)。
以及一个接收字符串值并返回另一个字符串值的闭包表达式。 | ||
|
||
|
||
如果常量或变量的已知类型是 `Any` 或 `AnyObject`,要确定其具体类型,可以在 switch 语句的情况下使用 `is` 或 `as` 模式。 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
switch-case中的case不应该翻译,应保留
@Pancf 可以再看一眼,没问题就 Approve Merge, Thx! |
原文地址:https://docs.swift.org/swift-book/documentation/the-swift-programming-language/typecasting/
Closes: #1335