Skip to content

Commit 9cd66b7

Browse files
committed
Merge pull request AlloyTeam#3 from kokdemo/master
translate a part of code guide
2 parents 2a10488 + 6592fa2 commit 9cd66b7

File tree

1 file changed

+37
-39
lines changed

1 file changed

+37
-39
lines changed

code-guide/index.html

Lines changed: 37 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ <h2>Table of contents</h2>
5454
</div>
5555
<div class="section toc">
5656
<div class="col">
57-
<h4><a href="#html">Naming Project</a></h4>
57+
<h4><a href="#html">命名规则</a></h4>
5858
<ul>
5959
<li><a href="#project-naming">项目名</a></li>
6060
<li><a href="#folder-naming">目录名</a></li>
@@ -68,10 +68,9 @@ <h4><a href="#html">HTML</a></h4>
6868
<ul>
6969
<li><a href="#html-syntax">语法</a></li>
7070
<li><a href="#html-doctype">HTML5 doctype</a></li>
71-
<li><a href="#html-lang">Language attribute</a></li>
71+
<li><a href="#html-lang">语言属性</a></li>
7272
<li><a href="#html-encoding">字符编码</a></li>
73-
<li><a href="#html-ie-compatibility-mode">Internet Explorer
74-
compatibility mode</a></li>
73+
<li><a href="#html-ie-compatibility-mode">IE 兼容模式</a></li>
7574
<li><a href="#html-style-script">引入 CSS 和 JavaScript</a></li>
7675
<li><a href="#html-practicality">实用高于完美</a></li>
7776
<li><a href="#html-attribute-order">属性顺序</a></li>
@@ -85,11 +84,10 @@ <h4><a href="#css">CSS</a></h4>
8584
<ul>
8685
<li><a href="#css-syntax">CSS 语法</a></li>
8786
<li><a href="#css-declaration-order">声明顺序</a></li>
88-
<li><a href="#css-import">Don't use @import</a></li>
89-
<li><a href="#css-media-queries">Media query placement</a></li>
87+
<li><a href="#css-import">不要使用 @import</a></li>
88+
<li><a href="#css-media-queries">Media query 的位置</a></li>
9089
<li><a href="#css-prefixed-properties">前缀属性</a></li>
91-
<li><a href="#css-single-declarations">Rules with single
92-
declarations</a></li>
90+
<li><a href="#css-single-declarations">单行声明的规则</a></li>
9391
<li><a href="#css-shorthand">属性简写</a></li>
9492
<li><a href="#css-nesting">LESS 和 SASS 中的嵌套</a></li>
9593
<li><a href="#css-comments">代码注释</a></li>
@@ -101,14 +99,14 @@ <h4><a href="#css">CSS</a></h4>
10199
<div class="col">
102100
<h4><a href="#javascript">JavaScript</a></h4>
103101
<ul>
104-
<li><a href="#js-indentation">Indentation,分号,单行长度</a></li>
102+
<li><a href="#js-indentation">缩进,分号,单行长度</a></li>
105103
<li><a href="#js-blank-lines">空行</a></li>
106104
<li><a href="#js-variable-naming">变量命名</a></li>
107105
<li><a href="#js-literal-value-string">字符常量</a></li>
108106
<li><a href="#js-literal-value-null">null使用场景</a></li>
109107
<li><a href="#js-literal-value-undefined">undefined使用场景</a></li>
110-
<li><a href="#js-literal-value-object">Object Literals</a></li>
111-
<li><a href="#js-literal-value-array">Array Literals</a></li>
108+
<li><a href="#js-literal-value-object">Object 的声明</a></li>
109+
<li><a href="#js-literal-value-array">Array 的声明</a></li>
112110
<li><a href="#js-comments-single-line">单行注释</a></li>
113111
<li><a href="#js-comments-multiline">多行注释</a></li>
114112
<li><a href="#js-comments-documentation">文档注释</a></li>
@@ -126,12 +124,12 @@ <h4><a href="#javascript">JavaScript</a></h4>
126124

127125
<div class="section" id="golden-rule">
128126
<div class="col">
129-
<h2>Golden rule</h2>
130-
<p>Enforce these, or your own, agreed upon guidelines at all times. Small or large, call out what's incorrect. For additions or contributions to this Code Guide, please <a href="https://github.com/materliu/code-guide/issues/new">open an issue on GitHub</a>.</p>
127+
<h2>最佳原则</h2>
128+
<p>坚持这些原则。无论多少,找出不对的地方。如果你想要为这个编码指导做贡献,请访问<a href="https://github.com/materliu/code-guide/issues/new">新开一个issue</a>.</p>
131129
</div>
132130
<div class="col">
133131
<blockquote>
134-
<p>Every line of code should appear to be written by a single person, no matter the number of contributors.</p>
132+
<p>无论人数多少,代码都应该同出一门。</p>
135133
</blockquote>
136134
</div>
137135
</div>
@@ -222,13 +220,13 @@ <h3>HTML5 doctype</h3>
222220

223221
<div class="section" id="html-lang">
224222
<div class="col">
225-
<h3>Language attribute</h3>
226-
<p>From the HTML5 spec:</p>
223+
<h3>语言属性</h3>
224+
<p>针对HTML5 :</p>
227225
<blockquote>
228-
<p>Authors are encouraged to specify a lang attribute on the root html element, giving the document's language. This aids speech synthesis tools to determine what pronunciations to use, translation tools to determine what rules to use, and so forth.</p>
226+
<p>作者应在html的跟元素上加上这个文件的语言。这会给语音工具和翻译工具帮助,告诉它们应当怎么去发音和翻译。</p>
229227
</blockquote>
230-
<p>Read more about the <code>lang</code> attribute <a href="http://www.w3.org/html/wg/drafts/html/master/semantics.html#the-html-element">in the spec</a>.</p>
231-
<p>Head to Sitepoint for a <a href="http://reference.sitepoint.com/html/lang-codes">list of language codes</a>.</p>
228+
<p>阅读更多有关 <code>lang</code> 属性 <a href="http://www.w3.org/html/wg/drafts/html/master/semantics.html#the-html-element">在这个文章中</a>.</p>
229+
<p>通过Sitepoint 得到一个<a href="http://reference.sitepoint.com/html/lang-codes">语言代码列表</a>.</p>
232230
<p>Sitepoint只是给出了语言代码的大类,比如说中文就只给出了ZH,但是没有区分香港,台湾,大陆等。而微软给出的一份细分了zh-cn,zh-hk,zh-tw, Head to Microsoft for a <a href="http://msdn.microsoft.com/en-us/library/ms533052(v=vs.85).aspx">detail list of language codes</a>.</p>
233231
</div>
234232
<div class="col">
@@ -241,9 +239,9 @@ <h3>Language attribute</h3>
241239

242240
<div class="section" id="html-ie-compatibility-mode">
243241
<div class="col">
244-
<h3>IE compatibility mode</h3>
245-
<p>Internet Explorer supports the use of a document compatibility <code>&lt;meta&gt;</code> tag to specify what version of IE the page should be rendered as. Unless circumstances require otherwise, it's most useful to instruct IE to use the latest supported mode with <strong>edge mode</strong>.</p>
246-
<p>For more information, <a href="http://stackoverflow.com/questions/6771258/whats-the-difference-if-meta-http-equiv-x-ua-compatible-content-ie-edge-e">read this awesome Stack Overflow article</a>.</p>
242+
<h3>IE 兼容模式</h3>
243+
<p>Internet Explorer 支持使用一个文档属性标签 <code>&lt;meta&gt;</code> 来指出这个页面应当支持的IE的版本。除非另有规定,最好用最新的支持的模式。</p>
244+
<p>更多信息, <a href="http://stackoverflow.com/questions/6771258/whats-the-difference-if-meta-http-equiv-x-ua-compatible-content-ie-edge-e">阅读这个 Stack Overflow 文章</a>.</p>
247245
<p>不同doctype在不同浏览器下的不同渲染模式,诡异模式<a
248246
href="https://hsivonen.fi/doctype/">总结的很到位</a>.</p>
249247
</div>
@@ -627,14 +625,14 @@ <h3>声明顺序</h3>
627625

628626
<div class="section" id="css-import">
629627
<div class="col">
630-
<h3>Don't use <code>@import</code></h3>
631-
<p>Compared to <code>&lt;link&gt;</code>s, <code>@import</code> is slower, adds extra page requests, and can cause other unforeseen problems. Avoid them and instead opt for an alternate approach:</p>
628+
<h3>不要使用 <code>@import</code></h3>
629+
<p><code>&lt;link&gt;</code>标签相比, <code>@import</code> 更慢, 增加了额外的页面请求,可能还会导致不可预见的问题。避免使用它们,改用以下的方法:</p>
632630
<ul>
633-
<li>Use multiple <code>&lt;link&gt;</code> elements</li>
634-
<li>Compile your CSS with a preprocessor like Sass or Less into a single file</li>
635-
<li>Concatenate your CSS files with features provided in Rails, Jekyll, and other environments</li>
631+
<li>多用几个 <code>&lt;link&gt;</code> 标签</li>
632+
<li>将你的css编译到一个文件里</li>
633+
<li>用Rails, Jekyll,以及其他环境提供的特性来间接这些css</li>
636634
</ul>
637-
<p>For more information, <a href="http://www.stevesouders.com/blog/2009/04/09/dont-use-import/">read this article by Steve Souders</a>.</p>
635+
<p>更多信息, <a href="http://www.stevesouders.com/blog/2009/04/09/dont-use-import/">阅读 Steve Souders 的文章</a>.</p>
638636
</div>
639637
<div class="col">
640638
<div class="highlight"><pre><code class="html"><span class="c">&lt;!-- Use link elements --&gt;</span>
@@ -893,10 +891,10 @@ <h2>JavaScript</h2>
893891

894892
<div class="section" id="js-indentation">
895893
<div class="col">
896-
<h3>Indentation,分号,单行长度</h3>
894+
<h3>缩进,分号,单行长度</h3>
897895
<ul>
898896
<li>一律使用4个空格</li>
899-
<li>continuation-indentation 同样适用4个空格,跟上一行对齐</li>
897+
<li>连续缩进 同样适用4个空格,跟上一行对齐</li>
900898
<li>Statement 之后一律以分号结束, 不可以省略</li>
901899
<li>单行长度,理论上不要超过80列,不过如果编辑器开启 soft wrap 的话可以不考虑单行长度</li>
902900
<li>接上一条,如果需要换行,存在操作符的情况,一定在操作符后换行,然后换的行缩进4个空格</li>
@@ -970,15 +968,15 @@ <h3>字符常量</h3>
970968
<div class="col">
971969
<h3>null的使用场景</h3>
972970
<ul>
973-
<li>To initialize a variable that may later be assigned an object value</li>
974-
<li>To compare against an initialized variable that may or may not have an object value</li>
975-
<li>To pass into a function where an object is expected</li>
976-
<li>To return from a function where an object is expected</li>
971+
<li>初始化一个将来可能被声明为一个对象的变量。</li>
972+
<li>与一个可能是对象或者非对象的初始化变量相比。</li>
973+
<li>传入一个对象待定的函数。</li>
974+
<li>作为一个对象待定的函数的返回值。</li>
977975
</ul>
978976
<h3>不适合null的使用场景</h3>
979977
<ul>
980-
<li>Do not use null to test whether an argument was supplied</li>
981-
<li>Do not test an uninitialized variable for the value null</li>
978+
<li>不要使用null来测试一个一个变量是否存在。</li>
979+
<li>不要用null来测试一个没声明的变量。</li>
982980
</ul>
983981
</div>
984982
</div>
@@ -1089,9 +1087,9 @@ <h3>文档注释</h3>
10891087
</ul>
10901088
<h3>用在哪里</h3>
10911089
<ul>
1092-
<li>All methods</li>
1093-
<li>All constructors</li>
1094-
<li>All objects with documented methods</li>
1090+
<li>所有的方法</li>
1091+
<li>所有的构造函数</li>
1092+
<li>所有的全局变量</li>
10951093
</ul>
10961094
</div>
10971095
<div class="col">

0 commit comments

Comments
 (0)