-
Notifications
You must be signed in to change notification settings - Fork 32
Translate object-oriented-programming #12
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
Conversation
.gitignore
Outdated
|
||
# Sublime | ||
*.sublime-workspace | ||
|
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.
这个既然不是你的 changes,请把这个改动删掉,否则后续会很难管理。
记得以后使用 git pull --rebase
,就不会有这个问题了。
如果不确定如何操作,有空了微信我
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.
@XiaoLuo01 @huluoyang 考虑下:
我觉得,前面对实际生活的描述中,object
应该翻译成“物体”。毕竟object
本身就有这个意思。
或者可以加一句:
在英文中,object 既有“对象”又有“物体”的意思
你们觉得?
@XiaoLuo01 主要是通顺性的问题。改的时候多读几遍吧
"What are some qualities of these <code>objects</code>? A car has wheels. Shops sell items. Birds have wings.", | ||
"These qualities, or <code>properties</code>, define what makes up an <code>object</code>. Note that similar <code>objects</code> share the same <code>properties</code>, but may have different values for those <code>properties</code>. For example, all cars have wheels, but not all cars have the same number of wheels.", | ||
"<code>Objects</code> in JavaScript are used to model real-world objects, giving them <code>properties</code> and behavior just like their real-world counterparts. Here's an example using these concepts to create a <code>duck</code> <code>object</code>:", | ||
"想想我们在生活中每天都可见到的事物:比如汽车、商店以及小鸟等。这些都是 <code>对象</code>:所以对象就是这些人们可以观察和与之互动的实体事物。", |
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.
这些都是 <code>对象</code>
这里“是”之后不需要空格,因为“对象”也是全角字符。
下同
这里和下文的“对象”(包括评论中的),如果指的是实际生活中的东西,我觉得翻译成“物体”更合适。见 review comments
这里的 line comments,我就先用“对象”代替了
"想想我们在生活中每天都可见到的事物:比如汽车、商店以及小鸟等。这些都是 <code>对象</code>:所以对象就是这些人们可以观察和与之互动的实体事物。", | ||
"那么这些 <code>对象</code> 都有哪些特征呢?比如汽车的特征是有轮子,商店是用来出售商品的,而小鸟的特征是有翅膀。", | ||
"这些特征,或者说是 <code>属性</code> 定义了一个 <code>对象</code> 由什么构成的。需要注意的是:那些相似的 <code>对象</code> 可以拥有相同的 <code>属性</code>,但是这些 <code>属性</code> 可能会有不同的值。举个例子:所有的汽车都有轮子,但并不是所有汽车的轮子个数都是一样的。", | ||
"Javascript 中的 <code>对象</code> 被用来模拟现实世界中的对象,并赋予他们 <code>属性</code> 和行为,就像它们在现实世界中的对应物一样。下面是使用这些概念来创建一个 <code>duck</code> <code>对象</code> 的示例:", |
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.
"<blockquote>let duck = {<br> name: \"Aflac\",<br> numLegs: 2<br>};</blockquote>", | ||
"This <code>duck</code> <code>object</code> has two property/value pairs: a <code>name</code> of \"Aflac\" and a <code>numLegs</code> of 2.", | ||
"这个 <code>duck</code> <code>对象</code> 有两组键值对:一个是属性 <code>name</code> 的值是 \"Aflac\" 和 一个是属性 <code>numLegs</code> 的值是2。", |
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.
但这里翻译成“对象”,我觉得没问题
一个是属性 <code>name</code> 的值是 \"Aflac\" 和 一个是属性 <code>numLegs</code> 的值是2。
=>
一个是属性 <code>name</code>,它的值为 \"Aflac\";另一个是属性 <code>numLegs</code>,它的值是 2。
2
之前要加空格
"<hr>", | ||
"Create a <code>dog</code> <code>object</code> with <code>name</code> and <code>numLegs</code> properties, and set them to a string and a number, respectively." | ||
"创建一个 <code>dog</code> <code>对象</code>,并给这个对象添加两个属性:<code>name</code> 和 <code>numLegs</code>,同时分别给这两个属性设置一个字符串和数字。" |
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.
分别给这两个属性设置一个字符串和数字。
=>
把这两个属性的值分别设为字符串和数字。
], | ||
"tests": [ | ||
{ | ||
"text": "<code>dog</code> should be an <code>object</code>.", | ||
"testString": "assert(typeof(dog) === 'object', '<code>dog</code> should be an <code>object</code>.');" | ||
"text": "<code>dog</code> 应该就是一个 <code>object</code>。", |
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.
应该就是
=> 应该是
下一行也要改
"<hr>", | ||
"Write a <code>joinDogFraternity</code> function that takes a <code>candidate</code> parameter and, using the <code>constructor</code> property, return <code>true</code> if the candidate is a <code>Dog</code>, otherwise return <code>false</code>." | ||
"写一个 <code>joinDogFraternity</code> 函数,传入一个 <code>candidate</code> 参数并使用 <code>constructor</code> 属性来判断传入的 candidate 是不是 <code>Dog</code> 创建的对象实例,如果是返回 <code>true</code> 否则返回 <code>false</code>。" |
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.
如果是返回 <code>true</code> 否则返回 <code>false</code>。
=>
如果是,就返回 <code>true</code>,否则返回 <code>false</code>。
}, | ||
{ | ||
"text": "<code>joinDogFraternity</code> should use the <code>constructor</code> property.", | ||
"testString": "assert(/\\.constructor/.test(code) && !/instanceof/.test(code), '<code>joinDogFraternity</code> should use the <code>constructor</code> property.');" | ||
"text": "<code>joinDogFraternity</code> 应该要使用 <code>constructor</code> 属性。", |
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.
<code>joinDogFraternity</code> 应该要使用
=>
<code>joinDogFraternity</code> 中应该用到
?
下同
"<blockquote>Bird.prototype.numLegs = 2;</blockquote>", | ||
"This becomes tedious after more than a few properties.", | ||
"这将在添加许多属性的时候变得单调乏味的。", |
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.
变得单调乏味的
=> 变得单调乏味
"<blockquote>Bird.prototype.eat = function() {<br> console.log(\"nom nom nom\");<br>}<br><br>Bird.prototype.describe = function() {<br> console.log(\"My name is \" + this.name);<br>}</blockquote>", | ||
"A more efficient way is to set the <code>prototype</code> to a new object that already contains the properties. This way, the properties are added all at once:", | ||
"一种更有效的方法就是给对象的 <code>prototype</code> 设置为一个已经包含了属性的新对象。这样一来,所有属性都可以一次性被添加进来:", |
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.
删掉“被”
"<blockquote>Bird.prototype = {<br> numLegs: 2, <br> eat: function() {<br> console.log(\"nom nom nom\");<br> },<br> describe: function() {<br> console.log(\"My name is \" + this.name);<br> }<br>};</blockquote>", | ||
"<hr>", | ||
"Add the property <code>numLegs</code> and the two methods <code>eat()</code> and <code>describe()</code> to the <code>prototype</code> of <code>Dog</code> by setting the <code>prototype</code> to a new object." | ||
"通过给 <code>prototype</code> 设置为新对象的方法,给 <code>Dog</code> 构造函数的 <code>原型</code> 上添加一个属性 <code>numLegs</code> 和两个方法 <code>eat()</code> 、<code>describe()</code>。" |
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.
在……上
和两个方法 <code>eat()</code> 、<code>describe()</code>。
=>
以及两个方法:<code>eat()</code> 和 <code>describe()</code>。
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.
Thanks 👍

🎉 恭喜小罗的第一个PR成功进入仓库,keep moving! |
* finish 50% translation of object-oriented-programming * modify translate * change 对象 to 物体 in the real life.
* finish 50% translation of object-oriented-programming * modify translate * change 对象 to 物体 in the real life.
* finish 50% translation of object-oriented-programming * modify translate * change 对象 to 物体 in the real life.
翻译章节
《算法和数据结构——面向对象编程》
变更文件
object-oriented-programming.json
object-oriented-programming.md
翻译进度
40%
0%