Skip to content

1-js/05-data-types/07-map-set/#589

Merged
leviding merged 6 commits intojavascript-tutorial:masterfrom
bemself:map-85e67eb
Feb 17, 2020
Merged

1-js/05-data-types/07-map-set/#589
leviding merged 6 commits intojavascript-tutorial:masterfrom
bemself:map-85e67eb

Conversation

@bemself
Copy link
Copy Markdown
Collaborator

@bemself bemself commented Jan 14, 2020

你所看到的是一个 Pull Request 模板。(请删除此行,并请按实际情况修改下面内容,然后提交~)

目标章节:1-js/05-data-types/07-map-set/

当前上游最新 commit:*

所做更改如下:

文件名 参考上游 commit 更改(理由)
limitations.png 85e67eb 增改新翻译,修正一些格式问题

@javascript-translate-bot javascript-translate-bot requested a review from a team January 14, 2020 14:36
@bemself bemself added the WIP Work in process label Jan 14, 2020
@bemself bemself removed the WIP Work in process label Jan 17, 2020
@bemself bemself marked this pull request as ready for review January 17, 2020 13:56
Copy link
Copy Markdown
Collaborator

@KerbalHao KerbalHao left a comment

Choose a reason for hiding this comment

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

感谢翻译,校对完成

Comment thread 1-js/05-data-types/07-map-set/article.md
Comment thread 1-js/05-data-types/07-map-set/article.md Outdated
```

如果我们有个纯对象, 并且想利用这个纯对象来创建 `Map`, 可以使用内建方法 [Object.entries(obj)](mdn:js/Object/entries),它返回一个具有相同格式的并且带有键值对的数组对象
如果我们想从一个已有的普通对象来创建 `Map`,可以使用内置方法 [Object.entries(obj)](mdn:js/Object/entries),它返回一个该类型对象的键值对数组 //TODO
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

  1. [普通对象] -> [简单对象],我查了一下,网上对于 [plain object] 好像都翻译为 [简单对象],我觉得这里可以这样写
  2. [它返回一个该类型对象的键值对数组 //TODO] -> [它返回一个对象的键值对数组,该数组符合 Map 集合的格式],这里这样翻译您觉得合适吗?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

@KerbalHao 惭愧忘记了我标了 TODO 的这个地方,感谢翻译,我改一下

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

@KerbalHao

网上对于 [plain object] 好像都翻译为 [简单对象]
我查了下 MDN,好像没有 plain object 的对应翻译,你这边一般查的是哪里呢?

这个”简单对象“我感觉会比较有歧义,因为有简单就会有复杂,会造成还有复杂对象的错觉,所以我用了普通对象。不过我 js 不熟,这里的上下文是否内含了简单和复杂的意思呢?

[普通对象] -> [简单对象],我查了一下,网上对于 [plain object] 好像都翻译为 [简单对象],我觉得这里可以这样写

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

@KerbalHao 不好意思更正一下,感觉还是你说的”简单对象“对着呢。

我查了一下 [1-js/08-prototypes/04-prototype-methods/article.md),这里似乎解释了, regular plain object,看来 plain 还是和 regular 有区别的。

We can call such objects "very plain" or "pure dictionary" objects, because they are even simpler than the regular plain object {...}.

不过现在其他 article 中也有类似的 plain object,大概看了下,有译作简单对象的,也有译作普通对象的,不太统一,请教@leviding

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

@leviding 大佬,有空的话,麻烦看看这边?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@KerbalHao @bemself 这种没有统一翻译的,翻译了会有歧义的,就全用英文?

## Object.fromEntries:把 `map` 转化为对象

我们刚刚已经利用 `Object.entries(obj)` 把一个纯对象转化成 `Map`
我们刚刚已经利用 `Object.entries(obj)` 把一个普通对象转化成 `Map`
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

[普通对象] -> [简单对象]

```

我们可以使用 `Object.fromEntries` 从 `Map` 中得到一个纯对象
我们可以使用 `Object.fromEntries` 从 `Map` 中得到一个普通对象
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

[普通对象] -> [简单对象]

我们可以使用 `Object.fromEntries` 从 `Map` 中得到一个普通对象

例如, 我们存了数据在 `Map` 中, 但是我们需要把它转给需要纯对象的第三方代码
例如,我们存了数据在 `Map` 中,但是我们需要把它传给需要普通对象的第三方代码
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

[普通对象] -> [简单对象]


*!*
let obj = Object.fromEntries(map.entries()); // make a plain object (*)
let obj = Object.fromEntries(map.entries()); // 生成一个普通对象 (*)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

[普通对象] -> [简单对象]

```

上面的代码作用也是一样的, 因为 `Object.fromEntries` 需要一个可迭代对象作为参数, 而一定是数组. `map` 的标准迭代会返回跟 `map.entries()` 一样的键值对. 所以我们可以获得一个与 `Map` 一样具有键值对的纯对象
上面的代码作用也是一样的因为 `Object.fromEntries` 需要一个可迭代对象作为参数,而不一定是数组。`map` 的标准迭代会返回跟 `map.entries()` 一样的键值对所以我们可以获得一个与 `map` 一样具有键值对的普通对象
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

[普通对象] -> [简单对象]

Comment thread 1-js/05-data-types/07-map-set/article.md Outdated
@javascript-translate-bot
Copy link
Copy Markdown

Please make the requested changes. After it, add a comment "/done".
Then I'll ask for a new review 👻

@leviding
Copy link
Copy Markdown
Member

目前 plain object 没有好的翻译,就保留原文把,已修改,我合并了哈,两位辛苦啦!

@leviding leviding merged commit 53f9434 into javascript-tutorial:master Feb 17, 2020
@leviding leviding added DONE and removed needs +1 labels Feb 17, 2020
@bemself bemself deleted the map-85e67eb branch February 17, 2020 14:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants