Skip to content
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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

weixiang0815
Copy link
Contributor

更新內容描述

基於 #25341 反映的翻譯文件同步需求,新增【Code Style Guide】文件及其目錄下的子文件翻譯。

@weixiang0815 weixiang0815 requested a review from a team as a code owner February 8, 2025 19:51
@weixiang0815 weixiang0815 requested review from jasonren0403 and removed request for a team February 8, 2025 19:51
@github-actions github-actions bot added the l10n-zh Issues related to Chinese content. label Feb 8, 2025
Copy link
Contributor

github-actions bot commented Feb 8, 2025

Preview URLs

External URLs (17)

URL: /zh-TW/docs/MDN/Writing_guidelines/Writing_style_guide/Code_style_guide
Title: 程式碼範例寫作指南


URL: /zh-TW/docs/MDN/Writing_guidelines/Writing_style_guide/Code_style_guide/Shell
Title: Shell 提示字程式碼範例寫作指南


URL: /zh-TW/docs/MDN/Writing_guidelines/Writing_style_guide/Code_style_guide/HTML
Title: HTML 程式碼範例寫作指南


URL: /zh-TW/docs/MDN/Writing_guidelines/Writing_style_guide/Code_style_guide/JavaScript
Title: JavaScript 程式碼範例寫作指南


URL: /zh-TW/docs/MDN/Writing_guidelines/Writing_style_guide/Code_style_guide/CSS
Title: CSS 程式碼範例寫作指南

(comment last updated: 2025-02-14 09:04:45)

@weixiang0815 weixiang0815 requested review from a team as code owners February 11, 2025 15:29
@weixiang0815 weixiang0815 requested review from hochan222, JuanVqz, saionaro, kenji-yamasaki, cw118 and josielrocha and removed request for a team February 11, 2025 15:29
@github-actions github-actions bot added l10n-ja Issues related to Japanese content. l10n-fr Issues related to French content. l10n-es Issues related to Spanish content. l10n-ru Issues related to Russian content. labels Feb 11, 2025
@github-actions github-actions bot added l10n-pt-br Issues related to Brazilian Portuguese system Infrastructure and configuration for the project labels Feb 11, 2025
@weixiang0815 weixiang0815 marked this pull request as draft February 11, 2025 15:33
@weixiang0815 weixiang0815 force-pushed the code_style_guide_20250208 branch from b463a7f to 5ba8d10 Compare February 11, 2025 16:19
@github-actions github-actions bot removed l10n-ja Issues related to Japanese content. l10n-fr Issues related to French content. l10n-es Issues related to Spanish content. l10n-ru Issues related to Russian content. l10n-ko Issues related to Korean content. l10n-pt-br Issues related to Brazilian Portuguese system Infrastructure and configuration for the project labels Feb 11, 2025
@weixiang0815 weixiang0815 marked this pull request as ready for review February 11, 2025 16:23
Copy link
Member

@yin1999 yin1999 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

请先按 #25774 提出的一些建议更新这些文档,后面会由 @jasonren0403 来审核当前 PR。

@weixiang0815
Copy link
Contributor Author

@yin1999 已根據您的建議修正好了。

@weixiang0815 weixiang0815 force-pushed the code_style_guide_20250208 branch from 9d0d9e0 to 02db967 Compare February 12, 2025 07:21
Copy link
Contributor

@jasonren0403 jasonren0403 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

一些修改建议


### 函式名稱

函式名稱應使用 {{Glossary("camel_case", "駝峰命名法")}},首個字母須為小寫。請選擇簡潔、易讀且具語意性的名稱,以提升可讀性。
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
函式名稱應使用 {{Glossary("camel_case", "駝峰命名法")}},首個字母須為小寫。請選擇簡潔、易讀且具語意性的名稱,以提升可讀性。
函式名稱應使用{{Glossary("camel_case", "駝峰命名法")}},首個字母須為小寫。請選擇簡潔、易讀且具語意性的名稱,以提升可讀性。

Copy link
Contributor Author

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()` 方法是否存在。
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- 在遍歷集合元素時,請避免使用傳統 `for (;;)` 迴圈,建議使用 `for-of``forEach()`。請注意,若使用的集合並非 `陣列(Array`,則須確認 `for-of` 是否支援(它要求變數可迭代),或確保 `forEach()` 方法是否存在。
- 在遍歷集合元素時,請避免使用傳統 `for (;;)` 迴圈,建議使用 `for-of``forEach()`。請注意,若使用的集合並非 `Array`(陣列),則須確認 `for-of` 是否支援(它要求變數可迭代),或確保 `forEach()` 方法是否存在。

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

已修正。

}
```

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.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里遗漏了

Copy link
Contributor Author

@weixiang0815 weixiang0815 Feb 14, 2025

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` 陳述式。此規則同樣適用於回傳值的情境。請這樣撰寫:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
當你需要根據條件將某個字面值存入變數時,請使用[三元運算子](/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)中閱讀更多相關資訊。
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
為了在最廣裝置範圍內提供最大靈活性,建議使用相對單位來設定容器(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)中閱讀更多相關資訊。

Comment on lines +401 to +403
在 `if-else` 控制陳述中,有一個需要特別注意的情況。如果 `if` 陳述以 `return` 結束,就不用再寫 `else` 陳述。

請在 `if` 陳述後直接繼續撰寫程式碼。請這樣撰寫:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
`if-else` 控制陳述中,有一個需要特別注意的情況。如果 `if` 陳述以 `return` 結束,就不用再寫 `else` 陳述。
請在 `if` 陳述後直接繼續撰寫程式碼。請這樣撰寫:
`if-else` 控制陳述式中,有一個需要特別注意的情況。如果 `if` 陳述以 `return` 結束,就不用再寫 `else` 陳述。
請在 `if` 陳述式後直接繼續撰寫程式碼。請這樣撰寫:

Copy link
Contributor

@jasonren0403 jasonren0403 left a 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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
l10n-zh Issues related to Chinese content.
Projects
Status: In progress - PRs
Development

Successfully merging this pull request may close these issues.

3 participants