Skip to content

Commit 1760153

Browse files
committed
restore wrongly overridden translation
1 parent d2ee0c0 commit 1760153

File tree

17 files changed

+127
-138
lines changed

17 files changed

+127
-138
lines changed

website/i18n/ja/docusaurus-plugin-content-docs/version-0.21/advanced-topics/optimizations.mdx

Lines changed: 32 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
---
2-
title: 'Optimizations & Best Practices'
2+
title: '最適化とベストプラクティス'
33
sidebar_label: Optimizations
44
description: 'Make your app faster'
55
---
66

7-
## Using smart pointers effectively
7+
## 効果的にスマートポインタを使う
88

9-
**Note: if you're unsure about some of the terms used in this section, the Rust Book has a useful
10-
[chapter about smart pointers](https://doc.rust-lang.org/book/ch15-00-smart-pointers.html).**
9+
**注意: このセクションで使われている用語がわからなければ Rust book は
10+
[スマートポインタについての章](https://doc.rust-lang.org/book/ch15-00-smart-pointers.html)
11+
があり、非常に有用です。**
1112

1213
To avoid cloning large amounts of data to create props when re-rendering, we can use
1314
smart pointers to only clone a reference to the data instead of the data itself. If you pass
@@ -79,31 +80,29 @@ If your main crate is too heavyweight, or you want to rapidly iterate on a deepl
7980
a page that renders on top of another page\), you can use an example crate to create a simplified
8081
implementation of the main page and additionally render the component you are working on.
8182

82-
## Reducing binary sizes
83+
## バイナリサイズを小さくする
8384

84-
- optimize Rust code
85-
- `cargo.toml` \( defining release profile \)
86-
- optimize wasm code using `wasm-opt`
85+
- Rust のコードを最適化する
86+
- `cargo.toml` \( release profile を定義 \)
87+
- `wasm-opt`を用いて wasm のコードを最適化する
8788

88-
**Note: more information about reducing binary sizes can be found in the
89-
[Rust Wasm Book](https://rustwasm.github.io/book/reference/code-size.html#optimizing-builds-for-code-size).**
89+
**注意: バイナリサイズを小さくするのについては[Rust Wasm Book](https://rustwasm.github.io/book/reference/code-size.html#optimizing-builds-for-code-size)に詳しく書いてあります。**
9090

9191
### Cargo.toml
9292

93-
It is possible to configure release builds to be smaller using the available settings in the
94-
`[profile.release]` section of your `Cargo.toml`.
93+
`Cargo.toml``[profile.release]`のセクションに設定を書き込むことでリリースビルドを小さくすることが可能です。
9594

9695
```toml, title=Cargo.toml
9796
[profile.release]
98-
# less code to include into binary
97+
# バイナリに含むコードを少なくする
9998
panic = 'abort'
100-
# optimization over all codebase ( better optimization, slower build )
99+
# コードベース全体での最適化 ( 良い最適化だがビルドが遅くなる)
101100
codegen-units = 1
102-
# optimization for size ( more aggressive )
101+
# サイズの最適化( よりアグレッシブに )
103102
opt-level = 'z'
104-
# optimization for size
103+
# サイズの最適化
105104
# opt-level = 's'
106-
# link time optimization using using whole-program analysis
105+
# プログラム全体の分析によるリンク時最適化
107106
lto = true
108107
```
109108

@@ -133,31 +132,31 @@ that require occasional attention and tweaking. Use these experimental options w
133132

134133
### wasm-opt
135134

136-
Further, it is possible to optimize the size of `wasm` code.
135+
更に`wasm`のコードのサイズを最適化することができます。
137136

138-
The Rust Wasm Book has a section about reducing the size of Wasm binaries:
137+
The Rust Wasm Book には Wasm バイナリのサイズを小さくすることについてのセクションがあります:
139138
[Shrinking .wasm size](https://rustwasm.github.io/book/game-of-life/code-size.html)
140139

141-
- using `wasm-pack` which by default optimizes `wasm` code in release builds
142-
- using `wasm-opt` directly on `wasm` files.
140+
- `wasm-pack`でデフォルトの`wasm`のコードをリリースビルド時に最適化する
141+
- `wasm-opt`によって直接`wasm`ファイルを最適化する
143142

144143
```text
145144
wasm-opt wasm_bg.wasm -Os -o wasm_bg_opt.wasm
146145
```
147146

148-
#### Build size of 'minimal' example in yew/examples/
147+
#### yew/examples/にある例を小さなサイズでビルドする
149148

150-
Note: `wasm-pack` combines optimization for Rust and Wasm code. `wasm-bindgen` is used in this example without any Rust size optimization.
149+
注意: `wasm-pack`Rust Wasm のコードへの最適化を組み合わせます。`wasm-bindgen`はこの例では Rust のサイズ最適化を用いていません。
151150

152-
| used tool | size |
153-
| :-------------------------- | :---- |
154-
| wasm-bindgen | 158KB |
155-
| wasm-bindgen + wasm-opt -Os | 116KB |
156-
| wasm-pack | 99 KB |
151+
| 使用したツール | サイズ |
152+
| :-------------------------- | :----- |
153+
| wasm-bindgen | 158KB |
154+
| wasm-bindgen + wasm-opt -Os | 116KB |
155+
| wasm-pack | 99 KB |
157156

158-
## Further reading:
157+
## 参考文献:
159158

160-
- [The Rust Book's chapter on smart pointers](https://doc.rust-lang.org/book/ch15-00-smart-pointers.html)
161-
- [Information from the Rust Wasm Book about reducing binary sizes](https://rustwasm.github.io/book/reference/code-size.html#optimizing-builds-for-code-size)
162-
- [Documentation about Rust profiles](https://doc.rust-lang.org/cargo/reference/profiles.html)
163-
- [binaryen project](https://github.com/WebAssembly/binaryen)
159+
- [The Rust Book のスマートポインタに関する章](https://doc.rust-lang.org/book/ch15-00-smart-pointers.html)
160+
- [the Rust Wasm Book でのバイナリサイズを小さくすることについて](https://rustwasm.github.io/book/reference/code-size.html#optimizing-builds-for-code-size)
161+
- [Rust profiles についてのドキュメント](https://doc.rust-lang.org/cargo/reference/profiles.html)
162+
- [binaryen プロジェクト](https://github.com/WebAssembly/binaryen)

website/i18n/ja/docusaurus-plugin-content-docs/version-0.21/advanced-topics/struct-components/lifecycle.mdx

Lines changed: 26 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,22 @@
11
---
2-
title: 'Lifecycle'
3-
description: 'Components and their lifecycle hooks'
2+
title: 'ライフサイクル'
3+
description: 'コンポーネントとそのライフサイクルフック'
44
---
55

6-
The `Component` trait has a number of methods which need to be implemented; Yew will call these at different
7-
stages in the lifecycle of a component.
6+
`Component` トレイトには実装が必要なメソッドがいくつかあります。Yew はコンポーネントのライフサイクルの異なる段階でこれらを呼び出します。
87

9-
## Lifecycle
8+
## ライフサイクル
109

1110
:::important contribute
1211
`Contribute to our docs:` [Add a diagram of the component lifecycle](https://github.com/yewstack/yew/issues/1915)
1312
:::
1413

15-
## Lifecycle Methods
14+
## ライフサイクルのメソッド
1615

1716
### Create
1817

19-
When a component is created, it receives properties from its parent component and is stored within
20-
the `Context<Self>` that is passed down to the `create` method. The properties can be used to
21-
initialize the component's state and the "link" can be used to register callbacks or send messages to the component.
18+
コンポーネントが作られると、親コンポーネントからプロパティを受け取り、`create` メソッドに渡される `Context<Self>` 内に格納されます。
19+
プロパティはコンポーネントの状態を初期化するのに使われ、"link"はコールバックを登録したりコンポーネントにメッセージを送るのに使われます。
2220

2321
```rust
2422
use yew::{Component, Context, html, Html, Properties};
@@ -48,12 +46,10 @@ impl Component for MyComponent {
4846

4947
### View
5048

51-
The `view` method allows you to describe how a component should be rendered to the DOM. Writing
52-
HTML-like code using Rust functions can become quite messy, so Yew provides a macro called `html!`
53-
for declaring HTML and SVG nodes (as well as attaching attributes and event listeners to them) and a
54-
convenient way to render child components. The macro is somewhat similar to React's JSX (the
55-
differences in programming language aside).
56-
One difference is that Yew provides a shorthand syntax for properties, similar to Svelte, where instead of writing `onclick={onclick}`, you can just write `{onclick}`.
49+
コンポーネントは`view()`メソッドによってレイアウトを宣言します。
50+
Yew は`html!`マクロによって HTML と SVG ノード、リスナー、子コンポーネントを宣言できます。
51+
マクロは React の JSX のような動きをしますが、JavaScript の代わりに Rust の式を用います。
52+
Yew は Svelte のように、`onclick={onclick}` の代わりに `{onclick}` と書くことができる省略構文を提供しています。
5753

5854
```rust
5955
use yew::{Component, Context, html, Html, Properties};
@@ -88,15 +84,14 @@ impl Component for MyComponent {
8884
}
8985
```
9086

91-
For usage details, check out [the `html!` guide](concepts/html/introduction.mdx).
87+
使い方については[`html!`ガイド](concepts/html/introduction.mdx)をご確認ください。
9288

9389
### Rendered
9490

95-
The `rendered` component lifecycle method is called once `view` has been called and Yew has rendered
96-
the results to the DOM, but before the browser refreshes the page. This method is useful when you
97-
want to perform actions that can only be completed after the component has rendered elements. There
98-
is also a parameter called `first_render` which can be used to determine whether this function is
99-
being called on the first render, or instead a subsequent one.
91+
`rendered()`コンポーネントのライフサイクルのメソッドは`view()`が処理されて Yew がコンポーネントをレンダリングした後、
92+
ブラウザがページを更新する前に呼ばれます。
93+
コンポーネントは、コンポーネントが要素をレンダリングした後にのみ実行できるアクションを実行するため、このメソッドを実装したい場合があります。
94+
コンポーネントが初めてレンダリングされたかどうかは `first_render` パラメータで確認できます。
10095

10196
```rust
10297
use web_sys::HtmlInputElement;
@@ -137,17 +132,17 @@ impl Component for MyComponent {
137132
```
138133

139134
:::tip note
140-
Note that this lifecycle method does not require implementation and will do nothing by default.
135+
ライフサイクルメソッドは実装の必要がなく、デフォルトでは何もしません。
141136
:::
142137

143138
### Update
144139

145-
Communication with components happens primarily through messages which are handled by the
146-
`update` lifecycle method. This allows the component to update itself
147-
based on what the message was, and determine if it needs to re-render itself. Messages can be sent
148-
by event listeners, child components, Agents, Services, or Futures.
140+
コンポーネントは動的で、非同期メッセージを受信するために登録することができます。
141+
ライフサイクルメソッド `update()` はメッセージごとに呼び出されます。
142+
これにより、コンポーネントはメッセージが何であったかに基づいて自身を更新し、自身を再レンダリングする必要があるかどうかを判断することができます。
143+
メッセージは、HTML 要素リスナーによってトリガーされたり、子コンポーネント、エージェント、サービス、または Futures によって送信されたりします。
149144

150-
Here is an example of what an implementation of `update` could look like:
145+
`update()`がどのようなのかについての例は以下の通りです:
151146

152147
```rust
153148
use yew::{Component, Context, html, Html};
@@ -199,10 +194,10 @@ impl Component for MyComponent {
199194

200195
### Changed
201196

202-
Components may be re-rendered by their parents. When this happens, they could receive new properties
203-
and need to re-render. This design facilitates parent-to-child component communication by just
204-
changing the values of a property. There is a default implementation that re-renders the component
205-
when props are changed.
197+
コンポーネントは親によって再レンダリングされることがあります。
198+
このような場合、新しいプロパティを受け取り、再レンダリングを選択する可能性があります。
199+
この設計では、プロパティを変更することで、親から子へのコンポーネントの通信が容易になります。
200+
props が変更されたときにコンポーネントを再レンダリングするデフォルト実装があります。
206201

207202
### Destroy
208203

website/i18n/ja/docusaurus-plugin-content-docs/version-0.21/advanced-topics/struct-components/properties.mdx

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,20 @@ title: 'Properties'
33
description: 'Parent to child communication'
44
---
55

6-
Properties enable child and parent components to communicate with each other.
7-
Every component has an associated properties type which describes what is passed down from the parent.
8-
In theory, this can be any type that implements the `Properties` trait, but in practice, there is no
9-
reason for it to be anything but a struct where each field represents a property.
6+
プロパティは、子コンポーネントと親コンポーネントが互いに通信できるようにします。
7+
各コンポーネントには、親から渡されるものを記述する関連付けられたプロパティタイプがあります。
8+
理論的には、これは `Properties` trait を実装する任意のタイプにすることができますが、実際には
9+
各フィールドがプロパティを表す構造体以外にする理由はありません。
1010

11-
## Derive macro
11+
## マクロの継承
1212

13-
Instead of implementing the `Properties` trait yourself, you should use `#[derive(Properties)]` to
14-
automatically generate the implementation instead.
15-
Types for which you derive `Properties` must also implement `PartialEq`.
13+
`Properties`を自分で実装しようとせず、代わりに`#[derive(Properties)]`を使ってください。
14+
`Properties`を継承した型は`PartialEq`も実装していなければいけません。
1615

17-
### Field attributes
16+
### フィールド属性
1817

19-
When deriving `Properties`, all fields are required by default.
20-
The following attributes allow you to give your props initial values which will be used unless they are set to another value.
18+
デフォルトでは、`Properties` を導出する構造体内のフィールドは必須です。
19+
以下の属性を使うと、props に初期値を与えることができ、他の値に設定されない限りこの値が使用されます。
2120

2221
:::tip
2322
Attributes aren't visible in Rustdoc generated documentation.
@@ -39,13 +38,16 @@ Call `function` to initialize the prop value. `function` should have the signatu
3938

4039
## `PartialEq`
4140

42-
`Properties` require `PartialEq` to be implemented. This is so that they can be compared by Yew to call the `changed` method
43-
only when they change.
41+
もし可能なら props で `PartialEq` を継承するのが良いかもしれません。
42+
`PartialEq`を使うことで、不必要な再レンダリングを避けることができます
43+
(これについては、**最適化とベストプラクティス**のセクションで説明しています)。
4444

45-
## Memory/speed overhead of using Properties
45+
## プロパティを使用する際のメモリと速度のオーバーヘッド
4646

47-
Internally properties are reference counted. This means that only a pointer is passed down the component tree for props.
48-
It saves us from the cost of having to clone the entire props, which might be expensive.
47+
`Component::view`ではコンポーネントの状態への参照を取り、それを使って `Html` を作成します。
48+
しかし、プロパティは自身の値です。
49+
つまり、それらを作成して子コンポーネントに渡すためには、`view` 関数で提供される参照を所有する必要があるのです。
50+
これは所有する値を取得するためにコンポーネントに渡される参照を暗黙のうちにクローンすることで行われます。
4951

5052
:::tip
5153
Make use of `AttrValue` which is our custom type for attribute values instead of defining them as String or another similar type.

website/i18n/ja/docusaurus-plugin-content-docs/version-0.21/advanced-topics/struct-components/refs.mdx

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,16 @@
11
---
2-
title: 'Refs'
3-
description: 'Out-of-band DOM access'
2+
title: Refs
3+
description: Out-of-band DOM access
44
---
55

6-
The `ref` keyword can be used inside of any HTML element or component to get the DOM `Element` that
7-
the item is attached to. This can be used to make changes to the DOM outside of the `view` lifecycle
8-
method.
6+
`ref`は、任意の HTML 要素やコンポーネントの内部で、割り当てられている DOM`Element`を取得するために使用することができます。
7+
これは、`view` ライフサイクルメソッドの外で DOM に変更を加えるために使用できます。
98

10-
This is useful for getting ahold of canvas elements, or scrolling to different sections of a page.
9+
これは、キャンバスの要素を取得したり、ページの異なるセクションにスクロールしたりするのに便利です。
1110
For example, using a `NodeRef` in a component's `rendered` method allows you to make draw calls to
1211
a canvas element after it has been rendered from `view`.
1312

14-
The syntax is:
13+
構文は以下の通りです:
1514

1615
```rust
1716
use web_sys::Element;

website/i18n/zh-Hans/docusaurus-plugin-content-docs/version-0.21/advanced-topics/how-it-works.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
---
22
title: 'How it works'
3-
description: 'Low level details about the framework'
3+
description: '有关框架的底层细节'
44
---
55

6-
# Low-level library internals
6+
# 底层库的内部细节
77

88
## Under the hood of the `html!` macro
99

website/i18n/zh-Hans/docusaurus-plugin-content-docs/version-0.21/advanced-topics/optimizations.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
2-
title: 'Optimizations & Best Practices'
2+
title: '性能优化与最佳实践'
33
sidebar_label: Optimizations
4-
description: 'Make your app faster'
4+
description: 加速你的应用程序
55
---
66

77
## Using smart pointers effectively

website/i18n/zh-Hans/docusaurus-plugin-content-docs/version-0.21/advanced-topics/struct-components/callbacks.mdx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
---
2-
title: 'Callbacks'
2+
title: '回调(Callbacks)'
3+
description: 'ComponentLink 和 Callbacks'
34
---
45

56
## Callbacks
67

7-
Callbacks are used to communicate with services, agents, and parent components within Yew.
8-
Internally their type is just `Fn` wrapped in `Rc` to allow them to be cloned.
8+
Callbacks 用于与 Yew 中的 services,agents 和父组件进行通信。它们仅仅是个 `Fn`,并由 `Rc` 包裹以允许被克隆。
99

10-
They have an `emit` function that takes their `<IN>` type as an argument and converts that to a message expected by its destination. If a callback from a parent is provided in props to a child component, the child can call `emit` on the callback in its `update` lifecycle hook to send a message back to its parent. Closures or Functions provided as props inside the `html!` macro are automatically converted to Callbacks.
10+
它们有一个 `emit` 函数,该函数将它的 `<IN>` 类型作为参数并将其转换为目标所期望的消息。如果一个回调从父组件中通过 props 提供给子组件,则子组件可以在其 `update` 生命周期钩子中对该回调调用 `emit`,以将消息发送回父组件。在 `html!` 宏内被提供作为 props 的闭包或函数会自动转换为 Callbacks
1111

1212
A simple use of a callback might look something like this:
1313

0 commit comments

Comments
 (0)