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

Translate SyntheticEvent #43

Merged
merged 5 commits into from Feb 5, 2019

Conversation

summertree128
Copy link
Contributor

@summertree128 summertree128 commented Feb 2, 2019

This PR is part of #4.
Added translation to Add SyntheticEvents page.

Please review.

@summertree128 summertree128 changed the title WIP: translate synthetic events Translate SyntheticEvent Feb 3, 2019
@smikitky smikitky self-requested a review February 3, 2019 11:36
@koba04 koba04 self-requested a review February 4, 2019 01:15
Copy link
Member

@koba04 koba04 left a comment

Choose a reason for hiding this comment

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

@summertree128 いくつかコメントしましたのでご確認お願いします! 🙇


Your event handlers will be passed instances of `SyntheticEvent`, a cross-browser wrapper around the browser's native event. It has the same interface as the browser's native event, including `stopPropagation()` and `preventDefault()`, except the events work identically across all browsers.
あなたの書くイベントハンドラには、 `SyntheticEvent` のインスタンスが渡されます。これはブラウザのネイティブイベントに対するクロスブラウザ版のラッパです。`stopPropagation()` `preventDefault()` を含む、ブラウザのネイティブイベントと同じインターフェイスを持ちます。この 2つ以外はすべてのブラウザで同じように機能します。
Copy link
Member

Choose a reason for hiding this comment

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

通常のイベントオブジェクトと違い、ブラウザ互換性があるということが言いたいのだと思うので修正しました。

Suggested change
あなたの書くイベントハンドラには`SyntheticEvent` のインスタンスが渡されます。これはブラウザのネイティブイベントに対するクロスブラウザ版のラッパです。`stopPropagation()``preventDefault()` を含む、ブラウザのネイティブイベントと同じインターフェイスを持ちます。この 2つ以外はすべてのブラウザで同じように機能します
イベントハンドラには`SyntheticEvent` のインスタンスが渡されます。これはブラウザのネイティブイベントに対するクロスブラウザ版のラッパです。`stopPropagation()``preventDefault()` を含む、ブラウザのネイティブイベントと同じインターフェイスを持ち、すべてのブラウザで同じように動作します

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ここは私も悩んだのですが、"except the events"は「stopPropagationとpreventDefault以外」という意味ではないでしょうか?つまり、この2つのイベントは全ブラウザで同じようには動かない(古いIEなど)けどそれ以外は全ブラウザで同じように動くという意味なのではないかと解釈しました。こちらどう思われますか?

Copy link
Member

@smikitky smikitky Feb 5, 2019

Choose a reason for hiding this comment

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

koba04 さんの指摘が正しいと思います。比較的直訳的に行くと「SyntheticEventのインターフェースは元と変わっていないが、ブラウザ間で同様に動作するという点においては異なっています」です。

「この2つのイベント以外では」であれば "except (for) these," のような英文になるはずです。

少しだけ except のニュアンスを出すようにしてみましたが如何でしょう

Suggested change
あなたの書くイベントハンドラには、 `SyntheticEvent` のインスタンスが渡されます。これはブラウザのネイティブイベントに対するクロスブラウザ版のラッパです。`stopPropagation()``preventDefault()` を含む、ブラウザのネイティブイベントと同じインターフェイスを持ちます。この 2つ以外はすべてのブラウザで同じように機能します
あなたの書くイベントハンドラには、`SyntheticEvent` のインスタンスが渡されます。これはブラウザのネイティブイベントに対するクロスブラウザ版のラッパです。`stopPropagation()``preventDefault()` を含む、ブラウザのネイティブイベントと同じインターフェイスを持ちつつ、ブラウザ間で同じ挙動をするようになっています

>
> As of v0.14, returning `false` from an event handler will no longer stop event propagation. Instead, `e.stopPropagation()` or `e.preventDefault()` should be triggered manually, as appropriate.
> v0.14以降、イベントハンドラから false を返してもイベントの伝播が止まることはなくなりました。代わりに、`e.stopPropagation()` または `e.preventDefault()` を手動で呼び出す必要があります。
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
> v0.14以降、イベントハンドラから false を返してもイベントの伝播が止まることはなくなりました。代わりに、`e.stopPropagation()` または `e.preventDefault()` を手動で呼び出す必要があります。
> v0.14以降、イベントハンドラから `false` を返してもイベントの伝播は止まりません。代わりに、`e.stopPropagation()` または `e.preventDefault()` を手動で呼び出す必要があります。

As such, you cannot access the event in an asynchronous way.
### イベントのプール

`SyntheticEvent` はプールされます。つまり、`SyntheticEvent` オブジェクトは再利用され、すべてのプロパティはイベントコールバックが呼び出された後に無効化されます。これはパフォーマンス上の理由からです。そのため、非同期的な方法でイベントにアクセスすることはできません。
Copy link
Member

Choose a reason for hiding this comment

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

挙動としてもわかりにくい部分なので、説明を足してみました。

Suggested change
`SyntheticEvent` はプールされます。つまり、`SyntheticEvent` オブジェクトは再利用され、すべてのプロパティはイベントコールバックが呼び出された後に無効化されます。これはパフォーマンス上の理由からです。そのため、非同期的な方法でイベントにアクセスすることはできません
`SyntheticEvent` はプールされます。つまり、`SyntheticEvent` オブジェクトは再利用され、すべてのプロパティはイベントコールバックが呼び出された後に `null` で初期化されます。これはパフォーマンス上の理由からです。そのため、非同期処理の中でイベントオブジェクトにアクセスすることはできません

また、改行が原文と一致していないようです。


```javascript
function onClick(event) {
console.log(event); // => nullified object.
console.log(event); // => 無効なオブジェクト
Copy link
Member

Choose a reason for hiding this comment

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

この時点では、無効化されていないと思うので、言い方を変えてみました。

Suggested change
console.log(event); // => 無効なオブジェクト
console.log(event); // => null で初期化されるオブジェクト

Copy link
Member

Choose a reason for hiding this comment

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

確かに「このあとで無効化される」ということみたいですね、ややこしい…

@@ -52,70 +51,70 @@ function onClick(event) {
console.log(eventType); // => "click"
}, 0);

// Won't work. this.state.clickEvent will only contain null values.
// これは動作しません。this.state.clickEvent はnull値のみを保持します。
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
// これは動作しません。this.state.clickEvent はnull値のみを保持します
// これは動作しません。this.state.clickEvent は null 値のみを持つオブジェクトとなります

- [Animation Events](#animation-events)
- [Transition Events](#transition-events)
- [Other Events](#other-events)
> 非同期処理でイベントのプロパティにアクセスしたい場合は、`event.persist()` をイベント内で呼び出す必要があります。これにより、プールから合成イベントが削除され、イベントへの参照をコードで保持できるようになります。
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
> 非同期処理でイベントのプロパティにアクセスしたい場合は`event.persist()` をイベント内で呼び出す必要があります。これにより、プールから合成イベントが削除され、イベントへの参照をコードで保持できるようになります。
> 非同期処理の中でイベントのプロパティにアクセスしたい場合は`event.persist()` をイベント内で呼び出す必要があります。これにより、合成イベントがイベントプールの対象から除外され、イベントへの参照をコードで保持できるようになります。


## サポートするイベント

React はイベントを正規化して、異なるブラウザ間で一貫したプロパティが保持されるようにしています。
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
React はイベントを正規化して、異なるブラウザ間で一貫したプロパティが保持されるようにしています
React は異なるブラウザ間でも一貫したプロパティを持つようにイベントを正規化します


Pointer events are not yet supported in every browser (at the time of writing this article, supported browsers include: Chrome, Firefox, Edge, and Internet Explorer). React deliberately does not polyfill support for other browsers because a standard-conform polyfill would significantly increase the bundle size of `react-dom`.
すべてのブラウザでポインタイベントがサポートされているわけではありません(この記事の執筆時点でサポートされているブラウザは、ChromeFirefoxEdge、および Internet Explorer です)。標準に準拠したポリフィルは `react-dom` のバンドルサイズを大幅に増加させるため、Reactは意図的に他のブラウザのポリフィルをサポートしません。
Copy link
Member

@koba04 koba04 Feb 4, 2019

Choose a reason for hiding this comment

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

Suggested change
すべてのブラウザでポインタイベントがサポートされているわけではありません(この記事の執筆時点でサポートされているブラウザは、Chrome、Firefox、Edge、および Internet Explorer です)。標準に準拠したポリフィルは `react-dom` のバンドルサイズを大幅に増加させるため、Reactは意図的に他のブラウザのポリフィルをサポートしません
すべてのブラウザでポインタイベントがサポートされているわけではありません(この記事の執筆時点でサポートされているブラウザは、Chrome、Firefox、Edge、および Internet Explorer です)。標準に準拠したポリフィルは `react-dom` のバンドルサイズを大幅に増加させるため、React は意図的にその他ブラウザのためのポリフィルを提供しません

Copy link
Member

@smikitky smikitky left a comment

Choose a reason for hiding this comment

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

レビューしました、微修正のみです。
よろしくお願いします。


Your event handlers will be passed instances of `SyntheticEvent`, a cross-browser wrapper around the browser's native event. It has the same interface as the browser's native event, including `stopPropagation()` and `preventDefault()`, except the events work identically across all browsers.
あなたの書くイベントハンドラには、 `SyntheticEvent` のインスタンスが渡されます。これはブラウザのネイティブイベントに対するクロスブラウザ版のラッパです。`stopPropagation()` `preventDefault()` を含む、ブラウザのネイティブイベントと同じインターフェイスを持ちます。この 2つ以外はすべてのブラウザで同じように機能します。
Copy link
Member

@smikitky smikitky Feb 5, 2019

Choose a reason for hiding this comment

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

koba04 さんの指摘が正しいと思います。比較的直訳的に行くと「SyntheticEventのインターフェースは元と変わっていないが、ブラウザ間で同様に動作するという点においては異なっています」です。

「この2つのイベント以外では」であれば "except (for) these," のような英文になるはずです。

少しだけ except のニュアンスを出すようにしてみましたが如何でしょう

Suggested change
あなたの書くイベントハンドラには、 `SyntheticEvent` のインスタンスが渡されます。これはブラウザのネイティブイベントに対するクロスブラウザ版のラッパです。`stopPropagation()``preventDefault()` を含む、ブラウザのネイティブイベントと同じインターフェイスを持ちます。この 2つ以外はすべてのブラウザで同じように機能します
あなたの書くイベントハンドラには、`SyntheticEvent` のインスタンスが渡されます。これはブラウザのネイティブイベントに対するクロスブラウザ版のラッパです。`stopPropagation()``preventDefault()` を含む、ブラウザのネイティブイベントと同じインターフェイスを持ちつつ、ブラウザ間で同じ挙動をするようになっています


```javascript
function onClick(event) {
console.log(event); // => nullified object.
console.log(event); // => 無効なオブジェクト
Copy link
Member

Choose a reason for hiding this comment

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

確かに「このあとで無効化される」ということみたいですね、ややこしい…

content/docs/reference-events.md Outdated Show resolved Hide resolved
@summertree128
Copy link
Contributor Author

@koba04 @smikitky
Thank you for your review! Changed all of them.
Especially line 13 was hard to understand for me, thank you for good advices.

@smikitky
Copy link
Member

smikitky commented Feb 5, 2019

私の方ではOKです!

Copy link
Member

@koba04 koba04 left a comment

Choose a reason for hiding this comment

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

@summertree128 原文にない改行が2つ含めれているのでそこだけ対応お願いします 🙇
その他はOKだと思います!

`SyntheticEvent` はプールされます。つまり、`SyntheticEvent` オブジェクトは再利用され、すべてのプロパティはイベントコールバックが呼び出された後に `null` で初期化されます。
これはパフォーマンス上の理由からです。
そのため、非同期処理の中でイベントオブジェクトにアクセスすることはできません。

Copy link
Member

Choose a reason for hiding this comment

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

ここで原文と比較すると2行ずれているので、行数を合わせていただけると 🙏
### イベントのプールの上とそのため、非同期処理の中でイベントオブジェクトにアクセスすることはできません。の下にそれぞれに不要な改行があります。

Copy link
Contributor Author

Choose a reason for hiding this comment

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

すみません、気づいてませんでした。細かいところありがとうございます 🙏
修正しました。

@tesseralis tesseralis mentioned this pull request Feb 5, 2019
90 tasks
@koba04 koba04 merged commit 23e88ff into reactjs:master Feb 5, 2019
@koba04
Copy link
Member

koba04 commented Feb 5, 2019

@summertree128 対応ありがとうございました!mergeしました 🚀🚀🚀

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.

None yet

3 participants