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

APIReference-TypeSystem.md #61

Merged
merged 4 commits into from
Aug 10, 2017
Merged

Conversation

hikerpig
Copy link

@hikerpig hikerpig commented Aug 5, 2017

Close #18

感觉翻得有些词不达意,类似于 Composite 这种设计模式里的东西,懂的人自然懂,不懂的话照着原文里的简单说明去翻基本上也是云里雾里。

麻烦校对了

@hikerpig hikerpig changed the title "APIReference-TypeSystem.md" 初稿 "APIReference-TypeSystem.md" 翻译完成 Aug 5, 2017
@hikerpig hikerpig changed the title "APIReference-TypeSystem.md" 翻译完成 APIReference-TypeSystem.md 翻译完成 Aug 5, 2017
Copy link
Collaborator

@jonirrings jonirrings left a comment

Choose a reason for hiding this comment

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

细节需要讨论

@@ -1,167 +1,167 @@
---
title: graphql/types
title: graphql/type 类型系统
Copy link
Collaborator

Choose a reason for hiding this comment

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

这个是api……其实建议保持原样……:joy:

Copy link
Author

Choose a reason for hiding this comment

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

我感觉正因为是 api,才应该把后面的 s 去掉,正文第一句话就说了 graphql/type 模块,这个复数形式这么放感觉有点误导

Copy link
Author

Choose a reason for hiding this comment

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

哦你说的也对,还是保留 title 吧,然后我去提个 pull request ...

layout: ../_core/GraphQLJSLayout
category: API Reference
permalink: /graphql-js/type/
sublinks: getNamedType,getNullableType,GraphQLBoolean,GraphQLEnumType,GraphQLFloat,GraphQLID,GraphQLInputObjectType,GraphQLInt,GraphQLInterfaceType,GraphQLList,GraphQLNonNull,GraphQLObjectType,GraphQLScalarType,GraphQLSchema,GraphQLString,GraphQLUnionType,isAbstractType,isCompositeType,isInputType,isLeafType,isOutputType
next: /graphql-js/utilities/
---

The `graphql/type` module is responsible for defining GraphQL types and schema. You can import either from the `graphql/type` module, or from the root `graphql` module. For example:
`graphql/type` 模块的职责为定义 GraphQL 的类型和 schemea。你可以从 `graphql/type` 模块或是根模块 `graphql` 引入。例如:
Copy link
Collaborator

Choose a reason for hiding this comment

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

schemea -> schema

</a>
</li>
<li>
<a href="#graphqlnonnull">
<pre>class GraphQLNonNull</pre>
A type wrapper around other types that represents a non-null version of those types.
类型包装器,表示被包装类型取值不为 null 的版本。
Copy link
Collaborator

Choose a reason for hiding this comment

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

non-null 我是翻译作 非空 或者 不可为空。你参考下

</a>
</li>
<li>
<a href="#iscompositetype">
<pre>function isCompositeType</pre>
Returns if a type can be the parent context of a selection set.
判断某类型是否为组合类型,即是否可作为参加组合的叶节点的父节点。
Copy link
Collaborator

Choose a reason for hiding this comment

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

判断某类型是否为一个选择集的父级上下文。
selection set这个我们可能需要讨论下
即是后面的部分是不是可以作为传说中的译者案

Copy link
Author

Choose a reason for hiding this comment

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

回来看了下源码感觉自己脑子进水想太多了,“选择集”挺好的,感谢。
最后为了和上文的啰嗦形式统一,准备改为“判断某类型是否可以作为一个选择集的父级上下文”

</a>
</li>
<li>
<a href="#isabstracttype">
<pre>function isAbstractType</pre>
Returns if a type is a combination of object types.
判断某类型是否为抽象类型,即是否可代表其一系列 Object 类型实现。
Copy link
Collaborator

Choose a reason for hiding this comment

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

…这意译和原文 词语的对应关系好远。
直译感觉也行啊。
判断某类型是否为对象类型的组合。

Copy link
Author

@hikerpig hikerpig Aug 5, 2017

Choose a reason for hiding this comment

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

这个地方和 CompositeType 纠结了很久。

真的是脑子进水,看了下代码的实现,直译完全是对的。

/**
 * These types may describe the parent context of a selection set.
 */
export type GraphQLAbstractType =
  GraphQLInterfaceType |
  GraphQLUnionType;

export function isAbstractType(type: ?GraphQLType): boolean %checks {
  return (
    type instanceof GraphQLInterfaceType ||
    type instanceof GraphQLUnionType
  );
}

When two types need to refer to each other, or a type needs to refer to
itself in a field, you can use a function expression (aka a closure or a
thunk) to supply the fields lazily.
当两个类型需要相互指涉,或是某类型需要的某一字段类型为其自身,你可以使用函数表达式(也可称为闭包或是 thunk)来实现字段类型的延后求值。
Copy link
Collaborator

Choose a reason for hiding this comment

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

refer,不妨翻译作引用

Copy link
Author

Choose a reason for hiding this comment

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

这个地方我有考虑过,我的感觉是“引用”比较适合用作 reference 的翻译,类似于“引用变量”,“对该对象的引用”。此处是类型系统里的概念,不过“指涉”的确是有点太生僻了,不知 “指代” 会不会更好点?

The leaf values of any request and input values to arguments are
Scalars (or Enums) and are defined with a name and a series of serialization
functions used to ensure validity.
构建用于表示请求的叶节点值和输入值的标量(或枚举)类型 `GraphQLScalarType` 时,需要指定 `name` 以及一系列用于确保值的有效性的序列化函数。

#### Example
Copy link
Collaborator

Choose a reason for hiding this comment

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

咦,漏了个example没翻译,前后都有翻译来着

一些请求的叶节点值和输入值为枚举类型。GraphQL 会将枚举值序列化为字符串,但在内部使用时,枚举值可以用任何类型来表示,一般用整型来表示。

备注:如果在定义时没有指定 `value`,在内部使用时会用枚举类型的 `name` 作为其值。

Some leaf values of requests and input values are Enums. GraphQL serializes
Copy link
Collaborator

Choose a reason for hiding this comment

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

忘记删了

@@ -487,12 +479,11 @@ type GraphQLInputObjectFieldMap = {
};
```

An input object defines a structured collection of fields which may be
supplied to a field argument.
一个输入对象类型定义了一群可以作为某字段查询参数的字段。
Copy link
Collaborator

Choose a reason for hiding this comment

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

一群 -> 一组,如何?


### isCompositeType

```js
function isCompositeType(type: ?GraphQLType): boolean
```

These types may describe the parent context of a selection set
判断某类型是否为组合类型,即是否可作为参加组合的叶节点的父节点。
Copy link
Collaborator

Choose a reason for hiding this comment

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

同上。

</a>
</li>
</ul>

*Definitions*
*定义(Definitions*
Copy link
Collaborator

Choose a reason for hiding this comment

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

由于翻译规范要求所有翻译成中文的斜体都改成加粗,但是这里还存在一个并列关系的不翻译的 Schema,因此建议对于所有出现在 ul 元素之前的斜体小标题,采用以下两种二选一:

  1. 全部替换成加粗
  2. 全部保留英文不翻译

</a>
</li>
<li>
<a href="#graphqlenumtype">
<pre>class GraphQLEnumType</pre>
An enum type within GraphQL that defines a list of valid values.
GraphQL 中的枚举类型,定义一个有效值的列表。
Copy link
Collaborator

Choose a reason for hiding this comment

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

这一句和上一句同是 a list of,为什么翻译不一致呢?表达的意思并无不同呀


<ul class="apiIndex">
<li>
<a href="#isinputtype">
<pre>function isInputType</pre>
Returns if a type can be used as input types for arguments and directives.
判断某类型是否可以作为字段查询参数。
Copy link
Collaborator

Choose a reason for hiding this comment

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

directives 漏掉了

</a>
</li>
<li>
<a href="#isoutputtype">
<pre>function isOutputType</pre>
Returns if a type can be used as output types as the result of fields.
判断某类型是否可以作为字段查询结果的值。
Copy link
Collaborator

Choose a reason for hiding this comment

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

be used as output types,还是作为类型,不是作为值


<ul class="apiIndex">
<li>
<a href="#graphqlint">
<pre>var GraphQLInt</pre>
A scalar type representing integers.
整型数标量类型。
Copy link
Collaborator

Choose a reason for hiding this comment

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

“整型数”怪怪的,跟浮点数对应的话直接“整数”就好,另外可以多写几个字的,比如“表示整数的标量类型”,读起来更舒服

Some leaf values of requests and input values are Enums. GraphQL serializes
Enum values as strings, however internally Enums can be represented by any
kind of type, often integers.
一些请求的叶节点值和输入值为枚举类型。GraphQL 会将枚举值序列化为字符串,但在内部使用时,枚举值可以用任何类型来表示,一般用整型来表示。
Copy link
Collaborator

Choose a reason for hiding this comment

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

前边两段翻译的时候加上了比如 GraphQLUnionType 之类的类型名进去,从这段开始又没加了,建议保持统一,要么都加,要么都不加


Using `NonNull` will ensure that a value must be provided by the query
使用 `NonNull` 标明查询一定会有返回值。
Copy link
Collaborator

Choose a reason for hiding this comment

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

ensure 漏了

@@ -554,67 +532,65 @@ var RowType = new GraphQLObjectType({
});
```

## Predicates
## 谓词函数
Copy link
Collaborator

Choose a reason for hiding this comment

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

目录部分用括号补充了原单词,这里请保持统一


### isInputType

```js
function isInputType(type: ?GraphQLType): boolean
```

These types may be used as input types for arguments and directives.
判断某类型是否可以作为字段查询参数。
Copy link
Collaborator

Choose a reason for hiding this comment

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

???复制过来的?意思完全不对啊

Copy link
Author

Choose a reason for hiding this comment

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

好的,漏翻和错误的地方修改了一下。
除去原先翻译错误的部分,我觉得这部分可以直接从目录里复制过来,原文里主要描述与目录都是一样的。而且原文中此处的 "These types may describe" 没有传达出谓词函数的用意。
和目录中保持一致翻为 “判断某类型是否可以作为字段查询参数和指令的输入类型” 如何?


### isAbstractType

```js
function isAbstractType(type: ?GraphQLType): boolean
```

These types may describe a combination of object types
判断某类型是否为对象类型的组合。
Copy link
Collaborator

Choose a reason for hiding this comment

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

以上几段请重新翻译一下……

@jonirrings jonirrings changed the title APIReference-TypeSystem.md 翻译完成 APIReference-TypeSystem.md Aug 7, 2017
jonirrings
jonirrings previously approved these changes Aug 7, 2017
@jonirrings
Copy link
Collaborator

validator翻译成 校验器 和 验证器 方面 #65 讨论下,

@linhe0x0 linhe0x0 merged commit e32298a into xitu:zh-Hans Aug 10, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants