Skip to content
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

translate Object Oriented Programming - 100% #61

Open
wants to merge 2 commits into
base: translate
Choose a base branch
from

Conversation

XiaoLuo01
Copy link
Contributor

Translate Object Oriented Programming comlete

@XiaoLuo01 XiaoLuo01 changed the title translate complete 100% translate Object Oriented Programming - 100% Aug 5, 2018
Copy link
Contributor

@huluoyang huluoyang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

感谢小罗的辛苦付出。
对于符号的使用和意译的把握还有待加强。
建议先细看 wiki 中的 Style Guide,对你提升巨大。

"<blockquote>console.log(duck.constructor)<br>// prints ‘undefined’ - Oops!</blockquote>",
"To fix this, whenever a prototype is manually set to a new object, remember to define the <code>constructor</code> property:",
"<blockquote>Bird.prototype = {<br>&nbsp;&nbsp;constructor: Bird, // define the constructor property<br>&nbsp;&nbsp;numLegs: 2,<br>&nbsp;&nbsp;eat: function() {<br>&nbsp;&nbsp;&nbsp;&nbsp;console.log(\"nom nom nom\");<br>&nbsp;&nbsp;},<br>&nbsp;&nbsp;describe: function() {<br>&nbsp;&nbsp;&nbsp;&nbsp;console.log(\"My name is \" + this.name); <br>&nbsp;&nbsp;}<br>};</blockquote>",
"如果我们手动的给一个新对象重新设置<code>原型</code>的话,这将会产生一个重要的副作用:删除了<code>constructor</code>属性!所以在上一个挑战中,我们将<code>duck</code>的<code>constructor</code>属性输出到控制台的话将会得到以下结果:",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

一句话2个的,你懂的。
整个段落的翻译很生硬,不流畅。
重点把握好:It erased the constructor property

"<blockquote>Bird.prototype = {<br>&nbsp;&nbsp;constructor: Bird, // define the constructor property<br>&nbsp;&nbsp;numLegs: 2,<br>&nbsp;&nbsp;eat: function() {<br>&nbsp;&nbsp;&nbsp;&nbsp;console.log(\"nom nom nom\");<br>&nbsp;&nbsp;},<br>&nbsp;&nbsp;describe: function() {<br>&nbsp;&nbsp;&nbsp;&nbsp;console.log(\"My name is \" + this.name); <br>&nbsp;&nbsp;}<br>};</blockquote>",
"如果我们手动的给一个新对象重新设置<code>原型</code>的话,这将会产生一个重要的副作用:删除了<code>constructor</code>属性!所以在上一个挑战中,我们将<code>duck</code>的<code>constructor</code>属性输出到控制台的话将会得到以下结果:",
"<blockquote>console.log(duck.constructor)<br>// 哎呀,控制台中输出了 ‘undefined’!</blockquote>",
"为了解决这个问题,所以凡是原型被手动设置给了一个新对象,都要记得重新定义一个<code>constructor</code>属性:",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

所以从何而来?语句不通。

@@ -725,17 +725,17 @@
"id": "587d7db0367417b2b2512b81",
"title": "Understand Where an Object’s Prototype Comes From",
"description": [
"Just like people inherit genes from their parents, an object inherits its <code>prototype</code> directly from the constructor function that created it. For example, here the <code>Bird</code> constructor creates the <code>duck</code> object:",
"就像人们从父母那里继承基因一样,对象也可直接从创建它的构造函数那里继承其<code>原型。请看下面的例子:<code>Bird</code>构造函数创建了一个<code>duck</code>对象:",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

此处的 code 缺少闭合标签,而且 code 里面的应该保持原文输出。

"<blockquote>function Bird(name) {<br>&nbsp;&nbsp;this.name = name;<br>}<br><br>let duck = new Bird(\"Donald\");</blockquote>",
"<code>duck</code> inherits its <code>prototype</code> from the <code>Bird</code> constructor function. You can show this relationship with the <code>isPrototypeOf</code> method:",
"<blockquote>Bird.prototype.isPrototypeOf(duck);<br>// returns true</blockquote>",
"<code>duck</code>对象继承了<code>Bird</code>构造函数的<code>原型</code>。你可以使用<code>isPrototypeOf</code>方法来验证他们原型之间的关系:",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

duckBird构造函数那里继承了它的prototype,你可以使用isPrototypeOf方法来验证他们之间的关系:

"<hr>",
"Use <code>isPrototypeOf</code> to check the <code>prototype</code> of <code>beagle</code>."
"使用<code>isPrototypeOf</code>方法验证<code>beagle</code><code>原型</code>是否继承了<code>Bird</code>构造函数的<code>原型</code>。"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

code 里面原文输出即可

],
"tests": [
{
"text": "Your code should declare a <code>glideMixin</code> variable that is a function.",
"testString": "assert(typeof glideMixin === \"function\", 'Your code should declare a <code>glideMixin</code> variable that is a function.');"
"text": "你的代码应该声明一个变量名为<code>glideMixin</code>的函数。",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

你的代码应该声明一个变量名为glideMixin的函数。 => 啰嗦
你应该声明一个变量名为glideMixin的函数。=> 简洁
这个问题全文都有,请自行斟酌后修改。

"The simplest way to make properties private is by creating a variable within the constructor function. This changes the scope of that variable to be within the constructor function versus available globally. This way, the property can only be accessed and changed by methods also within the constructor function.",
"<blockquote>function Bird() {<br>&nbsp;&nbsp;let hatchedEgg = 10; // private property<br><br>&nbsp;&nbsp;this.getHatchedEggCount = function() { // publicly available method that a bird object can use<br>&nbsp;&nbsp;&nbsp;&nbsp;return hatchedEgg;<br>&nbsp;&nbsp;};<br>}<br>let ducky = new Bird();<br>ducky.getHatchedEggCount(); // returns 10</blockquote>",
"Here <code>getHachedEggCount</code> is a privileged method, because it has access to the private variable <code>hatchedEgg</code>. This is possible because <code>hatchedEgg</code> is declared in the same context as <code>getHachedEggCount</code>. In JavaScript, a function always has access to the context in which it was created. This is called <code>closure</code>.",
"因此,你代码的任何部分都可以轻松地将<code>bird</code>的 name 属性更改为任意值。想想密码和银行账户之类的东西,如果你代码库的任何部分都可以轻易改变,那么将会引起很多问题。",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

你代码 什么意思?


At its core, software development solves a problem or achieves a result with computation. The software development process first defines a problem, then presents a solution. Object oriented programming is one of several major approaches to the software development process.
软件开发的核心是通过计算解决问题或取得结果。软件开发过程首先定义问题,然后提出解决方案。面向对象编程是软件开发过程的几种主要方法之一。
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这是我直接从有道翻译的结果,你对比下:
软件开发的核心是解决问题或通过计算获得结果。软件开发过程首先定义一个问题,然后提出一个解决方案。面向对象编程是软件开发过程的几种主要方法之一。


The object structure makes it flexible within a program. Objects can transfer information by calling and passing data to another object's methods. Also, new classes can receive, or inherit, all the features from a base or parent class. This helps to reduce repeated code.
对象结构使它在程序中变得灵活。对象可以通过调用数据并将数据传递给另一个对象的方法来传递信息。此外,新类可以从基类或父类接收或继承所有功能。这有助于减少重复代码。
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

全是句号


Your choice of programming approach depends on a few factors. These include the type of problem, as well as how you want to structure your data and algorithms. This section covers object oriented programming principles in JavaScript.
你对编程方法的选择取决于几个因素。这些包括问题的类型,以及如何构造数据和算法。本节将介绍 JavaScript 中面向对象的编程原则。
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

符号的使用

@huluoyang huluoyang added the need update Use when a translation (?) PR has been reviewed and needs to address comments label Aug 8, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
need update Use when a translation (?) PR has been reviewed and needs to address comments
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants