Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Translate the introduction of Model module #17

Closed
wants to merge 3 commits into from

2 participants

@zernel
Collaborator

No description provided.

@towerhe

忘记添加英文原文链接了

@zernel
Collaborator

已经把原文链接加上了,另外又译了一篇。
Btw,一开始那篇很多地方译得很别扭。

@towerhe
Owner

以后不要这么提交PR,在做之前先创建分支。比如这两篇,就应该分别在不同分支里面。现在和在一起就不好合并和修改了

建议你关闭这个PR,然后重新分别提交。

@zernel zernel closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Mar 26, 2013
  1. @zernel
  2. @zernel

    Translation of defining-a-store

    zernel authored
  3. @zernel

    Add the link of original

    zernel authored
This page is out of date. Refresh to see the latest.
View
6 data/guides.yml
@@ -80,10 +80,10 @@ Controllers:
- title: "Managing Dependencies Between Controllers"
url: "controllers/dependencies-between-controllers"
-Models:
- - title: "Introduction"
+模型:
+ - title: "介绍"
url: "models"
- - title: "Defining a Store"
+ - title: "创建一个存储器"
url: "models/defining-a-store"
- title: "Defining Models"
url: "models/defining-models"
View
14 source/guides/models/defining-a-store.md
@@ -1,14 +1,21 @@
-## Defining a Store
+英文原文:[http://emberjs.com/guides/models/defining-a-store/](http://emberjs.com/guides/models/defining-a-store/)
+
+## 创建一个存储器(Defining a Store)
Every application using Ember Data has a store. The store is the
repository that holds loaded models, and is responsible for retrieving
models that have not yet been loaded.
+每一个使用 Ember Data 的应用都会有一个存储器。这个存储器会成为已加载模型的贮存器,并且检索还未被加载的模型。
+
Typically, you will interact with models directly, not the store.
However, you do need to tell Ember.js that you want Ember Data to manage
your models. To do so, simply define a subclass of `DS.Store` on your
`Ember.Application`:
+通常,你可以直接跟模型交互,而不使用存储器。但是你需要让 Ember.js 知道你现在在使用 Ember Data 来管理你的模型。
+要达到这们的目的,我们可以在你的`Ember.Application`里面简单地定义一个`DS.Store`的子类。
+
```js
App.Store = DS.Store.extend({
revision: 12
@@ -20,12 +27,17 @@ number, and is used by Ember Data to notify you of breaking changes to
the public API. This will be removed once Ember Data reaches 1.0. See
the [Breaking Changes document][1] for more information.
+注意这里的`revision`属性,它是 API 的修订版本号,在Ember Data 1.0 版本之前用来提醒你公共 API 的重大更改。
+查看[Breaking Changes 文档][1]以获取更多信息。
+
[1]: https://github.com/emberjs/data/blob/master/BREAKING_CHANGES.md
If you want to customize the store, you can do so when creating the
subclass. For example, if you wanted to use an adapter other than the
default `DS.RESTAdapter`, you would do so like this:
+如果你想要定制存储器,你可以在创建子类的时候去定制。例如,如果你想要用另外一个适配器去替换默认的`DS.RESTAdapter`,你可以像下面这们做:
+
```js
App.Store = DS.Store.extend({
revision: 12,
View
17 source/guides/models/index.md
@@ -1,27 +1,42 @@
-## Models
+英文原文:[http://emberjs.com/guides/models/](http://emberjs.com/guides/models/)
+
+## 模型(Models)
In most Ember.js apps, models are handled by [Ember Data][1]. Ember Data
is a library, built with and for Ember.js, designed to make it easy to
retrieve records from a server, make changes in the browser, then save
those changes back to the server.
+在大部分的 Ember.js 应用里,模型是通过 [Ember Data][1] 来处理的。Ember
+Data 是一个由 Ember.js 写的库,它使我们可以很方便从服务器端取回记录并动态改变浏览器中的内容,然后保存这些更改回服务器。
+
It provides many of the facilities you'd find in server-side ORMs like
ActiveRecord, but is designed specifically for the unique environment of
JavaScript in the browser.
+你可以在服务器端找到像 ActiveRecord 这样的 ORM,不过它提供了专门为浏览器端的 Javascript 环境设计的工具方法。
+
Without any configuration, Ember Data can load and save records and
relationships served via a RESTful JSON API, provided it follows certain
conventions.
+Ember Data 并不需要任务配置就可以通过 RESTful JSON API 的惯例来加载和保存记录和关系。
+
We also understand that there exist many web service APIs in the world,
many of them crazy, inconsistent, and out of your control. Ember Data is
designed to be configurable to work with whatever persistence layer you
want, from the ordinary to the exotic.
+我们也知道世界上还有很多Web服务的API,其中许多会是荒唐的,矛盾的和容易失去控制。
+Ember Data 被设计成可配置的,无论你想要怎么样的持久层它都可以满足。
+
Currently, Ember Data ships as a separate library from Ember.js, while
we expand the adapter API to support more features. The API described in
this section tends to be stable, however. Until Ember Data is included
as part of the standard distribution, you can get your copy from the
[GitHub page][1].
+目前,当我们需要扩展适配器的 API 来支持更多的功能时,Ember Data 会作为 Ember.js 一个独立的库。
+但是本节中提到的 API 已经趋于稳定。直到 Ember Data 作为标准配置的一部分,你可以从[GitHub page][1]获取它的副本。
+
[1]: https://github.com/emberjs/data
Something went wrong with that request. Please try again.