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

d3 1,2 #43

Open
wants to merge 5 commits into
base: translate
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
64 changes: 32 additions & 32 deletions 04-data-visualization/data-visualization-with-d3.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,43 +13,43 @@
}
],
"description": [
"D3 has several methods that let you add and change elements in your document.",
"The <code>select()</code> method selects one element from the document. It takes an argument for the name of the element you want and returns an HTML node for the first element in the document that matches the name. Here's an example:",
"D3 提供了多种方法让你添加或改变你的文本中的元素。",
Copy link
Contributor

Choose a reason for hiding this comment

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

请先细读翻译规范,这句话明显啰嗦。
D3 有多种方法可以用来在文档中增加元素、修改元素。
这里的 your 是代词,不用翻译的。

"<code>select()</code> 从文本中选择一个元素。 他的参数是你想选择的元素的名字,返回一个 HTML 结点给文本中第一个和这个名字匹配的元素。下面是一个例子:",
Copy link
Contributor

Choose a reason for hiding this comment

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

document => 文档
It => 它
你看这样翻译会不会流畅点:

 <code>select()</code>  方法用来从文档从选择元素,它以你想查询的元素名称作为参数,返回第一个符合条件的 HTML 节点。

Copy link
Contributor

Choose a reason for hiding this comment

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

后面也加了很多空格。

"<code>const anchor = d3.select(\"a\");</code>",
"The above example finds the first anchor tag on the page and saves an HTML node for it in the variable <code>anchor</code>. You can use the selection with other methods. The \"d3\" part of the example is a reference to the D3 object, which is how you access D3 methods.",
"Two other useful methods are <code>append()</code> and <code>text()</code>.",
"The <code>append()</code> method takes an argument for the element you want to add to the document. It appends an HTML node to a selected item, and returns a handle to that node.",
"The <code>text()</code> method either sets the text of the selected node, or gets the current text. To set the value, you pass a string as an argument inside the parentheses of the method.",
"Here's an example that selects an unordered list, appends a list item, and adds text:",
"上面这个例子找到页面上的第一个 a标签(锚标签), 在变量 <code>anchor</code> 中保存一个 HTML 结点。 你还可以用其他方法来选择。 例子中的 \"d3\" 是对 D3 对象的引用,可以通过他来访问 D3 的方法",
"其他两个很有用的方法是 <code>append()</code> <code>text()</code>",
"<code>append()</code> 的参数是你想添加到文本中的的元素。 他给选择的元素添加一个HTML结点, 返回那个结点的句柄。",
Copy link
Contributor

Choose a reason for hiding this comment

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

的的 => 的
他 => 它
document => 文档
这一段请重新翻译,行文不流畅。

Copy link
Author

@Mercy811 Mercy811 Aug 7, 2018

Choose a reason for hiding this comment

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

这样是否可行呢?
上面这个例子找到页面上的第一个a标签(锚标签),将它作为一个HTML结点保存在变量<code>anchor</code>中。你也可以用其他的方法选择页面上的元素。例子中的 \"d3\" 是对 D3 对象的引用,可以通过它来访问 D3 的方法。
还可以用<code>append()</code> 和 <code>text()</code> 方法。
<code>append()</code>方法以你想添加到文档中的元素作为参数,给选中的元素添加一个HTML结点,返回那个结点的句柄。
<code>text()</text>方法既可以给节点设置新的文本,也可以获取节点的当前文本。 如果要设置文字内容,需要在圆括号中传入一个string类型的参数。
这里是一个选择无序列表、添加列表项和文字的例子:

"<code>text()</text> 设置选中结点的文字内容或者得到当前的文字内容。 如果要设置文字内容,需要在圆括号中传入一个string类型的参数。",
Copy link
Contributor

Choose a reason for hiding this comment

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

method 总是自动忽略了,全局都有这个问题。
The text() method either sets the text of the selected node, or gets the current text.
text() 方法既可以给节点设置新的文本,也可以获取节点的当前文本。

"这里是一个例子。选择一个无序列表,添加列表项,添加文字:",
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

@Mercy811 Mercy811 Aug 7, 2018

Choose a reason for hiding this comment

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

是指中英文混用还是符号使用位置不当呢?
除去<code>中的使用英文符号,其他全部使用中文符号。

"<blockquote>d3.select(\"ul\")<br>&nbsp;&nbsp;.append(\"li\")<br>&nbsp;&nbsp;.text(\"Very important item\");</blockquote>",
"D3 allows you to chain several methods together with periods to perform a number of actions in a row.",
"D3 允许多个方法用英文句号串联来在一行中完成多个操作。",
"<hr>",
"Use the <code>select</code> method to select the <code>body</code> tag in the document. Then <code>append</code> an <code>h1</code> tag to it, and add the text \"Learning D3\" into the <code>h1</code> element."
],
"<code>select</code> 方法选择文本中的 <code>body</code>标签。 <code>append</code> 一个 <code>h1</code> 标签给它,同时在 <code>h1</code> 中添加文本 \"Learning D3\" "
],
Copy link
Contributor

Choose a reason for hiding this comment

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

去掉额外的空格。下同


这一条是描述挑战内容的,可以适当地加一些导语,而且整体也应通顺一些:

使用<code>select</code>方法选择文本中的<code>body</code>标签,然后用<code>append</code>方法为它添加一个<code>h1</code>标签,同时在<code>h1</code>中添加文本 \"Learning D3\"。

"tests": [
{
"text": "The <code>body</code> should have one <code>h1</code> element.",
"testString": "assert($('body').children('h1').length == 1, 'The <code>body</code> should have one <code>h1</code> element.');"
"text": "你的 <code>body</code> 元素应该包含元素 <code>h1</code> ",
"testString": "assert($('body').children('h1').length == 1, '你的 <code>body</code> 元素应该包含元素 <code>h1</code> ');"
},
{
"text": "The <code>h1</code> element should have the text \"Learning D3\" in it.",
"testString": "assert($('h1').text() == \"Learning D3\", 'The <code>h1</code> element should have the text \"Learning D3\" in it.');"
"text": "你的 <code>h1</code> 元素应该包含文本 \"Learning D3\" ",
"testString": "assert($('h1').text() == \"Learning D3\", '你的 <code>h1</code> 元素应该包含文本 \"Learning D3\" ');"
},
{
"text": "Your code should access the <code>d3</code> object.",
"testString": "assert(code.match(/d3/g), 'Your code should access the <code>d3</code> object.');"
"text": "你的代码应该能访问 <code>d3</code> 的对象。",
"testString": "assert(code.match(/d3/g), '你的代码应该能访问 <code>d3</code> 的对象。');"
},
{
"text": "Your code should use the <code>select</code> method.",
"testString": "assert(code.match(/\\.select/g), 'Your code should use the <code>select</code> method.');"
"text": "你的代码应该使用 <code>select</code> 方法。",
"testString": "assert(code.match(/\\.select/g), '你的代码应该使用 <code>select</code> 方法。');"
},
{
"text": "Your code should use the <code>append</code> method.",
"testString": "assert(code.match(/\\.append/g), 'Your code should use the <code>append</code> method.');"
"text": "你的代码应该使用 <code>append</code> 方法。",
"testString": "assert(code.match(/\\.append/g), '你的代码应该使用 <code>append</code> 方法。');"
},
{
"text": "Your code should use the <code>text</code> method.",
"testString": "assert(code.match(/\\.text/g), 'Your code should use the <code>text</code> method.');"
"text": "你的代码应该使用 <code>text</code> 方法。",
"testString": "assert(code.match(/\\.text/g), '你的代码应该使用 <code>text</code> 方法。');"
}
],
"solutions": [],
Expand Down Expand Up @@ -86,24 +86,24 @@
}
],
"description": [
"D3 also has the <code>selectAll()</code> method to select a group of elements. It returns an array of HTML nodes for all the items in the document that match the input string. Here's an example to select all the anchor tags in a document:",
"<code>selectAll()</code> 方法选择一组元素。 它以 HTML 结点数组的形式返回该文本中所有匹配所输入字符串的对象。 这里是一个选择文本中所有锚标签的例子:",
Copy link
Contributor

Choose a reason for hiding this comment

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

行文不流畅,请重新翻译。

"<code>const anchors = d3.selectAll(\"a\");</code>",
"Like the <code>select()</code> method, <code>selectAll()</code> supports method chaining, and you can use it with other methods.",
"像方法 <code>select()</code> 一样,<code>selectAll()</code> 也支持链式法则,你也可以用于其他方法。",
Copy link
Contributor

Choose a reason for hiding this comment

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

select() 方法一样

"<hr>",
"Select all of the <code>li</code> tags in the document, and change their text to \"list item\" by chaining the <code>.text()</code> method."
],
"选择所有的 <code>li</code> 标签,通过 <code>.text()</code> 方法将它的文本改为 \"list item\" 。"
],
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": "There should be 3 <code>li</code> elements on the page, and the text in each one should say \"list item\". Capitalization and spacing should match exactly.",
"testString": "assert($('li').text().match(/list item/g).length == 3, 'There should be 3 <code>li</code> elements on the page, and the text in each one should say \"list item\". Capitalization and spacing should match exactly.');"
"text": "页面上应该有3个 <code>li</code> 元素,每个元素的文本内容应为 \"list item\"。 大小写和空格必须一致。",
"testString": "assert($('li').text().match(/list item/g).length == 3, '页面上应该有3个 <code>li</code> 元素,每个元素的文本内容应为 \"list item\"。 大小写和空格必须一致。');"
},
{
"text": "Your code should access the <code>d3</code> object.",
"testString": "assert(code.match(/d3/g), 'Your code should access the <code>d3</code> object.');"
"text": "你的代码应该能访问 <code>d3</code> 的对象。",
"testString": "assert(code.match(/d3/g), '你的代码应该能访问 <code>d3</code> 的对象。');"
},
{
"text": "Your code should use the <code>selectAll</code> method.",
"testString": "assert(code.match(/\\.selectAll/g), 'Your code should use the <code>selectAll</code> method.');"
"text": "你的代码应该使用 <code>selectAll</code> 方法。",
"testString": "assert(code.match(/\\.selectAll/g), '你的代码应该使用 <code>selectAll</code> 方法。');"
}
],
"solutions": [],
Expand Down