docs(API): 翻译 router

This commit is contained in:
Zhicheng Wang 2018-08-31 16:21:38 +08:00
parent 4fc343f796
commit acfc14aafa
2 changed files with 236 additions and 107 deletions

View File

@ -2,106 +2,104 @@
按照下列优先级进行翻译:
URL|浏览量|占比
---|---|----
common/http/HttpClient | 7,263 | 2.26
common/NgForOf | 6,281 | 1.95
forms/NgModel | 5,648 | 1.75
core/Component | 5,582 | 1.73
common/NgIf | 4,940 | 1.53
core/NgModule | 4,097 | 1.27
router/Router | 4,049 | 1.26
animations/animate | 3,817 | 1.19
common/NgClass | 3,715 | 1.15
common/DatePipe | 3,576 | 1.11
/docs/ts/latest | 3,489 | 1.08
forms/FormsModule | 3,381 | 1.05
core/Input | 3,354 | 1.04
core/EventEmitter | 3,202 | 0.99
core/Injectable | 3,177 | 0.99
forms/FormGroup | 3,096 | 0.96
forms/FormControl | 3,034 | 0.94
router/ActivatedRoute | 2,993 | 0.93
forms/AbstractControl | 2,930 | 0.91
router/RouterLink | 2,929 | 0.91
core/ViewChild | 2,870 | 0.89
core/Directive | 2,767 | 0.86
router/Routes | 2,331 | 0.72
router/RouterModule | 2,227 | 0.69
router/Route | 2,223 | 0.69
http/Http | 2,220 | 0.69
common/http/HttpClientModule | 2,167 | 0.67
core/ElementRef | 2,163 | 0.67
core/OnInit | 2,136 | 0.66
common/UpperCasePipe | 2,078 | 0.65
common/NgStyle | 1,935 | 0.60
router/RouterOutlet | 1,908 | 0.59
forms/Validators | 1,900 | 0.59
common/http/HttpHeaders | 1,790 | 0.56
core/Pipe | 1,673 | 0.52
common/NgSwitch | 1,670 | 0.52
forms/NgForm | 1,597 | 0.50
core/Renderer2 | 1,562 | 0.49
core/HostListener | 1,501 | 0.47
common/AsyncPipe | 1,447 | 0.45
core/ViewContainerRef | 1,367 | 0.42
common/NgTemplateOutlet | 1,337 | 0.42
common/Location | 1,306 | 0.41
platform-browser/BrowserModule | 1,281 | 0.40
common/DecimalPipe | 1,275 | 0.40
common/CurrencyPipe | 1,260 | 0.39
router/RouterLinkActive | 1,231 | 0.38
core/TemplateRef | 1,212 | 0.38
forms/FormBuilder | 1,205 | 0.37
common/http/HttpParams | 1,131 | 0.35
core/OnChanges | 1,116 | 0.35
forms/FormControlName | 1,082 | 0.34
core/Output | 1,067 | 0.33
common/http/HttpInterceptor | 968 | 0.30
common/http/HttpRequest | 925 | 0.29
router/CanActivate | 863 | 0.27
router | 848 | 0.26
animations/style | 804 | 0.25
common/SlicePipe | 799 | 0.25
router/Event | 796 | 0.25
common/JsonPipe | 793 | 0.25
forms/FormArray | 792 | 0.25
common/CommonModule | 787 | 0.24
router/NavigationExtras | 776 | 0.24
core/HostBinding | 732 | 0.23
core/ContentChild | 719 | 0.22
core/ViewChildren | 717 | 0.22
common/http/HttpResponse | 714 | 0.22
router/ActivatedRouteSnapshot | 700 | 0.22
common/http | 683 | 0.21
core/ChangeDetectorRef | 670 | 0.21
router/NavigationStart | 663 | 0.21
common/formatDate | 662 | 0.21
core/ComponentFactoryResolver | 638 | 0.20
forms/Form | 635 | 0.20
common/http/HttpErrorResponse | 629 | 0.20
core/QueryList | 620 | 0.19
forms | 618 | 0.19
animations/state | 598 | 0.19
common | 596 | 0.19
router/LoadChildren | 593 | 0.18
router/ParamMap | 588 | 0.18
animations/trigger | 584 | 0.18
router/RouterLinkWithHref | 584 | 0.18
core/AfterViewInit | 579 | 0.18
forms/ReactiveFormsModule | 576 | 0.18
common/http/HTTP_INTERCEPTORS | 574 | 0.18
platform-browser/DomSanitizer | 573 | 0.18
core/PipeTransform | 572 | 0.18
core/SimpleChange | 570 | 0.18
core/SimpleChanges | 568 | 0.18
forms/NgSelectOption | 560 | 0.17
common/PercentPipe | 557 | 0.17
forms/ValidatorFn | 557 | 0.17
http/RequestOptionsArgs | 551 | 0.17
animations/animation | 549 | 0.17
common/NgSwitchCase | 521 | 0.16
core/testing/async | 518 | 0.16
状态|URL|浏览量|占比
---|---|---|----
[x] |common/http/HttpClient | 7,263 | 2.26
[x] |common/NgForOf | 6,281 | 1.95
[x] |forms/NgModel | 5,648 | 1.75
[x] |core/Component | 5,582 | 1.73
[x] |common/NgIf | 4,940 | 1.53
[x] |core/NgModule | 4,097 | 1.27
[x] |router/Router | 4,049 | 1.26
[ ] |animations/animate | 3,817 | 1.19
[ ] |common/NgClass | 3,715 | 1.15
[ ] |common/DatePipe | 3,576 | 1.11
[ ] |forms/FormsModule | 3,381 | 1.05
[x] |core/Input | 3,354 | 1.04
[x] |core/EventEmitter | 3,202 | 0.99
[ ] |core/Injectable | 3,177 | 0.99
[ ] |forms/FormGroup | 3,096 | 0.96
[ ] |forms/FormControl | 3,034 | 0.94
[ ] |router/ActivatedRoute | 2,993 | 0.93
[ ] |forms/AbstractControl | 2,930 | 0.91
[ ] |router/RouterLink | 2,929 | 0.91
[ ] |core/ViewChild | 2,870 | 0.89
[x] |core/Directive | 2,767 | 0.86
[ ] |router/Routes | 2,331 | 0.72
[ ] |router/RouterModule | 2,227 | 0.69
[ ] |router/Route | 2,223 | 0.69
[ ] |common/http/HttpClientModule | 2,167 | 0.67
[ ] |core/ElementRef | 2,163 | 0.67
[ ] |core/OnInit | 2,136 | 0.66
[ ] |common/UpperCasePipe | 2,078 | 0.65
[ ] |common/NgStyle | 1,935 | 0.60
[ ] |router/RouterOutlet | 1,908 | 0.59
[ ] |forms/Validators | 1,900 | 0.59
[ ] |common/http/HttpHeaders | 1,790 | 0.56
[x] |core/Pipe | 1,673 | 0.52
[ ] |common/NgSwitch | 1,670 | 0.52
[ ] |forms/NgForm | 1,597 | 0.50
[ ] |core/Renderer2 | 1,562 | 0.49
[x] |core/HostListener | 1,501 | 0.47
[ ] |common/AsyncPipe | 1,447 | 0.45
[ ] |core/ViewContainerRef | 1,367 | 0.42
[ ] |common/NgTemplateOutlet | 1,337 | 0.42
[ ] |common/Location | 1,306 | 0.41
[ ] |platform-browser/BrowserModule | 1,281 | 0.40
[ ] |common/DecimalPipe | 1,275 | 0.40
[ ] |common/CurrencyPipe | 1,260 | 0.39
[ ] |router/RouterLinkActive | 1,231 | 0.38
[ ] |core/TemplateRef | 1,212 | 0.38
[ ] |forms/FormBuilder | 1,205 | 0.37
[ ] |common/http/HttpParams | 1,131 | 0.35
[ ] |core/OnChanges | 1,116 | 0.35
[ ] |forms/FormControlName | 1,082 | 0.34
[x] |core/Output | 1,067 | 0.33
[ ] |common/http/HttpInterceptor | 968 | 0.30
[ ] |common/http/HttpRequest | 925 | 0.29
[ ] |router/CanActivate | 863 | 0.27
[ ] |router | 848 | 0.26
[ ] |animations/style | 804 | 0.25
[ ] |common/SlicePipe | 799 | 0.25
[ ] |router/Event | 796 | 0.25
[ ] |common/JsonPipe | 793 | 0.25
[ ] |forms/FormArray | 792 | 0.25
[ ] |common/CommonModule | 787 | 0.24
[ ] |router/NavigationExtras | 776 | 0.24
[x] |core/HostBinding | 732 | 0.23
[x] |core/ContentChild | 719 | 0.22
[x] |core/ViewChildren | 717 | 0.22
[ ] |common/http/HttpResponse | 714 | 0.22
[ ] |router/ActivatedRouteSnapshot | 700 | 0.22
[ ] |common/http | 683 | 0.21
[ ] |core/ChangeDetectorRef | 670 | 0.21
[ ] |router/NavigationStart | 663 | 0.21
[ ] |common/formatDate | 662 | 0.21
[ ] |core/ComponentFactoryResolver | 638 | 0.20
[ ] |forms/Form | 635 | 0.20
[ ] |common/http/HttpErrorResponse | 629 | 0.20
[ ] |core/QueryList | 620 | 0.19
[ ] |forms | 618 | 0.19
[ ] |animations/state | 598 | 0.19
[ ] |common | 596 | 0.19
[ ] |router/LoadChildren | 593 | 0.18
[ ] |router/ParamMap | 588 | 0.18
[ ] |animations/trigger | 584 | 0.18
[ ] |router/RouterLinkWithHref | 584 | 0.18
[ ] |core/AfterViewInit | 579 | 0.18
[ ] |forms/ReactiveFormsModule | 576 | 0.18
[ ] |common/http/HTTP_INTERCEPTORS | 574 | 0.18
[ ] |platform-browser/DomSanitizer | 573 | 0.18
[ ] |core/PipeTransform | 572 | 0.18
[ ] |core/SimpleChange | 570 | 0.18
[ ] |core/SimpleChanges | 568 | 0.18
[ ] |forms/NgSelectOption | 560 | 0.17
[ ] |common/PercentPipe | 557 | 0.17
[ ] |forms/ValidatorFn | 557 | 0.17
[ ] |http/RequestOptionsArgs | 551 | 0.17
[ ] |animations/animation | 549 | 0.17
[ ] |common/NgSwitchCase | 521 | 0.16
[ ] |core/testing/async | 518 | 0.16
## 翻译方式
@ -111,4 +109,4 @@ core/testing/async | 518 | 0.16
## 翻译内容
优先翻译函数主形态(如在 `common/http/src/client.ts` 中它通常都是重载形式中的最后一个),先不翻译各个重载形态,否则工作量太大
优先翻译函数主形态(如在 `common/http/src/client.ts` 中它通常都是重载形式中的最后一个),可以先不翻译各个重载形态。

View File

@ -34,14 +34,18 @@ import {TreeNode, nodeChildrenAsMap} from './utils/tree';
*
* Represents the extra options used during navigation.
*
*
*
*/
export interface NavigationExtras {
/**
* Enables relative navigation from the current ActivatedRoute.
*
*
*
* Configuration:
*
*
*
* ```
* [{
* path: 'parent',
@ -58,6 +62,8 @@ export interface NavigationExtras {
*
* Navigate to list route from child route:
*
* `child` `list`
*
* ```
* @Component({...})
* class ChildComponent {
@ -74,6 +80,8 @@ export interface NavigationExtras {
/**
* Sets query parameters to the URL.
*
* URL
*
* ```
* // Navigate to /results?page=1
* this.router.navigate(['/results'], { queryParams: { page: 1 } });
@ -84,6 +92,8 @@ export interface NavigationExtras {
/**
* Sets the hash fragment for the URL.
*
* URL `#`
*
* ```
* // Navigate to /results#top
* this.router.navigate(['/results'], { fragment: 'top' });
@ -94,8 +104,12 @@ export interface NavigationExtras {
/**
* Preserves the query parameters for the next navigation.
*
* `?`
*
* deprecated, use `queryParamsHandling` instead
*
* `queryParamsHandling`
*
* ```
* // Preserve query params from /results?page=1 to /view?page=1
* this.router.navigate(['/view'], { preserveQueryParams: true });
@ -108,6 +122,8 @@ export interface NavigationExtras {
/**
* config strategy to handle the query parameters for the next navigation.
*
* `?`
*
* ```
* // from /results?page=1 to /view?page=1&page=2
* this.router.navigate(['/view'], { queryParams: { page: 2 }, queryParamsHandling: "merge" });
@ -117,6 +133,8 @@ export interface NavigationExtras {
/**
* Preserves the fragment for the next navigation
*
* `#`
*
* ```
* // Preserve fragment from /results#top to /view#top
* this.router.navigate(['/view'], { preserveFragment: true });
@ -126,6 +144,8 @@ export interface NavigationExtras {
/**
* Navigates without pushing a new state into history.
*
*
*
* ```
* // Navigate silently to /view
* this.router.navigate(['/view'], { skipLocationChange: true });
@ -135,6 +155,8 @@ export interface NavigationExtras {
/**
* Navigates while replacing the current state in history.
*
*
*
* ```
* // Navigate to /view
* this.router.navigate(['/view'], { replaceUrl: true });
@ -148,10 +170,14 @@ export interface NavigationExtras {
*
* Error handler that is invoked when a navigation errors.
*
*
*
* If the handler returns a value, the navigation promise will be resolved with this value.
* If the handler throws an exception, the navigation promise will be rejected with
* the exception.
*
* Promise 使resolve
* Promise 使reject
*
*/
export type ErrorHandler = (error: any) => any;
@ -208,8 +234,12 @@ function defaultRouterHook(snapshot: RouterStateSnapshot, runExtras: {
*
* Provides the navigation and url manipulation capabilities.
*
* URL
*
* See `Routes` for more details and examples.
*
* `Routes`
*
* @ngModule RouterModule
*
*
@ -231,7 +261,11 @@ export class Router {
/**
* Error handler that is invoked when a navigation errors.
*
*
*
* See `ErrorHandler` for more information.
*
* `ErrorHandler`
*/
errorHandler: ErrorHandler = defaultErrorHandler;
@ -239,6 +273,9 @@ export class Router {
* Malformed uri error handler is invoked when `Router.parseUrl(url)` throws an
* error due to containing an invalid character. The most common case would be a `%` sign
* that's not encoded and is not part of a percent encoded sequence.
*
* uri `Router.parseUrl(url)` `url`
* `%` `%`
*/
malformedUriErrorHandler:
(error: URIError, urlSerializer: UrlSerializer,
@ -246,6 +283,8 @@ export class Router {
/**
* Indicates if at least one navigation happened.
*
*
*/
navigated: boolean = false;
private lastSuccessfulId: number = -1;
@ -262,6 +301,8 @@ export class Router {
/**
* Extracts and merges URLs. Used for AngularJS to Angular migrations.
*
* URL AngularJS Angular
*/
urlHandlingStrategy: UrlHandlingStrategy = new DefaultUrlHandlingStrategy();
@ -272,6 +313,10 @@ export class Router {
* By default, the router will ignore this navigation. However, this prevents features such
* as a "refresh" button. Use this option to configure the behavior when navigating to the
* current URL. Default is 'ignore'.
*
* URL
* "刷新"
* 使 URL 'ignore'
*/
onSameUrlNavigation: 'reload'|'ignore' = 'ignore';
@ -279,9 +324,17 @@ export class Router {
* Defines how the router merges params, data and resolved data from parent to child
* routes. Available options are:
*
*
*
* - `'emptyOnly'`, the default, only inherits parent params for path-less or component-less
* routes.
*
* `'emptyOnly'`
*
* - `'always'`, enables unconditional inheritance of parent params.
*
* `'always'`
*
*/
paramsInheritanceStrategy: 'emptyOnly'|'always' = 'emptyOnly';
@ -292,18 +345,31 @@ export class Router {
* URL early so if navigation fails, you can show an error message with the URL that failed.
* Available options are:
*
* URL
* URL URL
*
*
* - `'deferred'`, the default, updates the browser URL after navigation has finished.
*
* `'deferred'` URL
*
* - `'eager'`, updates browser URL at the beginning of navigation.
*
* `'eager'` URL
*/
urlUpdateStrategy: 'deferred'|'eager' = 'deferred';
/**
* See {@link RouterModule} for more information.
*
* {@link RouterModule}
*/
relativeLinkResolution: 'legacy'|'corrected' = 'legacy';
/**
* Creates the router service.
*
*
*/
// TODO: vsavkin make internal after the final is out.
constructor(
@ -337,6 +403,8 @@ export class Router {
/**
* Sets up the location change listener and performs the initial navigation.
*
*
*/
initialNavigation(): void {
this.setUpLocationChangeListener();
@ -347,6 +415,8 @@ export class Router {
/**
* Sets up the location change listener.
*
*
*/
setUpLocationChangeListener(): void {
// Don't need to use Zone.wrap any more, because zone.js
@ -365,7 +435,10 @@ export class Router {
}
}
/** The current url */
/** The current url
*
* URL
*/
get url(): string { return this.serializeUrl(this.currentUrlTree); }
/** @internal */
@ -374,8 +447,12 @@ export class Router {
/**
* Resets the configuration used for navigation and generating links.
*
* 使
*
* ### Usage
*
* ###
*
* ```
* router.resetConfig([
* { path: 'team/:id', component: TeamCmp, children: [
@ -395,7 +472,10 @@ export class Router {
/** @docsNotRequired */
ngOnDestroy(): void { this.dispose(); }
/** Disposes of the router */
/** Disposes of the router
*
*
*/
dispose(): void {
if (this.locationSubscription) {
this.locationSubscription.unsubscribe();
@ -406,11 +486,18 @@ export class Router {
/**
* Applies an array of commands to the current url tree and creates a new url tree.
*
* URL URL
*
* When given an activate route, applies the given commands starting from the route.
* When not given a route, applies the given command starting from the root.
*
*
*
*
* ### Usage
*
* ###
*
* ```
* // create /team/33/user/11
* router.createUrlTree(['/team', 33, 'user', 11]);
@ -476,13 +563,28 @@ export class Router {
/**
* Navigate based on the provided url. This navigation is always absolute.
*
* url 使
*
* Returns a promise that:
*
* Promise
*
* - resolves to 'true' when navigation succeeds,
*
* `'true'`
*
* - resolves to 'false' when navigation fails,
*
* `'false'`
*
* - is rejected when an error happens.
*
* reject
*
* ### Usage
*
* ###
*
* ```
* router.navigateByUrl("/team/33/user/11");
*
@ -492,6 +594,8 @@ export class Router {
*
* In opposite to `navigate`, `navigateByUrl` takes a whole URL
* and does not apply any delta to the current one.
*
* `navigate` `navigateByUrl` URL URL
*/
navigateByUrl(url: string|UrlTree, extras: NavigationExtras = {skipLocationChange: false}):
Promise<boolean> {
@ -505,13 +609,29 @@ export class Router {
* Navigate based on the provided array of commands and a starting point.
* If no starting route is provided, the navigation is absolute.
*
*
*
*
* Returns a promise that:
*
* Promise
*
* - resolves to 'true' when navigation succeeds,
*
* `'true'`
*
* - resolves to 'false' when navigation fails,
*
* `'false'`
*
* - is rejected when an error happens.
*
* reject
*
* ### Usage
*
* ###
*
* ```
* router.navigate(['team', 33, 'user', 11], {relativeTo: route});
*
@ -528,10 +648,16 @@ export class Router {
return this.navigateByUrl(this.createUrlTree(commands, extras), extras);
}
/** Serializes a `UrlTree` into a string */
/** Serializes a `UrlTree` into a string
*
* `UrlTree`
*/
serializeUrl(url: UrlTree): string { return this.urlSerializer.serialize(url); }
/** Parses a string into a `UrlTree` */
/** Parses a string into a `UrlTree`
*
* `UrlTree`
*/
parseUrl(url: string): UrlTree {
let urlTree: UrlTree;
try {
@ -542,7 +668,10 @@ export class Router {
return urlTree;
}
/** Returns whether the url is activated */
/** Returns whether the url is activated
*
* `url`
*/
isActive(url: string|UrlTree, exact: boolean): boolean {
if (url instanceof UrlTree) {
return containsTree(this.currentUrlTree, url, exact);
@ -789,6 +918,8 @@ export class Router {
/**
* Performs the logic of activating routes. This is a synchronous process by default. While this
* is a private method, it could be overridden to make activation asynchronous.
*
*
*/
private activateRoutes(
state: Observable<false|