Skip to content

Translate ES6 #6

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

Closed
wants to merge 37 commits into from
Closed

Conversation

demongodYY
Copy link

@demongodYY demongodYY commented Jul 20, 2018

翻译章节

《算法和数据结构——ES6》

变更文件

  • es6.json

  • es6.md

翻译进度

  • 20%

  • 0%

@demongodYY
Copy link
Author

先提交一下,看下中间有没有什么错误或不标准的地方好及时修改.

@huluoyang
Copy link
Contributor

全角符号和半角符号混用的问题,比较常见,望今后注意。

@S1ngS1ng S1ngS1ng added the ready for review Use when a translation (?) PR is ready for review label Jul 20, 2018
Copy link
Contributor

@S1ngS1ng S1ngS1ng left a comment

Choose a reason for hiding this comment

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

  1. 翻译中请使用全角标点,且全角标点之后不应由多余的空格
  2. 如果 <code></code> 之后是中文字符,那应该添加空格;但如果是标点则不应添加
  3. 记得加上代码示例中注释部分的翻译

@huluoyang @wudifeixue 建议所有的关键字都加上 <code></code> 你们觉得呢?

@@ -8,33 +8,33 @@
"id": "587d7b87367417b2b2512b3f",
"title": "Explore Differences Between the var and let Keywords",
"description": [
"One of the biggest problems with declaring variables with the <code>var</code> keyword is that you can overwrite variable declarations without an error.",
"使用 <code>var</code> 关键字来声明变量,会出现重复声明导致变量被覆盖却不会报错的问题。",
Copy link
Contributor

Choose a reason for hiding this comment

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

请把逗号改成全角的。下同


另外,这一行是引出下文的,建议结尾用冒号

@@ -8,33 +8,33 @@
"id": "587d7b87367417b2b2512b3f",
"title": "Explore Differences Between the var and let Keywords",
"description": [
"One of the biggest problems with declaring variables with the <code>var</code> keyword is that you can overwrite variable declarations without an error.",
"使用 <code>var</code> 关键字来声明变量,会出现重复声明导致变量被覆盖却不会报错的问题。",
"<blockquote>var camper = 'James';<br>var camper = 'David';<br>console.log(camper);<br>// logs 'David'</blockquote>",
Copy link
Contributor

Choose a reason for hiding this comment

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

这里的注释,也翻译下吧。下同

Copy link
Author

Choose a reason for hiding this comment

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

请问是所有 desc ,test, files 的代码块里的注释都需要翻译吗?因为看到很多类似 \use strict 这一类的注释?

"Because this behavior does not throw an error, searching and fixing bugs becomes more difficult.<br>",
"A new keyword called <code>let</code> was introduced in ES6 to solve this potential issue with the <code>var</code> keyword.",
"If you were to replace <code>var</code> with <code>let</code> in the variable declarations of the code above, the result would be an error.",
"看上面的代码, <code>camper</code> 最初声明为 <code>James</code>,然后又被覆盖成了 <code>David</code>。",
Copy link
Contributor

Choose a reason for hiding this comment

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

原文 As you can see in the code above,这里的 see 不需要特意地翻译出来。
可以说 在上面的代码中, 或者 上面的代码


标点问题也请修改一下


建议这里不用“最初声明为”,改用“初始值为”


既然是字符串,个人建议这里写成 <code>'James'</code><code>'David'</code>
效果图:
image

"A new keyword called <code>let</code> was introduced in ES6 to solve this potential issue with the <code>var</code> keyword.",
"If you were to replace <code>var</code> with <code>let</code> in the variable declarations of the code above, the result would be an error.",
"看上面的代码, <code>camper</code> 最初声明为 <code>James</code>,然后又被覆盖成了 <code>David</code>。",
"在小型的应用中,你可能不会遇到这样的问题,但是当你的代码规模变得更加庞大的时候,就可能会在你不经意的时候产生变量的覆盖",
Copy link
Contributor

Choose a reason for hiding this comment

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

就可能会在你不经意的时候产生变量的覆盖 建议改成:
就可能会在不经意间覆盖了之前定义的变量。

注意结尾的句号

"If you were to replace <code>var</code> with <code>let</code> in the variable declarations of the code above, the result would be an error.",
"看上面的代码, <code>camper</code> 最初声明为 <code>James</code>,然后又被覆盖成了 <code>David</code>。",
"在小型的应用中,你可能不会遇到这样的问题,但是当你的代码规模变得更加庞大的时候,就可能会在你不经意的时候产生变量的覆盖",
"因为这样的行为并不会报错,导致 debug 变得更加困难。<br>",
Copy link
Contributor

Choose a reason for hiding this comment

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

两种说法:

  1. 这样的行为不会报错导致了 debug 非常困难。
  2. 因为这样的行为不会报错,所以当它出现时,debug 会非常困难。

你来决定吧

"<blockquote>var printNumTwo;<br>for (var i = 0; i < 3; i++) {<br>&nbsp;&nbsp;if(i === 2){<br>&nbsp;&nbsp;&nbsp;&nbsp;printNumTwo = function() {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return i;<br>&nbsp;&nbsp;&nbsp;&nbsp;};<br>&nbsp;&nbsp;}<br>}<br>console.log(printNumTwo());<br>// returns 3</blockquote>",
"As you can see, <code>printNumTwo()</code> prints 3 and not 2. This is because the value assigned to <code>i</code> was updated and the <code>printNumTwo()</code> returns the global <code>i</code> and not the value <code>i</code> had when the function was created in the for loop. The <code>let</code> keyword does not follow this behavior:",
"可以看到, <code>printNumTwo()</code> 打印了 3 而不是 2。 这是因为 <code>i</code> 发生了改变,并且函数 <code>printNumTwo()</code> 返回的是全局变量 <code>i</code>的值,而不是 for 循环中创建函数时 <code>i</code> 的值。The <code>let</code> 关键字就不会有这种现象:",
Copy link
Contributor

Choose a reason for hiding this comment

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

迷之 The 😂


这里的结尾应该用全角冒号

"<blockquote>'use strict';<br>let printNumTwo;<br>for (let i = 0; i < 3; i++) {<br>&nbsp;&nbsp;if (i === 2) {<br>&nbsp;&nbsp;&nbsp;&nbsp;printNumTwo = function() {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return i;<br>&nbsp;&nbsp;&nbsp;&nbsp;};<br>&nbsp;&nbsp;}<br>}<br>console.log(printNumTwo());<br>// returns 2<br>console.log(i);<br>// returns \"i is not defined\"</blockquote>",
"<code>i</code> is not defined because it was not declared in the global scope. It is only declared within the for loop statement. <code>printNumTwo()</code> returned the correct value because three different <code>i</code> variables with unique values (0, 1, and 2) were created by the <code>let</code> keyword within the loop statement.",
"<code>i</code> 在全局作用域中没有声明,所以它没有被定义, 它只会在 for 循环的语句中被声明。 因为在循环语句中的 <code>let</code>关键字创建了拥有独一无二的值 (0, 1, 或 2) 的三个不同 <code>i</code> 变量,所以 <code>printNumTwo()</code> 返回了正确的值。",
Copy link
Contributor

Choose a reason for hiding this comment

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

建议在不影响意思的前提下,尽量调整为主动语态。 @huluoyang

它只会在 <code>for</code> 循环的语句中被声明 => 它的声明只会发生在 <code>for</code> 循环内。


因为在循环语句中的 <code>let</code>关键字创建了拥有独一无二的值 (0, 1, 或 2) 的三个不同 <code>i</code> 变量 建议改成:
在循环执行的时候,<code>let</code> 关键字创建了三个不同的 <code>i</code> 变量,他们的值分别为 0、1 和 2

个人觉得这里补充说明一下可能会更好

"Fix the code so that <code>i</code> declared in the if statement is a separate variable than <code>i</code> declared in the first line of the function. Be certain not to use the <code>var</code> keyword anywhere in your code.",
"This exercise is designed to illustrate the difference between how <code>var</code> and <code>let</code> keywords assign scope to the declared variable. When programming a function similar to the one used in this exercise, it is often better to use different variable names to avoid confusion."
"修改这段代码,使得在 if 语句中声明的 <code>i</code> 变量与在函数的第一行声明的 <code>i</code> 变量是彼此独立的。 请注意不要在你的代码的任何地方使用 <code>var</code> 关键字。",
"这个练习说明了使用 <code>var</code> <code>let</code>关键字声明变量时,作用域之间的不同。当编写类似这个练习中的函数的时候,通常来说最好还是使用不同的变量名,用于避免困惑。"
Copy link
Contributor

Choose a reason for hiding this comment

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

使用不同的变量名,用于避免困惑。 建议改成:
使用不同的变量名来避免误会。

},
{
"text": "The variable <code>i</code> declared in the if statement should equal \"block scope\".",
"testString": "getUserInput => assert(getUserInput('index').match(/(i\\s*=\\s*).*\\s*.*\\s*.*\\1('|\")block\\s*scope\\2/g), 'The variable <code>i</code> declared in the if statement should equal \"block scope\".');"
"text": "在 if 语句中声明的 <code>i</code> 变量的值是 \"block scope\"。",
Copy link
Contributor

Choose a reason for hiding this comment

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

在 if 语句中声明的 <code>i</code> 变量的值是 \"block scope\"。 建议改成:
在 <code>if</code> 语句中声明的 <code>i</code> 变量的值应为 \"block scope\"。

},
{
"text": "<code>checkScope()</code> should return \"function scope\"",
"testString": "assert(checkScope() === \"function scope\", '<code>checkScope()</code> should return \"function scope\"');"
"text": "<code>checkScope()</code> 应当 返回 \"function scope\"",
Copy link
Contributor

Choose a reason for hiding this comment

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

请去掉多余的空格

@S1ngS1ng S1ngS1ng removed the ready for review Use when a translation (?) PR is ready for review label Jul 21, 2018
@demongodYY demongodYY changed the title translate 2 lessons on ES6 chapter translate for ES6 chapter Jul 22, 2018
@S1ngS1ng S1ngS1ng added ready for review Use when a translation (?) PR is ready for review comments addressed Use when a translation (?) PR has addressed all comments labels Jul 22, 2018
@huluoyang huluoyang changed the title translate for ES6 chapter Translate ES6 Jul 24, 2018
@huluoyang huluoyang added need update Use when a translation (?) PR has been reviewed and needs to address comments and removed comments addressed Use when a translation (?) PR has addressed all comments ready for review Use when a translation (?) PR is ready for review labels Jul 24, 2018
@demongodYY
Copy link
Author

请问是所有 desc ,test, files 的代码块里的注释都需要翻译吗?因为看到很多类似 \use strict 这一类的注释? @S1ngS1ng @huluoyang

@S1ngS1ng
Copy link
Contributor

@demongodYY desctests 的肯定要。files 里面翻译注释的部分,如果注释对做题是有帮助的。
use strict; 是 JS 关键字。https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Strict_mode

@demongodYY
Copy link
Author

@huluoyang md文件在哪里呀?

@S1ngS1ng
Copy link
Contributor

S1ngS1ng commented Jul 29, 2018

huluoyang and others added 22 commits July 30, 2018 09:58
…na#11)

* Translation of intermediate-algorithm-scripting, first half

* Address comments
* Add CONTRIBUTING.md, add guide of git

* address review comments

- Pick pull --rebase among three options
- Update guideline of resolving conflicts

* Add git FAQ. Remove labels def as for not needed

* Fix style issue, using HTML tags

* Update Details w/ GFM, fix wrong command

* Update FAQ with guide of resolving conflicts and clarification of git add . vs git add -A

* Update CONTRIBUTING.md

更新了下排版

* Update CONTRIBUTING.md

更改符号的使用

* Update CONTRIBUTING.md

continue fix some type error
Add a pattern that captures .vscode.*\.json, as provided by FreeCodeCampChina#7
* fix some typo error

* remove upcoming fileds

* resolve conflicts
Fix inline code in summary title that is not rendering
* translation 2/10

* translation 4/10

* translate assert & revise

* translation 2/10

* revise

* fix typo

* translation 2/10

* fix typo

* revise

* translate the document

* fix typo

* translate the title

* remove upcoming
* part1

* update previous & 2/5 finished

* space fix

* fix part1&part2 spacing
* 完成helmet第一小节翻译

* Finish 10%

* Remove IDE generated files

* Update according to comments
* finish 50% translation of object-oriented-programming

* modify translate

* change 对象 to  物体 in the real life.
* add: 完成BasicCSS的前4个教程。

* alter: 修改调整翻译中文。

* add: 继续翻译3小节。

* fixed: 修复语义,以及翻译格式。

* update: 替换空格&修改css class翻译。

* remove extra whitespace
* 01-responsive-web-design\css-grid.json is completed

* translatre Update 2018/7/23-11:00

* translate Updata 2018/7/23-11:10

* css-grid-cn.json updata no.2

* Del '-cn' files

* 'css-grid.json' Updata no.3

* css-grid.json updata no.4

* 'css-grid.md' Updata no.1

* css-grid.md updata no.2, .h空间’ changed to '间距'

* css-grid.json Updata change some punctuations

* 01-responsive-web-design\css-grid.json is completed

* translatre Update 2018/7/23-11:00

* translate Updata 2018/7/23-11:10

* css-grid-cn.json updata no.2

* Del '-cn' files

* css-grid.json updata no.4

* css-grid.json Updata change some punctuations

* css-grid.md updata 2018/7/27 22:13
* Update style guide, fixing format issue, adding anchor link in CONTRIBUTING.md and adding content

* Add em-dash style guide

* Add two more rules
@S1ngS1ng
Copy link
Contributor

@demongodYY 你这个 file change 太多啦。。考虑重开个 branch 吧,只保留你自己改过的 files 

@wudifeixue
Copy link

建议所有的关键字都加上<code></code>这个我不觉得是好事儿,这个一定要根据题来决定,我和我弟正在刷题能看到很多问题,但是关键字都加上<code></code>可以肯定不是好的选择。

@demongodYY
Copy link
Author

@S1ngS1ng 所以是要重新提个 PR 吗? T_T

@S1ngS1ng
Copy link
Contributor

S1ngS1ng commented Jul 30, 2018

@demongodYY 可以的,不会很麻烦。

# 获取 upstream 的 HEAD 指针
git fetch upstream

# 基于 upstream 的 translate branch 新建一个 branch
git checkout -b translate-es6 upstream/translate

# 由于你这个 PR 是基于你的 translate branch 开的,
# 所以把这个 branch 上属于你的文件改动应用到新的 branch 上
git checkout translate -- 02-javascript-algorithms-and-data-structures/es6.json
git checkout translate -- 02-javascript-algorithms-and-data-structures/es6.md

# 这个应该只输出你改过的两个文件才对
git status

# add、commit、push
git add .
git commit -m "Finish translation of ES6"
git push origin translate-es6

# 然后用这个新的 branch 再开 PR 就好了

上面显示你改了 60 多个文件,显然是不准确的嘛。
记得以后用 pull --rebase,就不会出现这样的问题了

@S1ngS1ng
Copy link
Contributor

@demongodYY 请参考 常见问题 的最后一条

@S1ngS1ng
Copy link
Contributor

S1ngS1ng commented Aug 1, 2018

Changes addressed in #51

@S1ngS1ng S1ngS1ng closed this Aug 1, 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.