初步实现了对照翻译功能:自动隐藏原文,并把原文的文本内容设置为译文的title
This commit is contained in:
parent
9824aca0fe
commit
3634128fff
|
@ -15,6 +15,7 @@ script(src="/resources/js/vendor/angular-material.min.js")
|
||||||
|
|
||||||
|
|
||||||
<!-- Angular.io Site JS -->
|
<!-- Angular.io Site JS -->
|
||||||
|
script(src="/resources/js/translate.js")
|
||||||
script(src="/resources/js/site.js")
|
script(src="/resources/js/site.js")
|
||||||
script(src="/resources/js/controllers/app-controller.js")
|
script(src="/resources/js/controllers/app-controller.js")
|
||||||
script(src="/resources/js/directives/cheatsheet.js")
|
script(src="/resources/js/directives/cheatsheet.js")
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
making web development feel effortless. We believe that writing
|
making web development feel effortless. We believe that writing
|
||||||
beautiful apps should be joyful and fun. We're building a
|
beautiful apps should be joyful and fun. We're building a
|
||||||
platform for the future.
|
platform for the future.
|
||||||
|
p.text-body.
|
||||||
Angular由一个工程师组织打造,我们拥有共同的热情 —— 让Web开发变得更简单。我们深信,写漂亮的程序快乐而有趣。
|
Angular由一个工程师组织打造,我们拥有共同的热情 —— 让Web开发变得更简单。我们深信,写漂亮的程序快乐而有趣。
|
||||||
我们正在构建一个面向未来的平台。
|
我们正在构建一个面向未来的平台。
|
||||||
|
|
||||||
|
|
|
@ -53,9 +53,9 @@ figure.image-display
|
||||||
|
|
||||||
在此日程中,我们将会看到很多代码块。它们都很容易拷贝和粘贴:
|
在此日程中,我们将会看到很多代码块。它们都很容易拷贝和粘贴:
|
||||||
code-example(format='.', language='html').
|
code-example(format='.', language='html').
|
||||||
Click the glyph on the right to copy code snippets to the clipboard ⇨⇨⇨⇨⇨⇨⇨⇨⇨⇨
|
Click the glyph on the right to copy code snippets to the clipboard ==========>
|
||||||
|
|
||||||
点击右边的图标来把代码片段拷贝到剪贴板 ⇨⇨⇨⇨⇨⇨⇨⇨⇨⇨
|
点击右边的图标来把代码片段拷贝到剪贴板 ==========>
|
||||||
|
|
||||||
button(class="verbose off md-primary md-button md-ink-ripple", type="button", onclick="verbose(false)").
|
button(class="verbose off md-primary md-button md-ink-ripple", type="button", onclick="verbose(false)").
|
||||||
Hide explanations
|
Hide explanations
|
||||||
|
@ -82,6 +82,7 @@ a(id="devenv")
|
||||||
## 开发环境
|
## 开发环境
|
||||||
|
|
||||||
We need to set up our development environment:
|
We need to set up our development environment:
|
||||||
|
|
||||||
我们要设置开发环境:
|
我们要设置开发环境:
|
||||||
* install node and npm
|
* install node and npm
|
||||||
* 安装 node 和 npm
|
* 安装 node 和 npm
|
||||||
|
@ -804,23 +805,23 @@ figure.image-display
|
||||||
|
|
||||||
quickstart/ts/typings/typings.d.1.ts
|
quickstart/ts/typings/typings.d.1.ts
|
||||||
+makeTabs(`
|
+makeTabs(`
|
||||||
quickstart/ts/app/app.component.ts,
|
quickstart/ts/app/app.component.ts,
|
||||||
quickstart/ts/app/main.ts,
|
quickstart / ts / app / main.ts,
|
||||||
quickstart/ts/index.html,
|
quickstart / ts / index.html,
|
||||||
quickstart/ts/package.1.json,
|
quickstart / ts / package.1.json,
|
||||||
quickstart/ts/tsconfig.1.json,
|
quickstart / ts / tsconfig.1.json,
|
||||||
quickstart/ts/typings.1.json,
|
quickstart / ts / typings.1.json,
|
||||||
quickstart/ts/styles.1.css,
|
quickstart / ts / styles.1.css,
|
||||||
quickstart/ts/system.config.1.js`
|
quickstart / ts / system.config.1.js`
|
||||||
,null,
|
,null,
|
||||||
`app/app.component.ts,
|
`app/app.component.ts,
|
||||||
app/main.ts,
|
app / main.ts,
|
||||||
index.html,
|
index.html,
|
||||||
package.json,
|
package.json,
|
||||||
tsconfig.json,
|
tsconfig.json,
|
||||||
typings.json,
|
typings.json,
|
||||||
styles.css,
|
styles.css,
|
||||||
system.config.js`)
|
system.config.js`)
|
||||||
:marked
|
:marked
|
||||||
|
|
||||||
.l-main-section
|
.l-main-section
|
||||||
|
|
|
@ -60,7 +60,7 @@ div(class="home-rows")
|
||||||
div(class="promo-img-container promo-4")
|
div(class="promo-img-container promo-4")
|
||||||
div
|
div
|
||||||
img(src="resources/images/home/loved-by-millions.png")
|
img(src="resources/images/home/loved-by-millions.png")
|
||||||
|
|
||||||
.cta-bar
|
.cta-bar
|
||||||
a(href="/docs/ts/latest/quickstart.html" class="button button-large button-shield md-raised " + "md-primary" md-button) 立即开始
|
a(href="/docs/ts/latest/quickstart.html" class="button button-large button-shield md-raised " + "md-primary" md-button) 立即开始
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,3 @@
|
||||||
|
.hidden {
|
||||||
|
display: none !important;
|
||||||
|
}
|
|
@ -9,6 +9,7 @@
|
||||||
@import 'theme';
|
@import 'theme';
|
||||||
@import 'base/reset';
|
@import 'base/reset';
|
||||||
@import 'base/type';
|
@import 'base/type';
|
||||||
|
@import "translate";
|
||||||
@import 'angular';
|
@import 'angular';
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,38 @@
|
||||||
|
(function () {
|
||||||
|
var targets = document.querySelectorAll('p, li, h1, h2, h3, h4, h5, h6, header, a, button');
|
||||||
|
_.each(targets, function (node) {
|
||||||
|
if (isTranslationResult(node)) {
|
||||||
|
var prevNode = node.previousElementSibling;
|
||||||
|
if (prevNode && !prevNode.classList.contains('nav-list-item')) {
|
||||||
|
prevNode.classList.add('hidden');
|
||||||
|
}
|
||||||
|
node.title = prevNode.innerText;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
function isOriginalEnglish(text) {
|
||||||
|
return /[\1-\255⇨]/.test(text);
|
||||||
|
}
|
||||||
|
|
||||||
|
function isClonedNode(node1, node2) {
|
||||||
|
return node1.parentNode === node2.parentNode && node1.tagName === node2.tagName && node1.className === node2.className;
|
||||||
|
}
|
||||||
|
|
||||||
|
function indexOf(node) {
|
||||||
|
var i = 0;
|
||||||
|
var aNode = node.parentNode.firstChild;
|
||||||
|
while (aNode !== node) {
|
||||||
|
++i;
|
||||||
|
if (aNode.tagName !== node.tagName) {
|
||||||
|
i = 0;
|
||||||
|
}
|
||||||
|
aNode = aNode.nextElementSibling;
|
||||||
|
}
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
|
||||||
|
function isTranslationResult(node) {
|
||||||
|
var prevNode = node.previousElementSibling;
|
||||||
|
return indexOf(node) % 2 === 1 && prevNode && isClonedNode(node, prevNode) && isOriginalEnglish(prevNode.innerText);
|
||||||
|
}
|
||||||
|
})();
|
Loading…
Reference in New Issue