From 0eaf9156de4581fe0c2ba6474fb65e33ed9525ec Mon Sep 17 00:00:00 2001 From: Zhicheng Wang Date: Sun, 6 Aug 2017 13:37:25 +0800 Subject: [PATCH] fix: use new translation logic --- aio/content/guide/ajs-quick-reference.md | 2 - aio/content/guide/browser-support.md | 69 ++++++++++++------- aio/content/guide/ngmodule-faq.md | 1 - aio/content/guide/visual-studio-2015.md | 2 - .../layout/doc-viewer/doc-viewer.component.ts | 17 ++++- .../remark-package/services/translator.js | 2 +- 6 files changed, 59 insertions(+), 34 deletions(-) diff --git a/aio/content/guide/ajs-quick-reference.md b/aio/content/guide/ajs-quick-reference.md index 9f1b0f19ee..21fa16a44d 100644 --- a/aio/content/guide/ajs-quick-reference.md +++ b/aio/content/guide/ajs-quick-reference.md @@ -2,8 +2,6 @@ # 从 AngularJS 到 Angular 快速参考 -// TODO: bugfix - {@a top} diff --git a/aio/content/guide/browser-support.md b/aio/content/guide/browser-support.md index c99fa8db32..4b1ff991de 100644 --- a/aio/content/guide/browser-support.md +++ b/aio/content/guide/browser-support.md @@ -226,9 +226,7 @@ Angular 在持续集成过程中,对每一个提交都会使用 closure compiler. diff --git a/aio/content/guide/ngmodule-faq.md b/aio/content/guide/ngmodule-faq.md index 81c4791671..738ac97b6e 100644 --- a/aio/content/guide/ngmodule-faq.md +++ b/aio/content/guide/ngmodule-faq.md @@ -806,7 +806,6 @@ The application would fail the moment a user navigated to "Heroes". {@a q-component-or-module} -// TODO: bugfix ## Should I add other providers to a module or a component? ## 我应该把其它提供商注册到模块中还是组件中? diff --git a/aio/content/guide/visual-studio-2015.md b/aio/content/guide/visual-studio-2015.md index ec62f48ea2..65b1f0b7f4 100644 --- a/aio/content/guide/visual-studio-2015.md +++ b/aio/content/guide/visual-studio-2015.md @@ -313,8 +313,6 @@ Include the files in the Visual Studio project as follows:

第四步: 恢复需要的包

-// TODO: bugfix - Restore the packages required for an Angular application as follows: 按下面的步骤恢复Angular应用程序需要的包: diff --git a/aio/src/app/layout/doc-viewer/doc-viewer.component.ts b/aio/src/app/layout/doc-viewer/doc-viewer.component.ts index 8907f83819..eefd830101 100644 --- a/aio/src/app/layout/doc-viewer/doc-viewer.component.ts +++ b/aio/src/app/layout/doc-viewer/doc-viewer.component.ts @@ -12,10 +12,10 @@ import { OnDestroy, Output, } from '@angular/core'; +import { Title } from '@angular/platform-browser'; +import { DocumentContents } from 'app/documents/document.service'; 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'; interface EmbeddedComponentFactory { @@ -51,6 +51,7 @@ export class DocViewerComponent implements DoCheck, OnDestroy { this.hostElement = elementRef.nativeElement; // Security: the initialDocViewerContent comes from the prerendered DOM and is considered to be secure this.hostElement.innerHTML = initialDocViewerContent; + this.swapOriginAndResult(this.hostElement); for (const component of embeddedComponents.components) { 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 // and is considered to be safe this.hostElement.innerHTML = doc.contents || ''; + this.swapOriginAndResult(this.hostElement); if (!doc.contents) { 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); + } + } + } } diff --git a/aio/tools/transforms/remark-package/services/translator.js b/aio/tools/transforms/remark-package/services/translator.js index 54ae070db3..b72446bb55 100644 --- a/aio/tools/transforms/remark-package/services/translator.js +++ b/aio/tools/transforms/remark-package/services/translator.js @@ -10,7 +10,7 @@ function swap(text) { } function markAndSwap(text) { - return swap(mark(text)); + return mark(text); } function isTranslation(text) {