From 16a7a42dfa7c6dac75bdb0f6bdd4e2c6c7729350 Mon Sep 17 00:00:00 2001 From: sqrtthree Date: Mon, 9 Apr 2018 22:10:11 +0800 Subject: [PATCH 1/4] Transfer the existing translation, ready for review Co-authored-by: maoxiaoke resolve #2 --- 1-js/02-first-steps/01-hello-world/article.md | 76 +++++++++---------- 1 file changed, 38 insertions(+), 38 deletions(-) diff --git a/1-js/02-first-steps/01-hello-world/article.md b/1-js/02-first-steps/01-hello-world/article.md index 69d2ba976a..c1b274be12 100644 --- a/1-js/02-first-steps/01-hello-world/article.md +++ b/1-js/02-first-steps/01-hello-world/article.md @@ -1,17 +1,18 @@ # Hello, world! -The tutorial that you're reading is about core JavaScript, which is platform-independent. Further on, you will learn Node.JS and other platforms that use it. +你现在所阅读的这个教程是 JavaScript 的核心内容,这部分内容是平台无关的。接下来,你将会学习 Node.JS 以及使用 Node.JS 的其他平台。 -But, we need a working environment to run our scripts, and, just because this book is online, the browser is a good choice. We'll keep the amount of browser-specific commands (like `alert`) to a minimum, so that you don't spend time on them if you plan to concentrate on another environment like Node.JS. On the other hand, browser details are explained in detail in the [next part](/ui) of the tutorial. +但是,我们需要一个工作环境来运行代码,由于本书是在线的,所以浏览器是一个不错的选择。我们会尽可能少地使用浏览器特定的命令(比如 `alert` ),所以如果你打算使用如 Node.JS 的其他环境,你不必多花时间来关心这些特定指令。另一方面,浏览器的具体细节我们会在教程的[下一部分](/ui)介绍。 -So first, let's see how to attach a script to a webpage. For server-side environments, you can just execute it with a command like `"node my.js"` for Node.JS. +首先,让我们看看如何将脚本添加到网页上。对于服务器端环境,你只需要使用诸如 `"node my.js"` 的 Node.JS 的命令行来执行它。 +[cut] -## The "script" tag +## "script" 标签 -JavaScript programs can be inserted in any part of an HTML document with the help of the ` ``` - These comments were supposed to hide the code from an old browser that didn't know about a ` ``` -Here `/path/to/script.js` is an absolute path to the file with the script (from the site root). +这里 ,`/path/to/script.js` 是脚本文件的绝对路径(从站点根目录开始)。 -It is also possible to provide a path relative to the current page. For instance, `src="script.js"` would mean a file `"script.js"` in the current folder. +也可以提供相对于当前页面的相对路径。比如,`src="script.js"` 意思是来自当前文件夹的 `"script.js"` 文件。 -We can give a full URL as well, for instance: +我们还可以提供一个完整的 URL 地址,例如: ```html ``` -To attach several scripts, use multiple tags: +附加多个脚本,使用多个标签: ```html @@ -93,19 +93,19 @@ To attach several scripts, use multiple tags: ``` ```smart -As a rule, only the simplest scripts are put into HTML. More complex ones reside in separate files. +一般来说,只有最简单的脚本才嵌入到 HTML。 更复杂的脚本存放在单独的文件中。 -The benefit of a separate file is that the browser will download it and then store in its [cache](https://en.wikipedia.org/wiki/Web_cache). +使用独立文件的好处是浏览器会下载它,然后将它保存到浏览器的[缓存](https://en.wikipedia.org/wiki/Web_cache)中。 -After this, other pages that want the same script will take it from the cache instead of downloading it. So the file is actually downloaded only once. +之后,其他页面想要相同的脚本就会从缓存中获取,而不是下载它。所以文件实际上只会下载一次。 -That saves traffic and makes pages faster. +这可以节省流量,并使得页面更快。 ``` -````warn header="If `src` is set, the script content is ignored." -A single ` ``` -We must choose: either it's an external ` @@ -125,11 +125,11 @@ The example above can be split into two scripts to work: ``` ```` -## Summary +## 总结 -- We can use a ``. +- 我们可以使用一个 `` 这种方式插入。 -There is much more to learn about browser scripts and their interaction with the web-page. But let's keep in mind that this part of the tutorial is devoted to the JavaScript language, so we shouldn't distract ourselves from it. We'll be using a browser as a way to run JavaScript, which is very convenient for online reading, but yet one of many. +有关浏览器脚本以及它们和网页的关系,还有很多可学的。但是请记住,这部分教程主要是针对 JavaScript 语言的,所以我们不该分散自己的注意力。我们使用浏览器作为运行 JavaScript 的一种方式,非常便于我们在线阅读。 From c520710f821a62672645f996a57448f931e9814b Mon Sep 17 00:00:00 2001 From: sqrtthree Date: Tue, 17 Apr 2018 12:20:40 +0800 Subject: [PATCH 2/4] fix(hello-world): Adjust some contents --- 1-js/02-first-steps/01-hello-world/article.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/1-js/02-first-steps/01-hello-world/article.md b/1-js/02-first-steps/01-hello-world/article.md index c1b274be12..857adab8f1 100644 --- a/1-js/02-first-steps/01-hello-world/article.md +++ b/1-js/02-first-steps/01-hello-world/article.md @@ -6,7 +6,6 @@ 首先,让我们看看如何将脚本添加到网页上。对于服务器端环境,你只需要使用诸如 `"node my.js"` 的 Node.JS 的命令行来执行它。 -[cut] ## "script" 标签 @@ -20,7 +19,7 @@ JavaScript 程序可以使用 ` */!* -

...After the script.

+

...script 标签之后

@@ -42,15 +41,16 @@ JavaScript 程序可以使用 ` ``` - 这些注释被不知道什么是 ` ``` - 这些注释被不知道什么是 `