Skip to content

Commit 6580a85

Browse files
author
Zhicheng WANG
committed
docs: 翻译 API 文档
1 parent d6eccf8 commit 6580a85

File tree

344 files changed

+20508
-2553
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

344 files changed

+20508
-2553
lines changed

src/cdk-experimental/menu/menu.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ layed out horizontally or vertically (defaulting to horizontal). If the layout c
113113
the `orientation` attribute to match in order for the keyboard navigation to work properly and for
114114
menus to open up in the correct location.
115115

116-
`CdkMenuBar` 指令遵循 [ARIA 菜单栏][menubar]规范,其行为类似桌面应用de 菜单栏。它包括至少一个触发子菜单的 `CdkMenuItem`。菜单栏可以使用水平或垂直布局(默认为水平布局)。如果该布局发生了变化,你必须先设置与之匹配的 `orientation` 属性。这样才能让键盘导航正常工作,并让菜单在正确的位置打开。
116+
`CdkMenuBar` 指令遵循 [ARIA 菜单栏][menubar]规范,其行为类似桌面应用 de 菜单栏。它包括至少一个触发子菜单的 `CdkMenuItem`。菜单栏可以使用水平或垂直布局(默认为水平布局)。如果该布局发生了变化,你必须先设置与之匹配的 `orientation` 属性。这样才能让键盘导航正常工作,并让菜单在正确的位置打开。
117117

118118
<!-- example({
119119
"example": "cdk-menu-menubar",

src/cdk/a11y/a11y.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -212,19 +212,19 @@ defaults to `false` if not specified. The `monitor` method will return an Observ
212212

213213
* `'mouse'` indicates the element was focused with the mouse
214214

215-
`'mouse'`表示该元素是通过鼠标获得焦点的
215+
`'mouse'` 表示该元素是通过鼠标获得焦点的
216216

217217
* `'keyboard'` indicates the element was focused with the keyboard
218218

219-
`'keyboard'`表示该元素是通过键盘获得焦点的
219+
`'keyboard'` 表示该元素是通过键盘获得焦点的
220220

221221
* `'touch'` indicates the element was focused by touching on a touchscreen
222222

223-
`'touch'`表示该元素是通过触摸屏获得焦点的
223+
`'touch'` 表示该元素是通过触摸屏获得焦点的
224224

225225
* `'program'` indicates the element was focused programmatically
226226

227-
`'program'`表示该元素是通过编程方式获得焦点的
227+
`'program'` 表示该元素是通过编程方式获得焦点的
228228

229229
* `null` indicates the element was blurred
230230

src/cdk/a11y/fake-mousedown.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@
1212
* mousedown events and real mousedown events using the "buttons" property. While
1313
* real mousedowns will indicate the mouse button that was pressed (e.g. "1" for
1414
* the left mouse button), faked mousedowns will usually set the property value to 0.
15+
*
16+
* 当使用键盘激活可获得焦点的元素时,屏幕阅读器通常会触发一个伪 mousedown 事件。我们通常可以使用 “buttons” 属性来区分这些伪 mousedown 事件和真实的 mousedown 事件。真实的 mousedown 会指出被按下的鼠标按键(比如鼠标左键是“1”),而伪造的 mousedown 通常会把该属性值设置为 0。
17+
*
1518
*/
1619
export function isFakeMousedownFromScreenReader(event: MouseEvent): boolean {
1720
return event.buttons === 0;

src/cdk/accordion/accordion-item.ts

Lines changed: 87 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,20 @@ import {CDK_ACCORDION, CdkAccordion} from './accordion';
2222
import {BooleanInput, coerceBooleanProperty} from '@angular/cdk/coercion';
2323
import {Subscription} from 'rxjs';
2424

25-
/** Used to generate unique ID for each accordion item. */
25+
/**
26+
* Used to generate unique ID for each accordion item.
27+
*
28+
* 用来为每个手风琴条目生成唯一的 ID。
29+
*
30+
*/
2631
let nextId = 0;
2732

2833
/**
2934
* An basic directive expected to be extended and decorated as a component. Sets up all
3035
* events and attributes needed to be managed by a CdkAccordion parent.
36+
*
37+
* 一个基本指令,供使用者扩展并改成组件装饰器。设置所有要由 CdkAccordion 的父指令管理的事件和属性。
38+
*
3139
*/
3240
@Directive({
3341
selector: 'cdk-accordion-item, [cdkAccordionItem]',
@@ -39,26 +47,59 @@ let nextId = 0;
3947
],
4048
})
4149
export class CdkAccordionItem implements OnDestroy {
42-
/** Subscription to openAll/closeAll events. */
50+
/**
51+
* Subscription to openAll/closeAll events.
52+
*
53+
* 订阅 openAll / closeAll 事件。
54+
*
55+
*/
4356
private _openCloseAllSubscription = Subscription.EMPTY;
44-
/** Event emitted every time the AccordionItem is closed. */
57+
/**
58+
* Event emitted every time the AccordionItem is closed.
59+
*
60+
* 每次关闭此条目时都会发出本事件。
61+
*
62+
*/
4563
@Output() closed: EventEmitter<void> = new EventEmitter<void>();
46-
/** Event emitted every time the AccordionItem is opened. */
64+
/**
65+
* Event emitted every time the AccordionItem is opened.
66+
*
67+
* 每次打开此条目时都会发出本事件。
68+
*
69+
*/
4770
@Output() opened: EventEmitter<void> = new EventEmitter<void>();
48-
/** Event emitted when the AccordionItem is destroyed. */
71+
/**
72+
* Event emitted when the AccordionItem is destroyed.
73+
*
74+
* 当此条目被销毁时会发出本事件。
75+
*
76+
*/
4977
@Output() destroyed: EventEmitter<void> = new EventEmitter<void>();
5078

5179
/**
5280
* Emits whenever the expanded state of the accordion changes.
5381
* Primarily used to facilitate two-way binding.
82+
*
83+
* 每当手风琴展开状态发生变化时,就会触发。主要是为了方便进行双向绑定。
84+
*
5485
* @docs-private
5586
*/
5687
@Output() expandedChange: EventEmitter<boolean> = new EventEmitter<boolean>();
5788

58-
/** The unique AccordionItem id. */
89+
/**
90+
* The unique AccordionItem id.
91+
*
92+
* AccordionItem 的唯一 id。
93+
*
94+
*/
5995
readonly id: string = `cdk-accordion-child-${nextId++}`;
6096

61-
/** Whether the AccordionItem is expanded. */
97+
/**
98+
* Whether the AccordionItem is expanded.
99+
*
100+
* 此条目是否已经展开了。
101+
*
102+
*/
62103
@Input()
63104
get expanded(): any { return this._expanded; }
64105
set expanded(expanded: any) {
@@ -74,6 +115,9 @@ export class CdkAccordionItem implements OnDestroy {
74115
/**
75116
* In the unique selection dispatcher, the id parameter is the id of the CdkAccordionItem,
76117
* the name value is the id of the accordion.
118+
*
119+
* 在唯一选项派发器中,其 id 参数是 CdkAccordionItem 的 id,其 name 的值是这个手风琴的 id。
120+
*
77121
*/
78122
const accordionId = this.accordion ? this.accordion.id : this.id;
79123
this._expansionDispatcher.notify(this.id, accordionId);
@@ -88,13 +132,23 @@ export class CdkAccordionItem implements OnDestroy {
88132
}
89133
private _expanded = false;
90134

91-
/** Whether the AccordionItem is disabled. */
135+
/**
136+
* Whether the AccordionItem is disabled.
137+
*
138+
* 此条目是否被禁用了。
139+
*
140+
*/
92141
@Input()
93142
get disabled() { return this._disabled; }
94143
set disabled(disabled: any) { this._disabled = coerceBooleanProperty(disabled); }
95144
private _disabled: boolean = false;
96145

97-
/** Unregister function for _expansionDispatcher. */
146+
/**
147+
* Unregister function for \_expansionDispatcher.
148+
*
149+
* 取消注册 \_expansionDispatcher 的函数。
150+
*
151+
*/
98152
private _removeUniqueSelectionListener: () => void = () => {};
99153

100154
constructor(@Optional() @Inject(CDK_ACCORDION) @SkipSelf() public accordion: CdkAccordion,
@@ -114,7 +168,12 @@ export class CdkAccordionItem implements OnDestroy {
114168
}
115169
}
116170

117-
/** Emits an event for the accordion item being destroyed. */
171+
/**
172+
* Emits an event for the accordion item being destroyed.
173+
*
174+
* 发出此条目被销毁的事件。
175+
*
176+
*/
118177
ngOnDestroy() {
119178
this.opened.complete();
120179
this.closed.complete();
@@ -124,21 +183,36 @@ export class CdkAccordionItem implements OnDestroy {
124183
this._openCloseAllSubscription.unsubscribe();
125184
}
126185

127-
/** Toggles the expanded state of the accordion item. */
186+
/**
187+
* Toggles the expanded state of the accordion item.
188+
*
189+
* 切换此条目的展开状态。
190+
*
191+
*/
128192
toggle(): void {
129193
if (!this.disabled) {
130194
this.expanded = !this.expanded;
131195
}
132196
}
133197

134-
/** Sets the expanded state of the accordion item to false. */
198+
/**
199+
* Sets the expanded state of the accordion item to false.
200+
*
201+
* 把此条目的展开状态设置为 false。
202+
*
203+
*/
135204
close(): void {
136205
if (!this.disabled) {
137206
this.expanded = false;
138207
}
139208
}
140209

141-
/** Sets the expanded state of the accordion item to true. */
210+
/**
211+
* Sets the expanded state of the accordion item to true.
212+
*
213+
* 把此条目的展开状态设置为 true。
214+
*
215+
*/
142216
open(): void {
143217
if (!this.disabled) {
144218
this.expanded = true;

src/cdk/accordion/accordion.ts

Lines changed: 57 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,46 +10,93 @@ import {BooleanInput, coerceBooleanProperty} from '@angular/cdk/coercion';
1010
import {Directive, InjectionToken, Input, OnChanges, OnDestroy, SimpleChanges} from '@angular/core';
1111
import {Subject} from 'rxjs';
1212

13-
/** Used to generate unique ID for each accordion. */
13+
/**
14+
* Used to generate unique ID for each accordion.
15+
*
16+
* 用于为每个手风琴生成唯一的 ID。
17+
*
18+
*/
1419
let nextId = 0;
1520

1621
/**
1722
* Injection token that can be used to reference instances of `CdkAccordion`. It serves
1823
* as alternative token to the actual `CdkAccordion` class which could cause unnecessary
1924
* retention of the class and its directive metadata.
25+
*
26+
* 这个注入令牌可以用来引用一些 `CdkAccordion` 实例。它可以作为真实 `CdkAccordion` 类的备用令牌,直接使用该类可能导致该类及其指令的元数据无法被优化掉。
27+
*
2028
*/
2129
export const CDK_ACCORDION = new InjectionToken<CdkAccordion>('CdkAccordion');
2230

2331
/**
2432
* Directive whose purpose is to manage the expanded state of CdkAccordionItem children.
33+
*
34+
* 该指令的用途是管理 CdkAccordionItem 子组件的展开状态。
35+
*
2536
*/
2637
@Directive({
2738
selector: 'cdk-accordion, [cdkAccordion]',
2839
exportAs: 'cdkAccordion',
29-
providers: [{provide: CDK_ACCORDION, useExisting: CdkAccordion}],
40+
providers: [{ provide: CDK_ACCORDION, useExisting: CdkAccordion }],
3041
})
3142
export class CdkAccordion implements OnDestroy, OnChanges {
32-
/** Emits when the state of the accordion changes */
43+
/**
44+
* Emits when the state of the accordion changes
45+
*
46+
* 当手风琴状态发生变化时会触发
47+
*
48+
*/
3349
readonly _stateChanges = new Subject<SimpleChanges>();
3450

35-
/** Stream that emits true/false when openAll/closeAll is triggered. */
51+
/**
52+
* Stream that emits true/false when openAll/closeAll is triggered.
53+
*
54+
* 当 openAll/closeAll 被触发时,此流会发出 true/false。
55+
*
56+
*/
3657
readonly _openCloseAllActions: Subject<boolean> = new Subject<boolean>();
3758

38-
/** A readonly id value to use for unique selection coordination. */
59+
/**
60+
* A readonly id value to use for unique selection coordination.
61+
*
62+
* 一个只读的 id 值,用于在单选模式下进行协调。
63+
*
64+
*/
3965
readonly id = `cdk-accordion-${nextId++}`;
4066

41-
/** Whether the accordion should allow multiple expanded accordion items simultaneously. */
67+
/**
68+
* Whether the accordion should allow multiple expanded accordion items simultaneously.
69+
*
70+
* 手风琴是否应该允许同时展开多个手风琴条目。
71+
*
72+
*/
4273
@Input()
43-
get multi(): boolean { return this._multi; }
44-
set multi(multi: boolean) { this._multi = coerceBooleanProperty(multi); }
74+
get multi(): boolean {
75+
return this._multi;
76+
}
77+
78+
set multi(multi: boolean) {
79+
this._multi = coerceBooleanProperty(multi);
80+
}
81+
4582
private _multi: boolean = false;
4683

47-
/** Opens all enabled accordion items in an accordion where multi is enabled. */
84+
/**
85+
* Opens all enabled accordion items in an accordion where multi is enabled.
86+
*
87+
* 允许多选时,可以同时打开手风琴中的所有可用条目。
88+
*
89+
*/
4890
openAll(): void {
4991
this._openCloseAll(true);
5092
}
5193

52-
/** Closes all enabled accordion items in an accordion where multi is enabled. */
94+
/**
95+
* Closes all enabled accordion items in an accordion where multi is enabled.
96+
*
97+
* 允许多选时,可以同时关闭手风琴中的所有可用条目。
98+
*
99+
*/
53100
closeAll(): void {
54101
this._openCloseAll(false);
55102
}

src/cdk/bidi/dir-document-token.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,22 @@ import {inject, InjectionToken} from '@angular/core';
1414
* Injection token used to inject the document into Directionality.
1515
* This is used so that the value can be faked in tests.
1616
*
17+
* 用于把 document 注入到 Directionality 中的注入令牌。这是为了可以在测试中伪造该值。
18+
*
1719
* We can't use the real document in tests because changing the real `dir` causes geometry-based
1820
* tests in Safari to fail.
1921
*
22+
* 我们不能在测试中使用真正的 document,因为改变真实的 `dir` 会导致 Safari 中基于几何的测试失败。
23+
*
2024
* We also can't re-provide the DOCUMENT token from platform-brower because the unit tests
2125
* themselves use things like `querySelector` in test code.
2226
*
27+
* 我们也无法从 platform-browser 中重新提供 DOCUMENT 令牌,因为单元测试本身会在测试代码中使用 `querySelector` 等。
28+
*
2329
* This token is defined in a separate file from Directionality as a workaround for
24-
* https://github.com/angular/angular/issues/22559
30+
* <https://github.com/angular/angular/issues/22559>
31+
*
32+
* 这个令牌是在 Directionality 的一个独立文件中定义的,用于解决 <https://github.com/angular/angular/issues/22559> 问题。
2533
*
2634
* @docs-private
2735
*/

0 commit comments

Comments
 (0)