fix: translate more

fix: a NPE
This commit is contained in:
Zhicheng Wang 2017-08-01 13:05:28 +08:00
parent 92a739099d
commit 2a0c436347
3 changed files with 5 additions and 5 deletions

View File

@ -1,12 +1,12 @@
<span [ngSwitch]="mode"> <span [ngSwitch]="mode">
<span *ngSwitchCase="'disabled'">{{title}} <em>(not available on this device)</em></span> <span *ngSwitchCase="'disabled'">{{title}} <em>(在此设备上不可用)</em></span>
<span *ngSwitchCase="'embedded'"> <span *ngSwitchCase="'embedded'">
<div *ngIf="showEmbedded" title="{{title}}"> <div *ngIf="showEmbedded" title="{{title}}">
<aio-embedded-plunker [src]="plnkr"></aio-embedded-plunker> <aio-embedded-plunker [src]="plnkr"></aio-embedded-plunker>
</div> </div>
<img *ngIf="!showEmbedded" (click)="toggleEmbedded()" [src]="plnkrImg" alt="{{title}}"> <img *ngIf="!showEmbedded" (click)="toggleEmbedded()" [src]="plnkrImg" alt="{{title}}">
<p *ngIf="enableDownload"> <p *ngIf="enableDownload">
You can also <a [href]="zip" download title="Download example">download this example</a>. 你还可以 <a [href]="zip" download title="下载范例">下载这个例子</a>
</p> </p>
</span> </span>
<span *ngSwitchCase="'downloadOnly'"> <span *ngSwitchCase="'downloadOnly'">
@ -15,7 +15,7 @@
<span *ngSwitchDefault> <span *ngSwitchDefault>
<a [href]="plnkr" target="_blank" title="{{title}}">{{title}}</a> <a [href]="plnkr" target="_blank" title="{{title}}">{{title}}</a>
<span *ngIf="enableDownload"> <span *ngIf="enableDownload">
/ <a [href]="zip" download title="Download example">download example</a> / <a [href]="zip" download title="下载范例">下载范例</a>
</span> </span>
</span> </span>
</span> </span>

View File

@ -145,7 +145,7 @@ export class LiveExampleComponent implements OnInit {
// It is the original innerHTML of the host element. // It is the original innerHTML of the host element.
// Angular will sanitize this title when displayed so should be plain text. // Angular will sanitize this title when displayed so should be plain text.
const title = this.elementRef.nativeElement.liveExampleContent; const title = this.elementRef.nativeElement.liveExampleContent;
this.title = (title || this.attrs.title || 'live example').trim(); this.title = (title || this.attrs.title || '在线例子').trim();
this.onResize(window.innerWidth); this.onResize(window.innerWidth);
} }

View File

@ -76,7 +76,7 @@ export class TocService {
private isOriginalText(heading: HTMLHeadingElement): boolean { private isOriginalText(heading: HTMLHeadingElement): boolean {
if (heading && heading.hasAttribute('translation-origin')) { if (heading && heading.hasAttribute('translation-origin')) {
const prevNode = heading.previousElementSibling; const prevNode = heading.previousElementSibling;
if (prevNode.hasAttribute('translation-result')) { if (prevNode && prevNode.hasAttribute('translation-result')) {
return true; return true;
} }
} }