Skip to content

Translate mongodb-and-mongoose#16

Open
jiangyuzhen wants to merge 4 commits into
FreeCodeCampChina:translatefrom
jiangyuzhen:translate
Open

Translate mongodb-and-mongoose#16
jiangyuzhen wants to merge 4 commits into
FreeCodeCampChina:translatefrom
jiangyuzhen:translate

Conversation

@jiangyuzhen
Copy link
Copy Markdown

@jiangyuzhen jiangyuzhen commented Jul 23, 2018

翻译章节

《API 与 微服务—— MongoDB 和 Mongoose》

变更文件

  • mongodb-and-mongoose.json

  • mongodb-and-mongoose.md

翻译进度

  • 25%

  • 0%

"title": "Install and Set Up Mongoose",
"description": [
"Add mongodb and mongoose to the project’s package.json. Then require mongoose. Store your mLab database URI in the private .env file as MONGO_URI. Connect to the database using mongoose.connect(<Your URI>)"
"Add mongodb and mongoose to the project’s package.json. Then require mongoose. Store your mLab database URI in the private .env file as MONGO_URI. Connect to the database using mongoose.connect(<Your URI>)",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

这里覆盖掉英文 😁

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

意思是采用覆盖的方式,不是 copy 的方式?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

是的是的

Copy link
Copy Markdown
Contributor

@S1ngS1ng S1ngS1ng left a comment

Choose a reason for hiding this comment

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

请看下 comments。有问题的话随时回复。
记得把英文原文删掉。
注意标点

"description": [
"Add mongodb and mongoose to the project’s package.json. Then require mongoose. Store your mLab database URI in the private .env file as MONGO_URI. Connect to the database using mongoose.connect(<Your URI>)"
"Add mongodb and mongoose to the project’s package.json. Then require mongoose. Store your mLab database URI in the private .env file as MONGO_URI. Connect to the database using mongoose.connect(<Your URI>)",
"在 package.json 文件中添加 mongodb 和 mongoose 依赖. 然后 require('mongoose'). 将 mLab 数据库 URI 作为 MONGO_URI 变量存储在私有 .env 文件中. 使用 mongoose.connect(<Your URI>) 命令连接数据库"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

  1. mongoose.connect(<Your URI>)require('mongoose') 建议用 <code></code> 包上
  2. 注意句号,要用中文的全角句号
  3. 结尾要加句号。下同

"title": "Create a Model",
"description": [
"First of all we need a Schema. Each schema maps to a MongoDB collection. It defines the shape of the documents within that collection.",
"首先,我们需要一个 Schema. 每一个 schema 对应一个 mongoDB collection 并且在那个 collection 里面定义了 documents 的模型",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

mongoDB 注意拼写。应为 MongoDB

参考:https://www.mongodb.com/

"First of all we need a Schema. Each schema maps to a MongoDB collection. It defines the shape of the documents within that collection.",
"首先,我们需要一个 Schema. 每一个 schema 对应一个 mongoDB collection 并且在那个 collection 里面定义了 documents 的模型",
"Schemas are building block for Models. They can be nested to create complex models, but in this case we’ll keep things simple.",
"Schemas 是 Models 的构建块. 它们可以嵌套来创建复杂的模型,但是这里,我们会保持简单.",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

我们会保持简单 建议 =>
我们只学习简单的用法

"A model allows you to create instances of your objects, called documents.",
"Model 可以被实例化,实例化后的对象称为 document",
"Create a person having this prototype :",
"创建一个拥有以下 prototype 的 person 对象:",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

全角分号

"Use the mongoose basic schema types. If you want you can also add",
"more fields, use simple validators like required or unique,",
"and set default values. See the <a href='http://mongoosejs.com/docs/guide.html'>mongoose docs</a>.",
"你可以使用 schema 的基础 types 去添加更多的字段。比如使用 required 或者 unique 这样的简单验证去设置默认值. 看 <a href='http://mongoosejs.com/docs/guide.html'>mongoose 文档</a>.",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

感觉这里应该是 基础的 SchemaTypes

参考:http://mongoosejs.com/docs/schematypes.html#schematypes


看 <a href='http://mongoosejs.com/docs/guide.html'>mongoose 文档</a> =>
请参考 <a href='http://mongoosejs.com/docs/guide.html'>mongoose 文档</a>。

"你可以使用 schema 的基础 types 去添加更多的字段。比如使用 required 或者 unique 这样的简单验证去设置默认值. 看 <a href='http://mongoosejs.com/docs/guide.html'>mongoose 文档</a>.",
"[C]RUD Part I - CREATE",
"Note: Glitch is a real server, and in real servers the interactions with the db happen in handler functions. These function are executed when some event happens (e.g. someone hits an endpoint on your API). We’ll follow the same approach in these exercises. The done() function is a callback that tells us that we can proceed after completing an asynchronous operation such as inserting, searching, updating or deleting. It’s following the Node convention and should be called as done(null, data) on success, or done(err) on error.",
"注意: Glitch 是一个真实的服务, 并且通过 handler 函数和 db 进行交互. 这些函数通过一些事件去触发(e.g. 有人从终端调用了你的 API). 我们在这些联系中遵循同样的方法. 我们在完成如 nserting, searching, updating 或者 deleting 这样的异步操作后接着回调 done() 函数. 它遵循 Node 的惯例,需要在 success 时回调 done(null, data), 在 error 时回调 done(err)。",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

联系 => 练习 🤦‍♂️


注意,中文列举用顿号


done 那些,建议 <code></code> 包上

"Note: Glitch is a real server, and in real servers the interactions with the db happen in handler functions. These function are executed when some event happens (e.g. someone hits an endpoint on your API). We’ll follow the same approach in these exercises. The done() function is a callback that tells us that we can proceed after completing an asynchronous operation such as inserting, searching, updating or deleting. It’s following the Node convention and should be called as done(null, data) on success, or done(err) on error.",
"注意: Glitch 是一个真实的服务, 并且通过 handler 函数和 db 进行交互. 这些函数通过一些事件去触发(e.g. 有人从终端调用了你的 API). 我们在这些联系中遵循同样的方法. 我们在完成如 nserting, searching, updating 或者 deleting 这样的异步操作后接着回调 done() 函数. 它遵循 Node 的惯例,需要在 success 时回调 done(null, data), 在 error 时回调 done(err)。",
"Warning - When interacting with remote services, errors may occur !",
"Warning - 当与远程服务器交互时可能发生错误!",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

全角叹号

"title": "Create and Save a Record of a Model",
"description": [
"Create a document instance using the Person constructor you build before. Pass to the constructor an object having the fields name, age, and favoriteFoods. Their types must be conformant to the ones in the Person Schema. Then call the method document.save() on the returned document instance. Pass to it a callback using the Node convention. This is a common pattern, all the following CRUD methods take a callback function like this as the last argument.",
"使用 Person 的 constructor 函数可以创建一个 document 对象, 该对象包含 name, age 和 favoriteFoods 字段. 这些字段的类型必须符合 Person Schema 里面定义的类型. 然后调用 document.save(). 使用 Node 惯例传递 callback. 通常情况下,所有的 CRUD(增查改删) 方法都会像下面一样作为最后一个参数去执行一个 callback() ",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

constructor 有对应的翻译,构造器


建议,nameage 也用 <code></code> 包起来

@S1ngS1ng S1ngS1ng added the need update Use when a translation (?) PR has been reviewed and needs to address comments label Jul 24, 2018
@huluoyang huluoyang changed the title [Jane] Translaion 1-3 sections Translate mongodb-and-mongoose Jul 24, 2018
Copy link
Copy Markdown
Contributor

@S1ngS1ng S1ngS1ng left a comment

Choose a reason for hiding this comment

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

小问题,更新下就好了

"Use the mongoose basic schema types. If you want you can also add",
"more fields, use simple validators like required or unique,",
"and set default values. See the <a href='http://mongoosejs.com/docs/guide.html'>mongoose docs</a>.",
"你可以使用 基础的 SchemaTypes 去添加更多的字段,比如使用 required 或者 unique 这样的简单验证去设置默认值. 参考 <a href='http://mongoosejs.com/docs/guide.html'>Mongoose 文档</a>.",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

你可以使用 基础的 SchemaTypes 这里多了空格。“使用”之后

这句话里,句号要用全角的,你貌似忘了改了

"[C]RUD Part I - CREATE",
"Note: Glitch is a real server, and in real servers the interactions with the db happen in handler functions. These function are executed when some event happens (e.g. someone hits an endpoint on your API). We’ll follow the same approach in these exercises. The done() function is a callback that tells us that we can proceed after completing an asynchronous operation such as inserting, searching, updating or deleting. It’s following the Node convention and should be called as done(null, data) on success, or done(err) on error.",
"Warning - When interacting with remote services, errors may occur !",
"注意: Glitch 是一个真实的服务, 并且通过 handler 函数和 db 进行交互。 这些函数通过一些事件去触发(例如:有人从终端调用了你的 API), 我们在这些练习中遵循同样的方法。 比如,我们在完成 nserting、 searching、 updating 或者 deleting 这样的异步操作后接着回调 <code>done()</code> 函数。 它遵循 Node 的惯例,需要在 success 时回调 <code>done(null, data)</code>, 在 error 时回调 <code>done(err)</code>。",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

多了好多空格

Copy link
Copy Markdown
Contributor

@S1ngS1ng S1ngS1ng left a comment

Choose a reason for hiding this comment

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

Thanks 👍

@S1ngS1ng S1ngS1ng added :shipit: ship it Use when a translation (?) PR is ready for shipping and removed need update Use when a translation (?) PR has been reviewed and needs to address comments labels Jul 30, 2018
"tests": [
{
"text": "Creating and saving a db item should succeed",
"text": "成功创建一条 db 并保存。",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

此处不符合原意

"description": [
"Find all the people having a given name, using Model.find() -> [Person]",
"In its simplest usage, Model.find() accepts a query document (a JSON object ) as the first argument, then a callback. It returns an array of matches. It supports an extremely wide range of search options. Check it in the docs. Use the function argument personName as search key."
"使用<code>Model.find() -> [Person]</code>来查询给定名称的所有的人。",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

行文不流畅

"Find all the people having a given name, using Model.find() -> [Person]",
"In its simplest usage, Model.find() accepts a query document (a JSON object ) as the first argument, then a callback. It returns an array of matches. It supports an extremely wide range of search options. Check it in the docs. Use the function argument personName as search key."
"使用<code>Model.find() -> [Person]</code>来查询给定名称的所有的人。",
"最简单的用法:<code>Model.find()</code>接受一个查询的 document(一个 JSON 对象)作为第一参数,然后是回调。它将返回匹配到的项目组成的数组。这个支持极其广泛的搜索选项。使用人名作为搜索的关键词,来校验它。"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

行文不流畅

"tests": [
{
"text": "Find all items corresponding to a criteria should succeed",
"text": "成功找到所有符合条件的 item(项目)。",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

"成功找到所有符合条件的 items(项目)。

"tests": [
{
"text": "Creating many db items at once should succeed",
"text": "应当可以一次性创建多个 item(项目)。",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

不能按字面意思翻译啊。
这样会不会好点:一次创建多条记录,对应 title。

@huluoyang huluoyang added need update Use when a translation (?) PR has been reviewed and needs to address comments and removed :shipit: ship it Use when a translation (?) PR is ready for shipping labels Jul 30, 2018
@huluoyang
Copy link
Copy Markdown
Contributor

因为这个章节不长,建议翻译完后再 merge。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

need update Use when a translation (?) PR has been reviewed and needs to address comments

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants