Skip to content
Closed
Changes from 4 commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
e5395a0
init translate
demongodYY Jul 19, 2018
bf25da2
first lesson translate
demongodYY Jul 19, 2018
3342d58
translate lesson 2
demongodYY Jul 19, 2018
0a37e22
fix comma error
demongodYY Jul 19, 2018
a05db5b
translate lesson 3
demongodYY Jul 22, 2018
36a6787
translate lesson 4
demongodYY Jul 22, 2018
e56a241
translate lesson 5
demongodYY Jul 22, 2018
4267806
fix issue errors,but not add annotation translate yet
demongodYY Jul 22, 2018
da09657
translate
demongodYY Jul 28, 2018
d080545
translate
demongodYY Jul 28, 2018
e42f5cf
fix
demongodYY Jul 28, 2018
e22a645
translate 10 11
demongodYY Jul 29, 2018
2681e72
translate 12,13
demongodYY Jul 29, 2018
589ce65
Update README.md
huluoyang Jul 18, 2018
ef148e5
Update README.md
Jul 18, 2018
2dad887
Update README.md
huluoyang Jul 19, 2018
7ea3f14
Update README.md
huluoyang Jul 19, 2018
5b08d48
translate html chapter to 40%
huluoyang Jul 21, 2018
8a9e928
translate chapter to 40%
huluoyang Jul 21, 2018
99ce5ce
add chapter introduce markdown file
huluoyang Jul 21, 2018
3bf748b
modify some file's name equal to it's json name filed
huluoyang Jul 21, 2018
177b569
fix some error
huluoyang Jul 22, 2018
f90315b
fix some typo error (#18)
huluoyang Jul 24, 2018
37fba7c
Add .gitignore, including patterns for OS, Vim, VSCode, Jetbrains and…
S1ngS1ng Jul 25, 2018
91a8634
Translation of intermediate-algorithm-scripting, 50% (#11)
S1ngS1ng Jul 26, 2018
8cf8e94
Add CONTRIBUTING.md (#15)
S1ngS1ng Jul 26, 2018
4a711dc
Update .gitignore that captures .vscode.*\.json (#28)
S1ngS1ng Jul 27, 2018
588c816
Fix (#29)
huluoyang Jul 27, 2018
3bd3606
(WIP) style-guide (#33)
S1ngS1ng Jul 28, 2018
60128e9
Translate managing-packages-with-npm (#1)
ifyour Jul 28, 2018
b0263b3
Translate responsive-web-design-projects (#2)
XERO75 Jul 28, 2018
0cac235
Translate information-security-with-helmet (#4)
stanleyyylau Jul 28, 2018
b35427d
Translate object-oriented-programming (#12)
XiaoLuo01 Jul 28, 2018
0fbaf7e
Translate basic-css (#17)
focus-kfc Jul 28, 2018
a1c16db
Css grid (#30)
stevending1st Jul 28, 2018
0c17ea8
responsive-web-design-principles translate (#35)
rainpure Jul 28, 2018
38a70b2
更新:翻译格式与建议 (#37)
S1ngS1ng Jul 29, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 32 additions & 32 deletions 02-javascript-algorithms-and-data-structures/es6.json
Original file line number Diff line number Diff line change
Expand Up @@ -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.

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


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

"<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 这一类的注释?

"As you can see in the code above, the <code>camper</code> variable is originally declared as <code>James</code> and then overridden to be <code>David</code>.",
"In a small application, you might not run into this type of problem, but when your code becomes larger, you might accidentally overwrite a variable that you did not intend to overwrite.",
"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

"在小型的应用中,你可能不会遇到这样的问题,但是当你的代码规模变得更加庞大的时候,就可能会在你不经意的时候产生变量的覆盖",
Copy link
Contributor

Choose a reason for hiding this comment

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

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

注意结尾的句号

"因为这样的行为并不会报错,导致 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 会非常困难。

你来决定吧

"在 ES6 中使用了新的关键字 <code>let</code> 来解决 <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.

在 ES6 中使用了新的关键字 建议改成:
ES6 引入了新的关键字


可能带来的问题。 建议改成:
带来的潜在问题。

potential 不是修饰 带来,而应该修饰 issue。因为 带来 已经实锤了,上面就证明过了

"如果你在上面的代码中,使用了 <code>let</code> 关键字来代替 <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.

<code>var</code> 之后应该有一个空格。


an error 也不必翻译成 一个报错,这里的 an 是泛指。

建议:

如果你在上面的代码中用 <code>let</code> 代替 <code>var</code> 关键字,那么就会出现报错。

"<blockquote>let camper = 'James';<br>let camper = 'David'; // throws an error</blockquote>",
"This error can be seen in the console of your browser.",
"So unlike <code>var</code>, when using <code>let</code>, a variable with the same name can only be declared once.",
"Note the <code>\"use strict\"</code>. This enables Strict Mode, which catches common coding mistakes and \"unsafe\" actions. For instance:",
"可以在可以在浏览器的控制台里看见这个错误。",
Copy link
Contributor

Choose a reason for hiding this comment

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

可以在可以在浏览器的控制台里看见这个错误。 =>
你可以在浏览器的控制台里看见这个错误。

"<code>var</code> 不同的是, 当使用 <code>let</code> 的时候,同一名字的变量只能被声明一次。",
"请注意 <code>\"use strict\"</code>。这代表着开启了严格模式, 用于检测常见的代码错误以及\"不安全\"的行为,例如:",
"<blockquote>\"use strict\";<br>x = 3.14; // throws an error because x is not declared</blockquote>",
"<hr>",
"Update the code so it only uses the <code>let</code> keyword."
"请更新这段代码,并且在其中只使用 <code>let</code> 关键字"
],
"tests": [
{
"text": "<code>var</code> does not exist in code.",
"testString": "getUserInput => assert(!getUserInput('index').match(/var/g),'<code>var</code> does not exist in code.');"
"text": "在代码中不应存在 <code>var</code>",
"testString": "getUserInput => assert(!getUserInput('index').match(/var/g),'在代码中不应存在 <code>var</code>');"
},
{
"text": "<code>catName</code> should be <code>Oliver</code>.",
"testString": "assert(catName === \"Oliver\", '<code>catName</code> should be <code>Oliver</code>.');"
"text": "<code>catName</code> 变量的值应该为 <code>Oliver</code>",
Copy link
Contributor

Choose a reason for hiding this comment

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

统一一下。既然底下你加上了引号,这里就也加上吧

"testString": "assert(catName === \"Oliver\", '<code><code>catName</code> 变量的值应该为 <code>\"Oliver\"</code>');"
},
{
"text": "<code>quote</code> should be <code>\"Oliver says Meow!\"</code>",
"testString": "assert(quote === \"Oliver says Meow!\", '<code>quote</code> should be <code>\"Oliver says Meow!\"</code>');"
"text": "<code>quote</code> 变量的值应该为 <code>\"Oliver says Meow!\"</code>",
"testString": "assert(quote === \"Oliver says Meow!\", '<code>quote</code> 变量的值应该为 <code>\"Oliver says Meow!\"</code>');"
}
],
"releasedOn": "Feb 17, 2017",
Expand Down Expand Up @@ -65,33 +65,33 @@
"id": "587d7b87367417b2b2512b40",
"title": "Compare Scopes of the var and let Keywords",
"description": [
"When you declare a variable with the <code>var</code> keyword, it is declared globally, or locally if declared inside a function.",
"The <code>let</code> keyword behaves similarly, but with some extra features. When you declare a variable with the <code>let</code> keyword inside a block, statement, or expression, its scope is limited to that block, statement, or expression.",
"For example:",
"当你使用 <code>var</code> 关键字来声明一个变量的时候,这个变量会被声明成全局变量,或是函数内的局部变量。",
"<code>let</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.

请去掉全角句号后多余的空格


注意语序

当你使用 <code>let</code> 关键字在代码块,语句或者表达式里声明变量的时候, => 如果你在代码块、语句或表达式中使用关键字 <code>let</code> 声明变量,


就在 => 就被限制在

"举个例子:",
"<blockquote>var numArray = [];<br>for (var i = 0; i < 3; i++) {<br>&nbsp;&nbsp;numArray.push(i);<br>}<br>console.log(numArray);<br>// returns [0, 1, 2]<br>console.log(i);<br>// returns 3</blockquote>",
Copy link
Contributor

Choose a reason for hiding this comment

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

这里的注释也记得加上翻译哈。下同

"With the <code>var</code> keyword, <code>i</code> is declared globally. So when <code>i++</code> is executed, it updates the global variable. This code is similar to the following:",
"当使用 <code>var</code> 关键字的时候, <code>i</code> 会被声明成全局变量。 当 <code>i++</code> 执行的时候, 它会改变全局变量的值。 这段代码可以看做下面这样:",
"<blockquote>var numArray = [];<br>var i;<br>for (i = 0; i < 3; i++) {<br>&nbsp;&nbsp;numArray.push(i);<br>}<br>console.log(numArray);<br>// returns [0, 1, 2]<br>console.log(i);<br>// returns 3</blockquote>",
"This behavior will cause problems if you were to create a function and store it for later use inside a for loop that uses the <code>i</code> variable. This is because the stored function will always refer to the value of the updated global <code>i</code> variable.",
"这个行为在你一个创建函数用来存储在 for 循环中使用的 <code>i</code> 变量的时候,会出现问题。这是因为函数存储的值会因为全局变量 <code>i</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>for</code> 循环中创建了使用 <code>i</code> 变量的函数,那么在后续调用函数的时候,上面提到的这种行为就会导致问题。

"<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

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

"<hr>",
"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.

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

],
"tests": [
{
"text": "<code>var</code> does not exist in code.",
"testString": "getUserInput => assert(!getUserInput('index').match(/var/g),'<code>var</code> does not exist in code.');"
"text": "<code>var</code> 不应该在代码中存在。",
"testString": "getUserInput => assert(!getUserInput('index').match(/var/g),'<code>var</code> 不应该在代码中存在。');"
},
{
"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\"。

"testString": "getUserInput => assert(getUserInput('index').match(/(i\\s*=\\s*).*\\s*.*\\s*.*\\1('|\")block\\s*scope\\2/g), '在 if 语句中声明的 <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.

请去掉多余的空格

"testString": "assert(checkScope() === \"function scope\", '<code>checkScope()</code> 应该返回 \"function scope\"');"
}
],
"releasedOn": "Feb 17, 2017",
Expand Down Expand Up @@ -1362,4 +1362,4 @@
}
}
]
}
}