Skip to content

[zh-Hans] translate API docs: utils and components (15) - #525

Merged
hyesungoh merged 3 commits into
toss:mainfrom
assassinationss:zh-hans-translate-utils-and-components
Sep 28, 2026
Merged

hyesungoh merged 3 commits into
toss:mainfrom
assassinationss:zh-hans-translate-utils-and-components

Conversation

@assassinationss

@assassinationss assassinationss commented Sep 24, 2026 •

Copy link
Copy Markdown
Contributor

Translates all 15 remaining zh-Hans API reference pages, as claimed in my comment on the issue. Follows agent-translation-reviewer.md (zh-Hans glossary and typography rules: Hook kept in English, full-width punctuation in prose, half-width spaces at CJK–Latin boundaries, 书面语 with 你) and the ko/ directory layout.

utils (12): buildContext, disableBodyScrollLock, enableBodyScrollLock, getKeyboardHeight, getSafeAreaInset, isAndroid, isIOS, isKeyboardVisible, isServer, mergeProps, mergeRefs, subscribeKeyboardHeight
components (3): ImpressionArea, Separated, SwitchCase

Conventions kept consistent with the already-translated hooks pages:

  • section headings: 接口 / 参数 / 返回值 / 示例
  • code blocks: comments and expected-output annotations stay in English (matches the existing zh-Hans hook docs)
  • 「此函数不接受任何参数。」/「此函数不返回任何值。」 for the no-params/no-return formulas
  • technical terms per glossary: 工具函数, 组件, 服务端渲染, 已弃用; ref/props/React/TypeScript/SSR kept as-is

Closes #501

@changeset-bot

changeset-bot Bot commented Sep 24, 2026 •

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 46df04b

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@hyesungoh hyesungoh left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks for the translation! One required fix before merging (the mergeRefs example), plus a few small typography nits.

```tsx
function Component(props) {
const ref = useRef(null);
const eight, setHeight] = useState(0);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Required: The English source is correct here (mergeRefs.md:45 has const [height, setHeight]). The [ and h were dropped during translation. Could you also remove the "reported typo" paragraph from the PR description?

Suggested change
const eight, setHeight] = useState(0);
const [height, setHeight] = useState(0);


注意:

- 所有 Android 浏览器的 user agent 中都包含 “Android” 字符串。

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Nit: No spaces around full-width quotes.

Suggested change
- 所有 Android 浏览器的 user agent 中都包含 “Android” 字符串。
- 所有 Android 浏览器的 user agent 中都包含“Android”字符串。

Comment on lines +7 to +8
- 在 iPadOS 13 之前,iPad 申报的平台为 “iPad”(或在 UA 中匹配 /iPad/)。
- 从 iPadOS 13 开始,Apple 将平台字符串改为 “MacIntel”,让网站将 iPadOS 当作桌面级 Safari 对待。但这些设备仍然支持多点触控。

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Nit: Same here — no spaces around full-width quotes.

Suggested change
- 在 iPadOS 13 之前,iPad 申报的平台为 “iPad”(或在 UA 中匹配 /iPad/)。
- 从 iPadOS 13 开始,Apple 将平台字符串改为 “MacIntel”,让网站将 iPadOS 当作桌面级 Safari 对待。但这些设备仍然支持多点触控。
- 在 iPadOS 13 之前,iPad 申报的平台为“iPad”(或在 UA 中匹配 /iPad/)。
- 从 iPadOS 13 开始,Apple 将平台字符串改为“MacIntel”,让网站将 iPadOS 当作桌面级 Safari 对待。但这些设备仍然支持多点触控。

Comment on lines +15 to +17
- top: 47-59px(刘海/灵动岛)
- bottom: 34px(主屏幕指示条)
- left/right: 0px

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Nit: Full-width : to match lines 9–11.

Suggested change
- top: 47-59px(刘海/灵动岛)
- bottom: 34px(主屏幕指示条)
- left/right: 0px
- top:47-59px(刘海/灵动岛)
- bottom:34px(主屏幕指示条)
- left/right:0px

@@ -0,0 +1,55 @@
# mergeRefs

`mergeRefs` 接收多个 ref(RefObject 或 RefCallback),返回一个能更新所有传入 ref 的单一 ref。当你需要向单个元素同时传递多个 ref 时很有用。当回调 ref 返回清理函数(React 19)时,合并后的 ref 也会返回一个清理函数,并在卸载时执行所有清理操作。

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Nit: "on detach" → 在分离时. A ref also detaches when it's swapped for another element, not only on unmount.

Suggested change
`mergeRefs` 接收多个 ref(RefObject 或 RefCallback),返回一个能更新所有传入 ref 的单一 ref。当你需要向单个元素同时传递多个 ref 时很有用。当回调 ref 返回清理函数(React 19)时,合并后的 ref 也会返回一个清理函数,并在卸载时执行所有清理操作。
`mergeRefs` 接收多个 ref(RefObject 或 RefCallback),返回一个能更新所有传入 ref 的单一 ref。当你需要向单个元素同时传递多个 ref 时很有用。当回调 ref 返回清理函数(React 19)时,合并后的 ref 也会返回一个清理函数,并在分离时执行所有清理操作。

- restore dropped [h in mergeRefs example to match English source
- on detach -> 在分离时 (refs also detach on element swap)
- remove spaces around full-width quotes (isAndroid/isIOS)
- full-width colon in getSafeAreaInset typical values
@assassinationss

Copy link
Copy Markdown
Contributor Author

Thanks @hyesungoh for the thorough review! All feedback applied in 45e3ebb:

  • Restored the dropped [h in the mergeRefs example — it now matches the English source (const [height, setHeight]), and reworded the cleanup sentence to 在分离时 per your note about refs also detaching on element swaps.
  • Removed the spaces around full-width quotes in isAndroid/isIOS, and switched the getSafeAreaInset typical-values list to full-width : to match the lines above.
  • Also removed the reported-typo paragraph from the description — you are right, the English source is intact. That was a rendering artifact on my side when reading the generated file; apologies for the noise, and thanks for catching it.

@codecov-commenter

codecov-commenter commented Sep 27, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (9449b03) to head (46df04b).

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff            @@
##              main      #525   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           69        69           
  Lines         2280      2280           
  Branches       737       737           
=========================================
  Hits          2280      2280           
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@hyesungoh
hyesungoh merged commit ef39e32 into toss:main Sep 28, 2026
19 checks passed
@hyesungoh hyesungoh linked an issue Sep 28, 2026 that may be closed by this pull request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[zh-Hans] Translate API docs: utils and components (15) [Roadmap] Documentation translations: ja, zh-Hans, es

3 participants