fix: use new translation logic

This commit is contained in:
Zhicheng Wang 2017-08-06 13:37:25 +08:00
parent 4c2b0b51b7
commit 0eaf9156de
6 changed files with 59 additions and 34 deletions

View File

@ -2,8 +2,6 @@
# 从 AngularJS 到 Angular 快速参考 # 从 AngularJS 到 Angular 快速参考
// TODO: bugfix
{@a top} {@a top}

View File

@ -226,9 +226,7 @@ Angular 在持续集成过程中,对每一个提交都会使用 <a href="https
## Polyfills # ## Polyfills #
## 填充库 (polyfill) # ## 填充库 (polyfill) #
Angular is built on the latest standards of the web platform. Angular is built on the latest standards of the web platform.
Targeting such a wide range of browsers is challenging because they do not support all features of modern browsers. Targeting such a wide range of browsers is challenging because they do not support all features of modern browsers.
@ -275,9 +273,7 @@ Note that polyfills cannot magically transform an old, slow browser into a moder
### Mandatory polyfills ## ### Mandatory polyfills ##
### 强制性填充库 ## ### 强制性填充库 ##
These are the polyfills required to run an Angular application on each supported browser: These are the polyfills required to run an Angular application on each supported browser:
下表是填充库对每个支持的浏览器都是需要的: 下表是填充库对每个支持的浏览器都是需要的:
@ -289,17 +285,24 @@ These are the polyfills required to run an Angular application on each supported
<th> <th>
<p>
Browsers (Desktop & Mobile) Browsers (Desktop & Mobile)
</p>
<p>
浏览器(桌面和移动) 浏览器(桌面和移动)
</p>
</th> </th>
<th> <th>
<p>
Polyfills Required Polyfills Required
</p>
<p>
需要的填充库 需要的填充库
</p>
</th> </th>
@ -313,8 +316,6 @@ These are the polyfills required to run an Angular application on each supported
<td> <td>
None None
</td> </td>
</tr> </tr>
@ -344,18 +345,16 @@ These are the polyfills required to run an Angular application on each supported
[ES6<br>classList](guide/browser-support#classlist) [ES6<br>classList](guide/browser-support#classlist)
[ES6<br>classList](guide/browser-support#classlist) 支持
</td> </td>
</tr> </tr>
</table> </table>
### Optional browser features to polyfill ## ### Optional browser features to polyfill ##
### 可选浏览器特性的填充库 ## ### 可选浏览器特性的填充库 ##
Some features of Angular may require additional polyfills. Some features of Angular may require additional polyfills.
有些 Angular 特性可能需要额外的填充库。 有些 Angular 特性可能需要额外的填充库。
@ -440,9 +439,9 @@ Here are the features which may require additional polyfills:
</td> </td>
<td> <td>
All but Chrome, Firefox, Edge, IE11 and Safari 10 <p>All but Chrome, Firefox, Edge, IE11 and Safari 10</p>
除了 Chrome、Firefox、Edge、IE11 和 Safari 10 外的所有浏览器 <p>除了 Chrome、Firefox、Edge、IE11 和 Safari 10 外的所有浏览器</p>
</td> </td>
@ -452,9 +451,9 @@ Here are the features which may require additional polyfills:
<td> <td>
[NgClass](api/common/NgClass) on SVG elements <p>[NgClass](api/common/NgClass) on SVG elements</p>
在 SVG 元素上应用 [NgClass](api/common/NgClass) <p>在 SVG 元素上应用 [NgClass](api/common/NgClass)</p>
</td> </td>
<td> <td>
@ -473,9 +472,9 @@ Here are the features which may require additional polyfills:
<td> <td>
[Http](guide/http) when sending and receiving binary data <p>[Http](guide/http) when sending and receiving binary data</p>
用 [Http](guide/http) 发送和接收二进制数据 <p>用 [Http](guide/http) 发送和接收二进制数据</p>
</td> </td>
@ -508,24 +507,38 @@ Below are the polyfills which are used to test the framework itself. They are a
<tr> <tr>
<th> <th>
<p>
Polyfill Polyfill
</p>
<p>
填充库 填充库
</p>
</th> </th>
<th> <th>
<p>
Licence Licence
</p>
<p>
授权方式 授权方式
</p>
</th> </th>
<th> <th>
<p>
Size* Size*
</p>
<p>
大小* 大小*
</p>
</th> </th>
@ -555,9 +568,13 @@ Below are the polyfills which are used to test the framework itself. They are a
<td> <td>
<p>
Public domain Public domain
</p>
公共领域 <p>
公共域
</p>
</td> </td>
@ -649,7 +666,7 @@ Below are the polyfills which are used to test the framework itself. They are a
</table> </table>
// TODO: Bugfix
\* Figures are for minified and gzipped code, \* Figures are for minified and gzipped code,
computed with the <a href="http://closure-compiler.appspot.com/home" >closure compiler</a>. computed with the <a href="http://closure-compiler.appspot.com/home" >closure compiler</a>.

View File

@ -806,7 +806,6 @@ The application would fail the moment a user navigated to "Heroes".
{@a q-component-or-module} {@a q-component-or-module}
// TODO: bugfix
## Should I add other providers to a module or a component? ## Should I add other providers to a module or a component?
## 我应该把其它提供商注册到模块中还是组件中? ## 我应该把其它提供商注册到模块中还是组件中?

View File

@ -313,8 +313,6 @@ Include the files in the Visual Studio project as follows:
<h2 id='restore'> 第四步: 恢复需要的包 </h2> <h2 id='restore'> 第四步: 恢复需要的包 </h2>
// TODO: bugfix
Restore the packages required for an Angular application as follows: Restore the packages required for an Angular application as follows:
按下面的步骤恢复Angular应用程序需要的包 按下面的步骤恢复Angular应用程序需要的包

View File

@ -12,10 +12,10 @@ import {
OnDestroy, OnDestroy,
Output, Output,
} from '@angular/core'; } from '@angular/core';
import { Title } from '@angular/platform-browser';
import { DocumentContents } from 'app/documents/document.service';
import { EmbeddedComponents } from 'app/embedded/embedded.module'; import { EmbeddedComponents } from 'app/embedded/embedded.module';
import { DocumentContents } from 'app/documents/document.service';
import { Title } from '@angular/platform-browser';
import { TocService } from 'app/shared/toc.service'; import { TocService } from 'app/shared/toc.service';
interface EmbeddedComponentFactory { interface EmbeddedComponentFactory {
@ -51,6 +51,7 @@ export class DocViewerComponent implements DoCheck, OnDestroy {
this.hostElement = elementRef.nativeElement; this.hostElement = elementRef.nativeElement;
// Security: the initialDocViewerContent comes from the prerendered DOM and is considered to be secure // Security: the initialDocViewerContent comes from the prerendered DOM and is considered to be secure
this.hostElement.innerHTML = initialDocViewerContent; this.hostElement.innerHTML = initialDocViewerContent;
this.swapOriginAndResult(this.hostElement);
for (const component of embeddedComponents.components) { for (const component of embeddedComponents.components) {
const factory = componentFactoryResolver.resolveComponentFactory(component); const factory = componentFactoryResolver.resolveComponentFactory(component);
@ -77,6 +78,7 @@ export class DocViewerComponent implements DoCheck, OnDestroy {
// security: the doc.content is always authored by the documentation team // security: the doc.content is always authored by the documentation team
// and is considered to be safe // and is considered to be safe
this.hostElement.innerHTML = doc.contents || ''; this.hostElement.innerHTML = doc.contents || '';
this.swapOriginAndResult(this.hostElement);
if (!doc.contents) { if (!doc.contents) {
return; return;
@ -155,4 +157,15 @@ export class DocViewerComponent implements DoCheck, OnDestroy {
} }
} }
} }
swapOriginAndResult(root: Element): void {
const results = root.querySelectorAll('[translation-result]');
for (let i = 0; i < results.length; ++i) {
const result = results.item(i);
const origin = result.previousElementSibling;
if (origin && origin.hasAttribute('translation-origin')) {
origin.parentElement.insertBefore(result, origin);
}
}
}
} }

View File

@ -10,7 +10,7 @@ function swap(text) {
} }
function markAndSwap(text) { function markAndSwap(text) {
return swap(mark(text)); return mark(text);
} }
function isTranslation(text) { function isTranslation(text) {