Skip to content

Conversation

@otegami
Copy link
Collaborator

@otegami otegami commented Sep 18, 2025

GitHub: GH-181

@otegami otegami force-pushed the update-translation-turbo-reference-event branch from b3371dc to cd9e32b Compare November 5, 2025 10:49
@otegami otegami changed the title WIP turbo reference event: updated translation turbo reference event: updated translation Nov 9, 2025
@otegami otegami marked this pull request as ready for review November 9, 2025 02:36
@otegami otegami force-pushed the update-translation-turbo-reference-event branch from 7a23128 to a5ac0a0 Compare November 10, 2025 09:03

### `turbo:visit`

ページ遷移が開始された直後に発火します。`event.detail.url` でリクエストされたロケーションと `event.detail.action` でページ遷移のアクションを取得できます。
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
ページ遷移が開始された直後に発火します。`event.detail.url` でリクエストされたロケーションと `event.detail.action` でページ遷移のアクションを取得できます。
ページ遷移が開始された直後に発火します。`event.detail.url` でリクエストされたロケーションを、 `event.detail.action` でページ遷移のアクションを取得できます。


### `turbo:before-visit`

あるロケーションに移動する前に発火します(ただし、履歴操作によるナビゲーション時は除きます)。`event.detail.url` からリクエスト先のロケーションを取得できます。このイベントをキャンセルすると、ナビゲーションが行われなくなります。
Copy link
Contributor

Choose a reason for hiding this comment

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

原文と言葉のニュアンスが若干変わりそうですが、
turbo:visitと合わせて、「ページ遷移が開始される直前に発火します」とかもありです?

| `renderMethod` | `"replace" \| "morph"` | 新しいコンテンツを描画するときに使われる方式
| `newBody` | [HTMLBodyElement][] | 現在の `<body>` 要素を置き換える新しい `<body>` 要素
| `resume` | `(value?: any) => void` | [描画の一時停止][] 時に呼び出す関数
| `render` | `(currentBody, newBody) => void`| [描画処理をカスタマイズする][] 用に既存の描画処理をカスタマイズする関数
Copy link
Contributor

Choose a reason for hiding this comment

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

このままでも伝わりますが、説明が重複しているような気がしました。
よりシンプルにするのであれば、既存の[描画処理をカスタマイズする][]ための関数とか、もう少し説明を足すのであれば、[描画処理をカスタマイズする][] ために既存の描画処理を上書きする関数の方がしっくりくるかなと思いました。


### `turbo:before-render`

ページの描画前に発火します。新しい `<body>` 要素は `event.detail.newBody` から取得できます。描画は `event.detail.resume` を使って停止および再開ができます(詳細は [描画の一時停止][] を参照)。さらに、Turbo ドライブがレスポンスを描画する方法は、`event.detail.render` 関数を上書きしてカスタマイズできます(詳細は [描画処理をカスタマイズする][] を参照)。
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
ページの描画前に発火します。新しい `<body>` 要素は `event.detail.newBody` から取得できます。描画は `event.detail.resume` を使って停止および再開ができます(詳細は [描画の一時停止][] を参照)。さらに、Turbo ドライブがレスポンスを描画する方法は、`event.detail.render` 関数を上書きしてカスタマイズできます(詳細は [描画処理をカスタマイズする][] を参照)。
ページの描画前に発火します。新しい `<body>` 要素は `event.detail.newBody` から取得できます。描画は `event.detail.resume` を使って停止および再開ができます(詳細は [描画の一時停止][] を参照)。さらに `event.detail.render` 関数を上書きすることで、Turbo ドライブのレスポンス描画処理をカスタマイズできます(詳細は [描画処理をカスタマイズする][] を参照)。

### `turbo:submit-end`

フォーム送信によって開始されたネットワークリクエストが完了した後に発火します。
`event.detail.formSubmission`[FormSubmission][] オブジェクトにアクセスでき、`event.detail` 内の各プロパティを参照できます。
Copy link
Contributor

Choose a reason for hiding this comment

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

FormSubmission オブジェクトから event.detail にアクセスできる??のような読み方をしてしまいました。以下のような形で並列に書くというのはいかがでしょうか。

Suggested change
`event.detail.formSubmission`[FormSubmission][] オブジェクトにアクセスでき、`event.detail` 内の各プロパティを参照できます
`event.detail.formSubmission`[FormSubmission][] オブジェクトにアクセスでき、その他のプロパティは `event.detail` からアクセスできます

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.

3 participants