Skip to content

Commit 1430829

Browse files
committed
translate 01-svelte/02-reactivity into Japanese
1 parent 2846d29 commit 1430829

File tree

4 files changed

+19
-19
lines changed

4 files changed

+19
-19
lines changed

content/tutorial/01-svelte/02-reactivity/01-reactive-assignments/README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,20 @@
22
title: Assignments
33
---
44

5-
At the heart of Svelte is a powerful system of _reactivity_ for keeping the DOM in sync with your application state — for example, in response to an event.
5+
Svelteの中心には、DOMを(例えば、イベントに応じて)アプリケーションの状態に同期し続けさせるための強力な *reactivity* システムがあります。
66

7-
To demonstrate it, we first need to wire up an event handler (we'll learn more about these [later](/tutorial/dom-events)):
7+
これを実演するには、まずイベントハンドラ (これは[後ほど](/tutorial/dom-events)学習します) を定義する必要があります。
88

99
```svelte
1010
<button +++on:click={increment}+++>
1111
```
1212

13-
Inside the `increment` function, all we need to do is change the value of `count`:
13+
`increment` 関数の内側で必要なのは `count` の値を変更することだけです。
1414

1515
```js
1616
function increment() {
1717
+++count += 1;+++
1818
}
1919
```
2020

21-
Svelte 'instruments' this assignment with some code that tells it the DOM will need to be updated.
21+
Svelteは、DOMが更新される必要があることを伝えるコードをこの代入に'取り付け'ます。

content/tutorial/01-svelte/02-reactivity/02-reactive-declarations/README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,23 @@
22
title: Declarations
33
---
44

5-
Svelte automatically updates the DOM when your component's state changes. Often, some parts of a component's state need to be computed from _other_ parts (such as a `fullname` derived from a `firstname` and a `lastname`), and recomputed whenever they change.
5+
Svelte は、コンポーネントの状態が変更されると自動的に DOM を更新します。しばしば、コンポーネントの状態には、 _他の_ 状態から計算しなければならない部分があり (例えば、`firstname``lastname` から派生する `fullname`)、それらが変更されるたびに再計算しなければなりません。
66

7-
For these, we have _reactive declarations_. They look like this:
7+
これに対応するために、 _リアクティブ宣言(reactive declarations)_ があります。次のように記述します。
88

99
```js
1010
let count = 0;
1111
+++$: doubled = count * 2;+++
1212
```
1313

14-
> Don't worry if this looks a little alien. It's [valid](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/label) (if unconventional) JavaScript, which Svelte interprets to mean 're-run this code whenever any of the referenced values change'. Once you get used to it, there's no going back.
14+
> これが少し異質に見えても心配しないでください。これは(見慣れないかもしれませんが) [正しい](https://developer.mozilla.org/ja/docs/Web/JavaScript/Reference/Statements/label) JavaScript で、Svelte は「参照される値が変わるたびにこのコードを再実行する」という意味だと解釈します。一度慣れてしまえば、もう戻れません。
1515
16-
Let's use `doubled` in our markup:
16+
マークアップで `doubled` を使ってみましょう。
1717

1818
```svelte
1919
<button>...</button>
2020
2121
+++<p>{count} doubled is {doubled}</p>+++
2222
```
2323

24-
Of course, you could just write `{count * 2}` in the markup instead — you don't have to use reactive values. Reactive values become particularly valuable (no pun intended) when you need to reference them multiple times, or you have values that depend on _other_ reactive values.
24+
もちろん、代わりに `{count * 2}` とマークアップに書くだけでもよいでしょう。リアクティブな値を使用する必要はありません。リアクティブな値は、複数回参照する必要がある場合や、*他の* リアクティブな値に依存する値がある場合に特に価値があります。

content/tutorial/01-svelte/02-reactivity/03-reactive-statements/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@
22
title: Statements
33
---
44

5-
We're not limited to declaring reactive _values_ — we can also run arbitrary _statements_ reactively. For example, we can log the value of `count` whenever it changes:
5+
リアクティブな ** を宣言するだけでなく、任意の *ステートメント* をリアクティブに実行することもできます。例えば、`count` の値が変化するたびにログを取ることができます。
66

77
```js
88
let count = 0;
99

1010
+++$: console.log(`the count is ${count}`);+++
1111
```
1212

13-
You can easily group statements together with a block:
13+
ブロックで簡単にステートメントをグループ化することができます。
1414

1515
```js
1616
$: +++{+++
@@ -19,7 +19,7 @@ $: +++{+++
1919
+++}+++
2020
```
2121

22-
You can even put the `$:` in front of things like `if` blocks:
22+
`if` ブロックなどの前に `$:` を置くこともできます。
2323

2424
```js
2525
$: +++if (count >= 10)+++ {

content/tutorial/01-svelte/02-reactivity/04-updating-arrays-and-objects/README.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
title: Updating arrays and objects
33
---
44

5-
Because Svelte's reactivity is triggered by assignments, using array methods like `push` and `splice` won't automatically cause updates. For example, clicking the 'Add a number' button doesn't currently do anything.
5+
Svelte のりアクティビティは代入によってトリガーされるため、`push` `splice` のような配列のメソッドを使用しても更新が自動的に行われません。例えば、'Add a number' ボタンをクリックしても今のところ何も起こりません。
66

7-
One way to fix that is to add an assignment that would otherwise be redundant:
7+
これを修正する方法の1つとして、冗長に見えるかもしれませんが、代入を追加することです。
88

99
```js
1010
function addNumber() {
@@ -13,29 +13,29 @@ function addNumber() {
1313
}
1414
```
1515

16-
But there's a more idiomatic solution:
16+
もう少し慣用的な解決策もあります。
1717

1818
```js
1919
function addNumber() {
2020
numbers = +++[...numbers, numbers.length + 1];+++
2121
}
2222
```
2323

24-
You can use similar patterns to replace `pop`, `shift`, `unshift` and `splice`.
24+
同様のパターンで、`pop``shift``unshift``splice` を置き換えることができます。
2525

26-
Assignments to _properties_ of arrays and objects — e.g. `obj.foo += 1` or `array[i] = x` — work the same way as assignments to the values themselves.
26+
配列やオブジェクトの *プロパティ* への代入(例:`obj.foo += 1` `array[i] = x`)は値自体への代入と同じように動作します。
2727

2828
```js
2929
function addNumber() {
3030
numbers[numbers.length] = numbers.length + 1;
3131
}
3232
```
3333

34-
A simple rule of thumb: the name of the updated variable must appear on the left hand side of the assignment. For example this...
34+
大まかなまとめ: 更新される変数の名前は、代入の左側に置かなければならない。例えばこれは…
3535

3636
```js
3737
const foo = obj.foo;
3838
foo.bar = 'baz';
3939
```
4040

41-
...won't trigger reactivity on `obj.foo.bar`, unless you follow it up with `obj = obj`.
41+
`obj.foo.bar` に対するリアクティビティはトリガーされません。もしトリガーしたければ、`obj = obj` を続けて書く必要があります。

0 commit comments

Comments
 (0)