-
Notifications
You must be signed in to change notification settings - Fork 8.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[zh-tw]: add translation of "Code Style Guide" #25791
base: main
Are you sure you want to change the base?
Conversation
files/zh-tw/mdn/writing_guidelines/writing_style_guide/code_style_guide/css/index.md
Outdated
Show resolved
Hide resolved
files/zh-tw/mdn/writing_guidelines/writing_style_guide/code_style_guide/html/index.md
Outdated
Show resolved
Hide resolved
files/zh-tw/mdn/writing_guidelines/writing_style_guide/code_style_guide/html/index.md
Outdated
Show resolved
Hide resolved
files/zh-tw/mdn/writing_guidelines/writing_style_guide/code_style_guide/javascript/index.md
Outdated
Show resolved
Hide resolved
files/zh-tw/mdn/writing_guidelines/writing_style_guide/code_style_guide/javascript/index.md
Outdated
Show resolved
Hide resolved
b463a7f
to
5ba8d10
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
请先按 #25774 提出的一些建议更新这些文档,后面会由 @jasonren0403 来审核当前 PR。
@yin1999 已根據您的建議修正好了。 |
9d0d9e0
to
02db967
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
一些修改建议
files/zh-tw/mdn/writing_guidelines/writing_style_guide/code_style_guide/index.md
Outdated
Show resolved
Hide resolved
files/zh-tw/mdn/writing_guidelines/writing_style_guide/code_style_guide/index.md
Outdated
Show resolved
Hide resolved
files/zh-tw/mdn/writing_guidelines/writing_style_guide/code_style_guide/index.md
Outdated
Show resolved
Hide resolved
files/zh-tw/mdn/writing_guidelines/writing_style_guide/code_style_guide/index.md
Outdated
Show resolved
Hide resolved
files/zh-tw/mdn/writing_guidelines/writing_style_guide/code_style_guide/index.md
Outdated
Show resolved
Hide resolved
files/zh-tw/mdn/writing_guidelines/writing_style_guide/code_style_guide/javascript/index.md
Outdated
Show resolved
Hide resolved
|
||
### 函式名稱 | ||
|
||
函式名稱應使用 {{Glossary("camel_case", "駝峰命名法")}},首個字母須為小寫。請選擇簡潔、易讀且具語意性的名稱,以提升可讀性。 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
函式名稱應使用 {{Glossary("camel_case", "駝峰命名法")}},首個字母須為小寫。請選擇簡潔、易讀且具語意性的名稱,以提升可讀性。 | |
函式名稱應使用{{Glossary("camel_case", "駝峰命名法")}},首個字母須為小寫。請選擇簡潔、易讀且具語意性的名稱,以提升可讀性。 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
已修正。
|
||
當需要用[迴圈](/zh-TW/docs/Learn_web_development/Core/Scripting/Loops)時,請根據需求選擇適當的迴圈類型,例如 [`for(;;)`](/zh-TW/docs/Web/JavaScript/Reference/Statements/for)、[`for-of`](/zh-TW/docs/Web/JavaScript/Reference/Statements/for-of)、[`while`](/zh-TW/docs/Web/JavaScript/Reference/Statements/while) 等等。 | ||
|
||
- 在遍歷集合元素時,請避免使用傳統 `for (;;)` 迴圈,建議使用 `for-of` 或 `forEach()`。請注意,若使用的集合並非 `陣列(Array)`,則須確認 `for-of` 是否支援(它要求變數可迭代),或確保 `forEach()` 方法是否存在。 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- 在遍歷集合元素時,請避免使用傳統 `for (;;)` 迴圈,建議使用 `for-of` 或 `forEach()`。請注意,若使用的集合並非 `陣列(Array)`,則須確認 `for-of` 是否支援(它要求變數可迭代),或確保 `forEach()` 方法是否存在。 | |
- 在遍歷集合元素時,請避免使用傳統 `for (;;)` 迴圈,建議使用 `for-of` 或 `forEach()`。請注意,若使用的集合並非 `Array`(陣列),則須確認 `for-of` 是否支援(它要求變數可迭代),或確保 `forEach()` 方法是否存在。 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
已修正。
files/zh-tw/mdn/writing_guidelines/writing_style_guide/code_style_guide/javascript/index.md
Outdated
Show resolved
Hide resolved
} | ||
``` | ||
|
||
The conditional operator is helpful when creating strings to log information. In such cases, using a regular `if...else` statement leads to long blocks of code for a side operation like logging, obfuscating the central point of the example. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这里遗漏了
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
了解,已補上翻譯。
|
||
### 條件運算子 | ||
|
||
當你需要根據條件將某個字面值存入變數時,請使用[三元運算子](/zh-TW/docs/Web/JavaScript/Reference/Operators/Conditional_operator) 來取代 `if-else` 陳述式。此規則同樣適用於回傳值的情境。請這樣撰寫: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
當你需要根據條件將某個字面值存入變數時,請使用[三元運算子](/zh-TW/docs/Web/JavaScript/Reference/Operators/Conditional_operator) 來取代 `if-else` 陳述式。此規則同樣適用於回傳值的情境。請這樣撰寫: | |
當你需要根據條件將某個字面值存入變數時,請使用[三元運算子](/zh-TW/docs/Web/JavaScript/Reference/Operators/Conditional_operator)來取代 `if-else` 陳述式。此規則同樣適用於回傳值的情境。請這樣撰寫: |
|
||
### 使用彈性/相對單位 | ||
|
||
為了在最廣裝置範圍內提供最大靈活性,建議使用相對單位來設定容器(container)、內距(padding)等大小,例如 `em`、`rem`,或使用百分比與視口單位(viewport units),以根據視口寬度動態調整。你可以在我們的 [CSS 值與單位指南](/zh-TW/docs/Learn_web_development/Core/Styling_basics/Values_and_units#relative_length_units)中閱讀更多相關資訊。 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
為了在最廣裝置範圍內提供最大靈活性,建議使用相對單位來設定容器(container)、內距(padding)等大小,例如 `em`、`rem`,或使用百分比與視口單位(viewport units),以根據視口寬度動態調整。你可以在我們的 [CSS 值與單位指南](/zh-TW/docs/Learn_web_development/Core/Styling_basics/Values_and_units#relative_length_units)中閱讀更多相關資訊。 | |
為了在最廣裝置範圍內提供最大靈活性,建議使用相對單位來設定容器(container)、內距(padding)等大小,例如 `em`、`rem`,或使用百分比與視口單位(viewport unit),以根據視口寬度動態調整。你可以在我們的 [CSS 值與單位指南](/zh-TW/docs/Learn_web_development/Core/Styling_basics/Values_and_units#relative_length_units)中閱讀更多相關資訊。 |
在 `if-else` 控制陳述中,有一個需要特別注意的情況。如果 `if` 陳述以 `return` 結束,就不用再寫 `else` 陳述。 | ||
|
||
請在 `if` 陳述後直接繼續撰寫程式碼。請這樣撰寫: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
在 `if-else` 控制陳述中,有一個需要特別注意的情況。如果 `if` 陳述以 `return` 結束,就不用再寫 `else` 陳述。 | |
請在 `if` 陳述後直接繼續撰寫程式碼。請這樣撰寫: | |
在 `if-else` 控制陳述式中,有一個需要特別注意的情況。如果 `if` 陳述以 `return` 結束,就不用再寫 `else` 陳述。 | |
請在 `if` 陳述式後直接繼續撰寫程式碼。請這樣撰寫: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
还有部分空格、复数和名词统一问题,可以看一下
如 https://github.com/mdn/translated-content/pull/25791/files#r1959255829
更新內容描述
基於 #25341 反映的翻譯文件同步需求,新增【Code Style Guide】文件及其目錄下的子文件翻譯。