diff --git a/aio/content/translations/cn/api-plan.md b/aio/content/translations/cn/api-plan.md index 1e27c52271..bd2d48df10 100644 --- a/aio/content/translations/cn/api-plan.md +++ b/aio/content/translations/cn/api-plan.md @@ -82,8 +82,8 @@ [ ] | forms | 0.19 [ ] | animations/state | 0.19 [ ] | common | 0.19 -[ ] | router/LoadChildren | 0.18 -[ ] | router/ParamMap | 0.18 +[x] | router/LoadChildren | 0.18 +[x] | router/ParamMap | 0.18 [ ] | animations/trigger | 0.18 [ ] | router/RouterLinkWithHref | 0.18 [ ] | core/AfterViewInit | 0.18 diff --git a/packages/router/src/shared.ts b/packages/router/src/shared.ts index c43f7353d9..3247460929 100644 --- a/packages/router/src/shared.ts +++ b/packages/router/src/shared.ts @@ -16,6 +16,8 @@ import {UrlSegment, UrlSegmentGroup} from './url_tree'; * Name of the primary outlet. * * + * 主路由出口的名字。 + * */ export const PRIMARY_OUTLET = 'primary'; @@ -23,6 +25,7 @@ export const PRIMARY_OUTLET = 'primary'; * A collection of parameters. * * + * 参数的集合。 */ export type Params = { [key: string]: any @@ -31,32 +34,60 @@ export type Params = { /** * Matrix and Query parameters. * + * 矩阵参数(`;`)和查询参数(`?`)。 + * * `ParamMap` makes it easier to work with parameters as they could have either a single value or * multiple value. Because this should be known by the user, calling `get` or `getAll` returns the * correct type (either `string` or `string[]`). * + * `ParamMap` 让参数更容易使用,因为它们可以有一个值或多个值。 + * 因为用户原本就该知道有一个还是多个,所以请通过调用 `get` 或 `getAll` 来返回正确的类型(`string` 或 `string[]`)。 + * * The API is inspired by the URLSearchParams interface. * see https://developer.mozilla.org/en-US/docs/Web/API/URLSearchParams * * + * 该 API 的设计受到了 URLSearchParams 接口的启发。 + * 参见 https://developer.mozilla.org/en-US/docs/Web/API/URLSearchParams + * + * */ export interface ParamMap { has(name: string): boolean; /** * Return a single value for the given parameter name: + * + * 返回具有指定参数名的单一值。 + * * - the value when the parameter has a single value, + * + * 当该参数只有一个单一值时,返回这个值, + * * - the first value if the parameter has multiple values, + * + * 当该参数具有多个值时,返回第一个值, + * * - `null` when there is no such parameter. + * + * 当没有参数时,返回 `null`。 + * */ get(name: string): string|null; /** * Return an array of values for the given parameter name. * + * 返回指定参数名的值数组。 + * * If there is no such parameter, an empty array is returned. + * + * 如果没有该参数,则返回一个空数组。 */ getAll(name: string): string[]; - /** Name of the parameters */ + /** Name of the parameters + * + * 所有参数名的数组。 + */ readonly keys: string[]; } @@ -92,6 +123,7 @@ class ParamsAsMap implements ParamMap { * Convert a `Params` instance to a `ParamMap`. * * + * 把 `Params` 实例转换成 `ParamMap` 实例。 */ export function convertToParamMap(params: Params): ParamMap { return new ParamsAsMap(params);