From 3634128ffff122b0e28fa7255f4137ed5fa8325f Mon Sep 17 00:00:00 2001 From: Zhicheng Wang Date: Fri, 13 May 2016 13:00:21 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=9D=E6=AD=A5=E5=AE=9E=E7=8E=B0=E4=BA=86?= =?UTF-8?q?=E5=AF=B9=E7=85=A7=E7=BF=BB=E8=AF=91=E5=8A=9F=E8=83=BD=EF=BC=9A?= =?UTF-8?q?=E8=87=AA=E5=8A=A8=E9=9A=90=E8=97=8F=E5=8E=9F=E6=96=87=EF=BC=8C?= =?UTF-8?q?=E5=B9=B6=E6=8A=8A=E5=8E=9F=E6=96=87=E7=9A=84=E6=96=87=E6=9C=AC?= =?UTF-8?q?=E5=86=85=E5=AE=B9=E8=AE=BE=E7=BD=AE=E4=B8=BA=E8=AF=91=E6=96=87?= =?UTF-8?q?=E7=9A=84title?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/_includes/_scripts-include.jade | 1 + public/about/index.jade | 1 + public/docs/ts/latest/quickstart.jade | 41 +++++++++++++------------- public/index.jade | 2 +- public/resources/css/_translate.scss | 3 ++ public/resources/css/main.scss | 1 + public/resources/js/translate.js | 38 ++++++++++++++++++++++++ 7 files changed, 66 insertions(+), 21 deletions(-) create mode 100644 public/resources/css/_translate.scss create mode 100644 public/resources/js/translate.js diff --git a/public/_includes/_scripts-include.jade b/public/_includes/_scripts-include.jade index 7170fb57de..5dd3407ed7 100644 --- a/public/_includes/_scripts-include.jade +++ b/public/_includes/_scripts-include.jade @@ -15,6 +15,7 @@ script(src="/resources/js/vendor/angular-material.min.js") +script(src="/resources/js/translate.js") script(src="/resources/js/site.js") script(src="/resources/js/controllers/app-controller.js") script(src="/resources/js/directives/cheatsheet.js") diff --git a/public/about/index.jade b/public/about/index.jade index 14f24c232f..d49f225fbd 100644 --- a/public/about/index.jade +++ b/public/about/index.jade @@ -8,6 +8,7 @@ making web development feel effortless. We believe that writing beautiful apps should be joyful and fun. We're building a platform for the future. + p.text-body. Angular由一个工程师组织打造,我们拥有共同的热情 —— 让Web开发变得更简单。我们深信,写漂亮的程序快乐而有趣。 我们正在构建一个面向未来的平台。 diff --git a/public/docs/ts/latest/quickstart.jade b/public/docs/ts/latest/quickstart.jade index 23b67b46fd..f5a8432d3c 100644 --- a/public/docs/ts/latest/quickstart.jade +++ b/public/docs/ts/latest/quickstart.jade @@ -53,9 +53,9 @@ figure.image-display 在此日程中,我们将会看到很多代码块。它们都很容易拷贝和粘贴: 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)"). Hide explanations @@ -82,6 +82,7 @@ a(id="devenv") ## 开发环境 We need to set up our development environment: + 我们要设置开发环境: * install node and npm * 安装 node 和 npm @@ -804,23 +805,23 @@ figure.image-display quickstart/ts/typings/typings.d.1.ts +makeTabs(` - quickstart/ts/app/app.component.ts, - quickstart/ts/app/main.ts, - quickstart/ts/index.html, - quickstart/ts/package.1.json, - quickstart/ts/tsconfig.1.json, - quickstart/ts/typings.1.json, - quickstart/ts/styles.1.css, - quickstart/ts/system.config.1.js` - ,null, - `app/app.component.ts, - app/main.ts, - index.html, - package.json, - tsconfig.json, - typings.json, - styles.css, - system.config.js`) + quickstart/ts/app/app.component.ts, +quickstart / ts / app / main.ts, +quickstart / ts / index.html, +quickstart / ts / package.1.json, +quickstart / ts / tsconfig.1.json, +quickstart / ts / typings.1.json, +quickstart / ts / styles.1.css, +quickstart / ts / system.config.1.js` +,null, +`app/app.component.ts, +app / main.ts, +index.html, +package.json, +tsconfig.json, +typings.json, +styles.css, +system.config.js`) :marked .l-main-section diff --git a/public/index.jade b/public/index.jade index 44c1a3da9c..03e914c839 100644 --- a/public/index.jade +++ b/public/index.jade @@ -60,7 +60,7 @@ div(class="home-rows") div(class="promo-img-container promo-4") div img(src="resources/images/home/loved-by-millions.png") - + .cta-bar a(href="/docs/ts/latest/quickstart.html" class="button button-large button-shield md-raised " + "md-primary" md-button) 立即开始 diff --git a/public/resources/css/_translate.scss b/public/resources/css/_translate.scss new file mode 100644 index 0000000000..2724ccfa28 --- /dev/null +++ b/public/resources/css/_translate.scss @@ -0,0 +1,3 @@ +.hidden { + display: none !important; +} diff --git a/public/resources/css/main.scss b/public/resources/css/main.scss index 27b87b088d..ac1749935a 100644 --- a/public/resources/css/main.scss +++ b/public/resources/css/main.scss @@ -9,6 +9,7 @@ @import 'theme'; @import 'base/reset'; @import 'base/type'; +@import "translate"; @import 'angular'; diff --git a/public/resources/js/translate.js b/public/resources/js/translate.js new file mode 100644 index 0000000000..2d615da58c --- /dev/null +++ b/public/resources/js/translate.js @@ -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); + } +})();