-
Notifications
You must be signed in to change notification settings - Fork 34
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 Chapter of Typed Arrays #46
base: translate
Are you sure you want to change the base?
Translate Chapter of Typed Arrays #46
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
主要是格式的问题。请仔细读一下 style-guide
@@ -8,34 +8,34 @@ | |||
"id": "587d8253367417b2b2512c6a", | |||
"title": "Typed Arrays", | |||
"description": [ | |||
"Arrays are JavaScript objects that can hold a lot of different elements.", | |||
"数组是一种能存储各种数据类型的JavaScript对象。", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
JavaScript
两边要加空格。请参考 style-guide.md
翻译建议:数组是一种 JavaScript 对象,它可以存储多个不同类型的元素。
"<dfn>Typed arrays</dfn> are the answer to this problem. You are now able to say how much memory you want to give an array. Below is a basic overview of the different types of arrays available and the size in bytes for each element in that array.", | ||
"<table class='table table-striped'><tr><th>Type</th><th>Each element size in bytes</th></tr><tr><td><code>Int8Array</code></td><td>1</td></tr><tr><td><code>Uint8Array</code></td><td>1</td></tr><tr><td><code>Uint8ClampedArray</code></td><td>1</td></tr><tr><td><code>Int16Array</code></td><td>2</td></tr><tr><td><code>Uint16Array</code></td><td>2</td></tr><tr><td><code>Int32Array</code></td><td>4</td></tr><tr><td><code>Uint32Array</code></td><td>4</td></tr><tr><td><code>Float32Array</code></td><td>4</td></tr><tr><td><code>Float64Array</code></td><td>8</td></tr></table>", | ||
"There are two ways in creating these kind of arrays. One way is to create it directly. Below is how to create a 3 length <code>Int16Array</code>.", | ||
"通常浏览器会自动的为数组分配合适的内存空间,同时内存大小也会随着你增删元素而发生变化。", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
注意标点,请使用全角逗号
自动的为数组分配合适的内存空间
=> 自动地为数组分配合适的内存空间
注意 的
、地
、得
的区别
"通常浏览器会自动的为数组分配合适的内存空间,同时内存大小也会随着你增删元素而发生变化。", | ||
"然而,在一些对高性能有要求以及有不同数据类型的情况下,有时需要更精确地给一个数组分配内存空间。", | ||
"<dfn>Typed arrays</dfn> 就是解决这类问题的一种方案。 我们可以精确地给一个数组分配内存空间。如下列表说明了这种数组能够存放的数据类型以及不同数据类型所占据的字节数。", | ||
"<table class='table table-striped'><tr><th>类型</th><th>所占字节数</th></tr><tr><td><code>Int8Array</code></td><td>1</td></tr><tr><td><code>Uint8Array</code></td><td>1</td></tr><tr><td><code>Uint8ClampedArray</code></td><td>1</td></tr><tr><td><code>Int16Array</code></td><td>2</td></tr><tr><td><code>Uint16Array</code></td><td>2</td></tr><tr><td><code>Int32Array</code></td><td>4</td></tr><tr><td><code>Uint32Array</code></td><td>4</td></tr><tr><td><code>Float32Array</code></td><td>4</td></tr><tr><td><code>Float64Array</code></td><td>8</td></tr></table>", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
所占字节数
=> 元素所占字节数
会不会准确些?
"然而,在一些对高性能有要求以及有不同数据类型的情况下,有时需要更精确地给一个数组分配内存空间。", | ||
"<dfn>Typed arrays</dfn> 就是解决这类问题的一种方案。 我们可以精确地给一个数组分配内存空间。如下列表说明了这种数组能够存放的数据类型以及不同数据类型所占据的字节数。", | ||
"<table class='table table-striped'><tr><th>类型</th><th>所占字节数</th></tr><tr><td><code>Int8Array</code></td><td>1</td></tr><tr><td><code>Uint8Array</code></td><td>1</td></tr><tr><td><code>Uint8ClampedArray</code></td><td>1</td></tr><tr><td><code>Int16Array</code></td><td>2</td></tr><tr><td><code>Uint16Array</code></td><td>2</td></tr><tr><td><code>Int32Array</code></td><td>4</td></tr><tr><td><code>Uint32Array</code></td><td>4</td></tr><tr><td><code>Float32Array</code></td><td>4</td></tr><tr><td><code>Float64Array</code></td><td>8</td></tr></table>", | ||
"有两种方式可以创这类数组。其中一种是直接创建,如下代码创建了一个长度为3的 <code>Int16Array</code>.", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
3
两边要有空格。
"You can also create a <dfn>buffer</dfn> to assign how much data (in bytes) you want the array to take up.", | ||
"<strong>Note</strong><br>To create typed arrays using buffers, you need to assign the number of bytes to be a multiple of the bytes listed above.", | ||
"我们也可以通过创建 <dfn>buffer</dfn> 的方式来决定一个数组要容纳多少元素。", | ||
"<strong>提示</strong><br>我们可以通过分配对应长度字节数来创建一个和上方代码中一样的类型数组。", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
提示
应为 注意:
下同
注意,原文 a multiple of the bytes listed above
意思是 上面列出的 bytes 的倍数
,你的翻译 对应长度字节数
不够准确,请调整一下
"<blockquote>i8View[0] = 42;<br>console.log(i8View); // Returns [42, 0, 0]</blockquote>", | ||
"<strong>Note</strong><br>Typed arrays do not have some of the methods traditional arrays have such as <code>.pop()</code> or <code>.push()</code>. Typed arrays also fail <code>Array.isArray()</code> that checks if something is an array. Although simpler, this can be an advantage for less-sophisticated JavaScript engines to implement them.", | ||
"<strong>提示</strong><br>Typed Arrays并没有像 <code>.pop()</code> 或 <code>.push()</code>这些一般数组拥有的方法。 使用 <code>Array.isArray()</code> 方法对Typed Arrays做判断返回的是fail,而非true。因为更加简洁,所以更便于简化JavaScript引擎去实现这类数组。", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
注意,全角半角之间加空格。
全角句号之后不用加。
<code>
两边不加空格
请仔细阅读 style-guide
"<hr>", | ||
"First create a <code>buffer</code> that is 64-bytes. Then create a <code>Int32Array</code> typed array with a view of it called <code>i32View</code>." | ||
"先创建一个64个字节的 <code>buffer</code> , 再创建一个类型是 <code>Int32Array</code> 名称叫做 <code>i32View</code>的视图。" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
逗号之后多了个空格
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
请参考 https://github.com/FreeCodeCampChina/challenges/blob/translate/style-guide.md ,仔细检查一下你的翻译。
比如,<code>
两边不需要加空格,以及全角半角的加空格规则,这些规则都是全局适用的,不是只在给你 comment 的位置适用
"<blockquote>i8View[0] = 42;<br>console.log(i8View); // Returns [42, 0, 0]</blockquote>", | ||
"<strong>Note</strong><br>Typed arrays do not have some of the methods traditional arrays have such as <code>.pop()</code> or <code>.push()</code>. Typed arrays also fail <code>Array.isArray()</code> that checks if something is an array. Although simpler, this can be an advantage for less-sophisticated JavaScript engines to implement them.", | ||
"<strong>注意</strong><br>Typed Arrays并没有像<code>.pop()</code>或<code>.push()</code>这些一般数组拥有的方法。 使用 <code>Array.isArray()</code> 方法对Typed Arrays做判断返回的是fail,而非true。因为更加简洁,所以更便于简化JavaScript引擎去实现这类数组。", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这里的全角/半角之间也要加空格啊,<code>
不加空格的问题你只改了一部分,没有改全
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks 👍
Translate Chapter of Typed Arrays - By LXK