From ee778a8b28f10dd8fcb1441f35cd6ea4a2361134 Mon Sep 17 00:00:00 2001
From: Saki
Date: Fri, 9 Jun 2023 11:34:30 -0700
Subject: [PATCH 1/8] Translate up to line 170
---
src/content/reference/react/useId.md | 46 ++++++++++++++--------------
1 file changed, 23 insertions(+), 23 deletions(-)
diff --git a/src/content/reference/react/useId.md b/src/content/reference/react/useId.md
index 4ea029f27..7c3b24f56 100644
--- a/src/content/reference/react/useId.md
+++ b/src/content/reference/react/useId.md
@@ -4,7 +4,7 @@ title: useId
-`useId` is a React Hook for generating unique IDs that can be passed to accessibility attributes.
+`useId` は、アクセシビリティ属性に渡すことができる一意の ID を生成するための React フックです。
```js
const id = useId()
@@ -16,11 +16,11 @@ const id = useId()
---
-## Reference {/*reference*/}
+## リファレンス {/*reference*/}
### `useId()` {/*useid*/}
-Call `useId` at the top level of your component to generate a unique ID:
+コンポーネントのトップレベルで `useId` を呼び出して、一意の ID を生成します。
```js
import { useId } from 'react';
@@ -30,35 +30,35 @@ function PasswordField() {
// ...
```
-[See more examples below.](#usage)
+[その他の例は下をご覧ください。](#usage)
-#### Parameters {/*parameters*/}
+#### パラメータ {/*parameters*/}
-`useId` does not take any parameters.
+`useId` はパラメータを受け取りません。
-#### Returns {/*returns*/}
+#### 返す {/*returns*/}
-`useId` returns a unique ID string associated with this particular `useId` call in this particular component.
+`useId` は、特定のコンポーネント内で、この `useId` の呼び出しに関連付けられた一意の ID 文字列を返します。
-#### Caveats {/*caveats*/}
+#### 注意事項 {/*caveats*/}
-* `useId` is a Hook, so you can only call it **at the top level of your component** or your own Hooks. You can't call it inside loops or conditions. If you need that, extract a new component and move the state into it.
+* `useId` はフックであるため、**コンポーネントのトップレベル** または独自のフック内でのみ呼び出すことができます。ループまたは条件分岐内で呼び出すことはできません。もし必要な場合は、新しいコンポーネントを作成し、状態を移動させる必要があります。
-* `useId` **should not be used to generate keys** in a list. [Keys should be generated from your data.](/learn/rendering-lists#where-to-get-your-key)
+* `useId` を、**リスト内のキーの生成には使用しないでください**。[キーはデータから生成される必要があります。](/learn/rendering-lists#where-to-get-your-key)
---
-## Usage {/*usage*/}
+## 使用方法 {/*usage*/}
-**Do not call `useId` to generate keys in a list.** [Keys should be generated from your data.](/learn/rendering-lists#where-to-get-your-key)
+**リスト内のキーを生成するために `useId` を呼び出さないでください。**[キーはデータから生成される必要があります。](/learn/rendering-lists#where-to-get-your-key)
-### Generating unique IDs for accessibility attributes {/*generating-unique-ids-for-accessibility-attributes*/}
+### アクセシビリティ属性の一意の ID の生成 {/*generating-unique-ids-for-accessibility-attributes*/}
-Call `useId` at the top level of your component to generate a unique ID:
+コンポーネントのトップレベルで `useId` を呼び出して、一意の ID を生成します。
```js [[1, 4, "passwordHintId"]]
import { useId } from 'react';
@@ -68,7 +68,7 @@ function PasswordField() {
// ...
```
-You can then pass the generated ID to different attributes:
+その後、 生成された ID をさまざまな属性に渡すことができます。
```js [[1, 2, "passwordHintId"], [1, 3, "passwordHintId"]]
<>
@@ -77,11 +77,11 @@ You can then pass the generated ID to different at
>
```
-**Let's walk through an example to see when this is useful.**
+**これがどのような場合に役立つかを、例を通してみてみましょう。**
-[HTML accessibility attributes](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA) like [`aria-describedby`](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-describedby) let you specify that two tags are related to each other. For example, you can specify that an element (like an input) is described by another element (like a paragraph).
+[`aria-describedby`](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-describedby) のような [HTML アクセシビリティ属性](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA)を使用すると、2 つのタグが相互に関連していることを指定することができます。例えば、入力フィールドのような要素が、段落などの別の要素で説明されていることを指定することができます。
-In regular HTML, you would write it like this:
+通常の HTML では、次のように記述します。
```html {5,8}
```
-However, hardcoding IDs like this is not a good practice in React. A component may be rendered more than once on the page--but IDs have to be unique! Instead of hardcoding an ID, generate a unique ID with `useId`:
+ただし、このように ID をハードコードすることは、React ではおすすめできません。コンポーネントはページ上で複数回レンダー可能ですが、ID は一意である必要があります! ID をハードコードするのではなく、`useId` を使用して一意の ID を生成します。
```js {4,11,14}
import { useId } from 'react';
@@ -120,7 +120,7 @@ function PasswordField() {
}
```
-Now, even if `PasswordField` appears multiple times on the screen, the generated IDs won't clash.
+これで、画面上に `PasswordField` が複数回表示される場合でも、生成される ID が同じになることはありません。
@@ -163,11 +163,11 @@ input { margin: 5px; }
-[Watch this video](https://www.youtube.com/watch?v=0dNzNcuEuOo) to see the difference in the user experience with assistive technologies.
+[このビデオを見て](https://www.youtube.com/watch?v=0dNzNcuEuOo)支援技術による、ユーザ体験の違いを確認してみてください。
-With [server rendering](/reference/react-dom/server), **`useId` requires an identical component tree on the server and the client**. If the trees you render on the server and the client don't match exactly, the generated IDs won't match.
+[サーバーレンダリング](/reference/react-dom/server)では、**`useId` にはサーバとクライアント上で同一のコンポーネントツリーが必要です**。サーバ上とクライアント上でレンダーされるツリーが正確に一致しない場合、生成される ID は一致しません。
From 080a1384ae2221f1c859000af924a0d99e1568e6 Mon Sep 17 00:00:00 2001
From: Saki
Date: Tue, 13 Jun 2023 11:26:38 -0700
Subject: [PATCH 2/8] Translate up to line 176
---
src/content/reference/react/useId.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/content/reference/react/useId.md b/src/content/reference/react/useId.md
index 7c3b24f56..54389c918 100644
--- a/src/content/reference/react/useId.md
+++ b/src/content/reference/react/useId.md
@@ -175,7 +175,7 @@ input { margin: 5px; }
#### Why is useId better than an incrementing counter? {/*why-is-useid-better-than-an-incrementing-counter*/}
-You might be wondering why `useId` is better than incrementing a global variable like `nextId++`.
+なぜ `useId` が `nextId++` のようなグローバル変数をインクリメントするよりも優れているのか疑問に思われるかもしれません。
The primary benefit of `useId` is that React ensures that it works with [server rendering.](/reference/react-dom/server) During server rendering, your components generate HTML output. Later, on the client, [hydration](/reference/react-dom/client/hydrateRoot) attaches your event handlers to the generated HTML. For hydration to work, the client output must match the server HTML.
From 4f34c13cd2493f36eb95ecb05465bda37a5322c0 Mon Sep 17 00:00:00 2001
From: Saki
Date: Tue, 13 Jun 2023 11:40:29 -0700
Subject: [PATCH 3/8] Translate up to line 180
---
src/content/reference/react/useId.md | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/src/content/reference/react/useId.md b/src/content/reference/react/useId.md
index 54389c918..9b04c6743 100644
--- a/src/content/reference/react/useId.md
+++ b/src/content/reference/react/useId.md
@@ -167,17 +167,17 @@ input { margin: 5px; }
-[サーバーレンダリング](/reference/react-dom/server)では、**`useId` にはサーバとクライアント上で同一のコンポーネントツリーが必要です**。サーバ上とクライアント上でレンダーされるツリーが正確に一致しない場合、生成される ID は一致しません。
+[サーバーレンダリング](/reference/react-dom/server)では、**`useId` にはサーバーとクライアント上で同一のコンポーネントツリーが必要です**。サーバー上とクライアント上でレンダーされるツリーが正確に一致しない場合、生成される ID は一致しません。
-#### Why is useId better than an incrementing counter? {/*why-is-useid-better-than-an-incrementing-counter*/}
+#### useId が増分カウンタよりも良い理由 {/*why-is-useid-better-than-an-incrementing-counter*/}
なぜ `useId` が `nextId++` のようなグローバル変数をインクリメントするよりも優れているのか疑問に思われるかもしれません。
-The primary benefit of `useId` is that React ensures that it works with [server rendering.](/reference/react-dom/server) During server rendering, your components generate HTML output. Later, on the client, [hydration](/reference/react-dom/client/hydrateRoot) attaches your event handlers to the generated HTML. For hydration to work, the client output must match the server HTML.
+`useId` の主な利点は、React が、[サーバーレンダリング](/reference/react-dom/server) で、確実に機能することを保証しているためです。サーバーのレンダー中に、コンポーネントは HTML の出力を生成します。その後クライアント上で、生成された HTML に、[ハイドレーション](/reference/react-dom/client/hydrateRoot) によって、イベント ハンドラがアタッチされます。ハイドレーションが機能するには、クライアントの出力がサーバーの HTML と一致する必要があります。
This is very difficult to guarantee with an incrementing counter because the order in which the client components are hydrated may not match the order in which the server HTML was emitted. By calling `useId`, you ensure that hydration will work, and the output will match between the server and the client.
From 53f0637f3032352a5e0687ea2f1bcccacacf93f9 Mon Sep 17 00:00:00 2001
From: Saki
Date: Tue, 13 Jun 2023 11:47:59 -0700
Subject: [PATCH 4/8] Translate up to line 182
---
src/content/reference/react/useId.md | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/content/reference/react/useId.md b/src/content/reference/react/useId.md
index 9b04c6743..0b618f57b 100644
--- a/src/content/reference/react/useId.md
+++ b/src/content/reference/react/useId.md
@@ -175,11 +175,11 @@ input { margin: 5px; }
#### useId が増分カウンタよりも良い理由 {/*why-is-useid-better-than-an-incrementing-counter*/}
-なぜ `useId` が `nextId++` のようなグローバル変数をインクリメントするよりも優れているのか疑問に思われるかもしれません。
+なぜ `useId` が `nextId++` のようなグローバル変数を増分するよりもなぜ良いのか、疑問に思われるかもしれません。
`useId` の主な利点は、React が、[サーバーレンダリング](/reference/react-dom/server) で、確実に機能することを保証しているためです。サーバーのレンダー中に、コンポーネントは HTML の出力を生成します。その後クライアント上で、生成された HTML に、[ハイドレーション](/reference/react-dom/client/hydrateRoot) によって、イベント ハンドラがアタッチされます。ハイドレーションが機能するには、クライアントの出力がサーバーの HTML と一致する必要があります。
-This is very difficult to guarantee with an incrementing counter because the order in which the client components are hydrated may not match the order in which the server HTML was emitted. By calling `useId`, you ensure that hydration will work, and the output will match between the server and the client.
+クライアントコンポーネントがハイドレートされる順序は、サーバー HTML が出力された順序と一致しない可能性があるため、これをインクリメントカウンタで保証することは非常に困難です。`useId` を呼び出すことで、ハイドレーションが機能し、サーバーとクライアントの間で出力が一致することが保証されます。
Inside React, `useId` is generated from the "parent path" of the calling component. This is why, if the client and the server tree are the same, the "parent path" will match up regardless of rendering order.
From 4a9d1c06114f0443f9079176a99a080bfb82bc65 Mon Sep 17 00:00:00 2001
From: Saki
Date: Tue, 13 Jun 2023 11:51:40 -0700
Subject: [PATCH 5/8] Translate up to line 184
---
src/content/reference/react/useId.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/content/reference/react/useId.md b/src/content/reference/react/useId.md
index 0b618f57b..f8bfb909c 100644
--- a/src/content/reference/react/useId.md
+++ b/src/content/reference/react/useId.md
@@ -181,7 +181,7 @@ input { margin: 5px; }
クライアントコンポーネントがハイドレートされる順序は、サーバー HTML が出力された順序と一致しない可能性があるため、これをインクリメントカウンタで保証することは非常に困難です。`useId` を呼び出すことで、ハイドレーションが機能し、サーバーとクライアントの間で出力が一致することが保証されます。
-Inside React, `useId` is generated from the "parent path" of the calling component. This is why, if the client and the server tree are the same, the "parent path" will match up regardless of rendering order.
+React 内部では、呼び出し元コンポーネントの「親パス」から `useId` が生成されます。そのため、クライアントとサーバーのツリーが同じであれば、レンダリング順序に関係なく「親パス」が一致することになります。
From 80c700af4566781e9d1dd92b5de2fca763db603f Mon Sep 17 00:00:00 2001
From: Saki
Date: Tue, 13 Jun 2023 11:56:05 -0700
Subject: [PATCH 6/8] Translate up to line 219
---
src/content/reference/react/useId.md | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/src/content/reference/react/useId.md b/src/content/reference/react/useId.md
index f8bfb909c..7e3f133c5 100644
--- a/src/content/reference/react/useId.md
+++ b/src/content/reference/react/useId.md
@@ -187,9 +187,9 @@ React 内部では、呼び出し元コンポーネントの「親パス」か
---
-### Generating IDs for several related elements {/*generating-ids-for-several-related-elements*/}
+### 複数の関連要素に対してIDを生成する方法 {/*generating-ids-for-several-related-elements*/}
-If you need to give IDs to multiple related elements, you can call `useId` to generate a shared prefix for them:
+複数の関連要素に ID を与える必要がある場合は、`useId` を呼び出してそれらの共有プレフィックスを生成できます。
@@ -216,7 +216,7 @@ input { margin: 5px; }
-This lets you avoid calling `useId` for every single element that needs a unique ID.
+これにより、一意の ID を必要とするすべての要素に対して `useId` を呼び出す必要がなくなります。
---
From 6c183a1d07011041399abdbfe136c95181fc542b Mon Sep 17 00:00:00 2001
From: Saki
Date: Tue, 13 Jun 2023 12:03:13 -0700
Subject: [PATCH 7/8] Complete
---
src/content/reference/react/useId.md | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/src/content/reference/react/useId.md b/src/content/reference/react/useId.md
index 7e3f133c5..a563fd4a2 100644
--- a/src/content/reference/react/useId.md
+++ b/src/content/reference/react/useId.md
@@ -187,7 +187,7 @@ React 内部では、呼び出し元コンポーネントの「親パス」か
---
-### 複数の関連要素に対してIDを生成する方法 {/*generating-ids-for-several-related-elements*/}
+### 複数の関連要素に対してIDを生成する {/*generating-ids-for-several-related-elements*/}
複数の関連要素に ID を与える必要がある場合は、`useId` を呼び出してそれらの共有プレフィックスを生成できます。
@@ -220,9 +220,9 @@ input { margin: 5px; }
---
-### Specifying a shared prefix for all generated IDs {/*specifying-a-shared-prefix-for-all-generated-ids*/}
+### 生成されたすべての ID に共有プレフィックスを指定する {/*specifying-a-shared-prefix-for-all-generated-ids*/}
-If you render multiple independent React applications on a single page, pass `identifierPrefix` as an option to your [`createRoot`](/reference/react-dom/client/createRoot#parameters) or [`hydrateRoot`](/reference/react-dom/client/hydrateRoot) calls. This ensures that the IDs generated by the two different apps never clash because every identifier generated with `useId` will start with the distinct prefix you've specified.
+複数の独立した React アプリケーションを 1 つのページにレンダーする場合は、オプションとして `identifierPrefix` を [`createRoot`](/reference/react-dom/client/createRoot#parameters) または [`hydrateRoot`](/reference/react-dom/client/hydrateRoot) に渡します。これにより、`useId` で生成されたすべての識別子が指定した個別のプレフィックスで始まるため、2 つの異なるアプリによって生成された ID が衝突することがなくなります。
From a149a8acc1fa4b0917bafb00bc083f75e393a3bb Mon Sep 17 00:00:00 2001
From: Saki
Date: Wed, 14 Jun 2023 09:13:21 -0700
Subject: [PATCH 8/8] Update styling and correct sentences for readability
---
src/content/reference/react/useId.md | 38 ++++++++++++++--------------
1 file changed, 19 insertions(+), 19 deletions(-)
diff --git a/src/content/reference/react/useId.md b/src/content/reference/react/useId.md
index a563fd4a2..5770b995b 100644
--- a/src/content/reference/react/useId.md
+++ b/src/content/reference/react/useId.md
@@ -4,7 +4,7 @@ title: useId
-`useId` は、アクセシビリティ属性に渡すことができる一意の ID を生成するための React フックです。
+`useId` は、アクセシビリティ属性に渡すことができる一意の ID を生成するための React フックです。
```js
const id = useId()
@@ -30,33 +30,33 @@ function PasswordField() {
// ...
```
-[その他の例は下をご覧ください。](#usage)
+[さらに例を見る](#usage)
-#### パラメータ {/*parameters*/}
+#### 引数 {/*parameters*/}
`useId` はパラメータを受け取りません。
-#### 返す {/*returns*/}
+#### 返り値 {/*returns*/}
-`useId` は、特定のコンポーネント内で、この `useId` の呼び出しに関連付けられた一意の ID 文字列を返します。
+`useId` は、特定のコンポーネント内でこの特定の `useId` の呼び出しに関連付けられた、一意の ID 文字列を返します。
#### 注意事項 {/*caveats*/}
-* `useId` はフックであるため、**コンポーネントのトップレベル** または独自のフック内でのみ呼び出すことができます。ループまたは条件分岐内で呼び出すことはできません。もし必要な場合は、新しいコンポーネントを作成し、状態を移動させる必要があります。
+* `useId` はフックであるため、**コンポーネントのトップレベル**または独自のフック内でのみ呼び出すことができます。ループまたは条件分岐内で呼び出すことはできません。もし必要な場合は、新しいコンポーネントを作成し、状態を移動させる必要があります。
-* `useId` を、**リスト内のキーの生成には使用しないでください**。[キーはデータから生成される必要があります。](/learn/rendering-lists#where-to-get-your-key)
+* `useId` を、**リスト内の key の生成には使用しないでください**。[key はデータから生成される必要があります。](/learn/rendering-lists#where-to-get-your-key)
---
-## 使用方法 {/*usage*/}
+## 使用方 {/*usage*/}
-**リスト内のキーを生成するために `useId` を呼び出さないでください。**[キーはデータから生成される必要があります。](/learn/rendering-lists#where-to-get-your-key)
+**リスト内の key を生成するために `useId` を呼び出さないでください。**[key はデータから生成される必要があります。](/learn/rendering-lists#where-to-get-your-key)
-### アクセシビリティ属性の一意の ID の生成 {/*generating-unique-ids-for-accessibility-attributes*/}
+### アクセシビリティ属性のための一意の ID の生成 {/*generating-unique-ids-for-accessibility-attributes*/}
コンポーネントのトップレベルで `useId` を呼び出して、一意の ID を生成します。
@@ -68,7 +68,7 @@ function PasswordField() {
// ...
```
-その後、 生成された ID をさまざまな属性に渡すことができます。
+その後、生成された ID をさまざまな属性に渡すことができます。
```js [[1, 2, "passwordHintId"], [1, 3, "passwordHintId"]]
<>
@@ -167,7 +167,7 @@ input { margin: 5px; }
-[サーバーレンダリング](/reference/react-dom/server)では、**`useId` にはサーバーとクライアント上で同一のコンポーネントツリーが必要です**。サーバー上とクライアント上でレンダーされるツリーが正確に一致しない場合、生成される ID は一致しません。
+[サーバレンダリング](/reference/react-dom/server)では、**`useId` にはサーバとクライアント上で同一のコンポーネントツリーが必要です**。サーバ上とクライアント上でレンダーされるツリーが正確に一致しない場合、生成される ID は一致しません。
@@ -175,21 +175,21 @@ input { margin: 5px; }
#### useId が増分カウンタよりも良い理由 {/*why-is-useid-better-than-an-incrementing-counter*/}
-なぜ `useId` が `nextId++` のようなグローバル変数を増分するよりもなぜ良いのか、疑問に思われるかもしれません。
+`useId` が `nextId++` のようなグローバル変数を増分するよりもなぜ良いのか、疑問に思われるかもしれません。
-`useId` の主な利点は、React が、[サーバーレンダリング](/reference/react-dom/server) で、確実に機能することを保証しているためです。サーバーのレンダー中に、コンポーネントは HTML の出力を生成します。その後クライアント上で、生成された HTML に、[ハイドレーション](/reference/react-dom/client/hydrateRoot) によって、イベント ハンドラがアタッチされます。ハイドレーションが機能するには、クライアントの出力がサーバーの HTML と一致する必要があります。
+`useId` の主な利点は、React が、[サーバレンダリング](/reference/react-dom/server)で確実に機能することを保証していることです。サーバでのレンダー中に、コンポーネントは HTML 形式の出力を生成します。その後クライアント上で、生成された HTML に、[ハイドレーション](/reference/react-dom/client/hydrateRoot)によって、イベントハンドラがアタッチされます。ハイドレーションが機能するには、クライアントの出力がサーバの HTML と一致する必要があります。
-クライアントコンポーネントがハイドレートされる順序は、サーバー HTML が出力された順序と一致しない可能性があるため、これをインクリメントカウンタで保証することは非常に困難です。`useId` を呼び出すことで、ハイドレーションが機能し、サーバーとクライアントの間で出力が一致することが保証されます。
+クライアントコンポーネントがハイドレートされる順序は、サーバ HTML が出力された順序と一致しない可能性があるため、これをインクリメントカウンタで保証することは非常に困難です。`useId` を呼び出すことで、ハイドレーションが機能し、サーバとクライアントの間で出力が一致することが保証されます。
-React 内部では、呼び出し元コンポーネントの「親パス」から `useId` が生成されます。そのため、クライアントとサーバーのツリーが同じであれば、レンダリング順序に関係なく「親パス」が一致することになります。
+React 内部では、呼び出し元コンポーネントの "親のパス (parent path)" から `useId` が生成されます。そのため、クライアントとサーバのツリーが同じであれば、レンダー順序に関係なく "親のパス" が一致することになります。
---
-### 複数の関連要素に対してIDを生成する {/*generating-ids-for-several-related-elements*/}
+### 複数の関連要素に対して ID を生成する {/*generating-ids-for-several-related-elements*/}
-複数の関連要素に ID を与える必要がある場合は、`useId` を呼び出してそれらの共有プレフィックスを生成できます。
+複数の関連要素に ID を与える必要がある場合は、`useId` で生成した値を共有のプレフィックスとして使用できます。
@@ -220,7 +220,7 @@ input { margin: 5px; }
---
-### 生成されたすべての ID に共有プレフィックスを指定する {/*specifying-a-shared-prefix-for-all-generated-ids*/}
+### 生成されるすべての ID に共有プレフィックスを指定する {/*specifying-a-shared-prefix-for-all-generated-ids*/}
複数の独立した React アプリケーションを 1 つのページにレンダーする場合は、オプションとして `identifierPrefix` を [`createRoot`](/reference/react-dom/client/createRoot#parameters) または [`hydrateRoot`](/reference/react-dom/client/hydrateRoot) に渡します。これにより、`useId` で生成されたすべての識別子が指定した個別のプレフィックスで始まるため、2 つの異なるアプリによって生成された ID が衝突することがなくなります。