Skip to content

Commit 7adf5f1

Browse files
committed
translate 03-advanced-svelte/07-composition into Japanese
1 parent d612b57 commit 7adf5f1

File tree

5 files changed

+22
-22
lines changed

5 files changed

+22
-22
lines changed

content/tutorial/03-advanced-svelte/07-composition/01-slots/README.md

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

5-
Just like elements can have children...
5+
HTML要素が子を持つことができるように…
66

77
```svelte
88
<div>
99
<p>I'm a child of the div</p>
1010
</div>
1111
```
1212

13-
...so can components. Before a component can accept children, though, it needs to know where to put them. We do this with the `<slot>` element. Put this inside `Box.svelte`:
13+
…コンポーネントもそうすることができます。しかしコンポーネントが子を受け入れる前に、どこに子を置くかを知っておく必要があります。これを `<slot>` 要素で行います。これを `Box.svelte` の中に入れてください。
1414

1515
```svelte
1616
<div class="box">
1717
<slot></slot>
1818
</div>
1919
```
2020

21-
You can now put things in the box:
21+
これで box に物を入れることができるようになりました。
2222

2323
```svelte
2424
<Box>

content/tutorial/03-advanced-svelte/07-composition/02-slot-fallbacks/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
title: Slot fallbacks
33
---
44

5-
A component can specify _fallbacks_ for any slots that are left empty, by putting content inside the `<slot>` element:
5+
コンポーネントは、`<slot>` 要素の中にコンテンツを入れることで、空のままになっているスロットに対して *フォールバック* を指定することができます。
66

77
```svelte
88
<div class="box">
@@ -12,7 +12,7 @@ A component can specify _fallbacks_ for any slots that are left empty, by puttin
1212
</div>
1313
```
1414

15-
We can now create instances of `<Box>` without any children:
15+
これで、子を持たない `<Box>` のインスタンスを作成できるようになりました。
1616

1717
```svelte
1818
<Box>

content/tutorial/03-advanced-svelte/07-composition/03-named-slots/README.md

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

5-
The previous example contained a _default slot_, which renders the direct children of a component. Sometimes you will need more control over placement, such as with this `<ContactCard>`. In those cases, we can use _named slots_.
5+
前の例では、コンポーネントの直接の子をレンダリングする *デフォルトスロット* が含まれていました。この `<ContactCard>` のように、配置をより制御したい場合もあるでしょう。そのような場合には、*名前付きスロット* を使うことができます。
66

7-
In `ContactCard.svelte`, add a `name` attribute to each slot:
7+
`ContactCard.svelte` の各スロットに `name` 属性を追加します。
88

99
```svelte
1010
<article class="contact-card">
@@ -28,7 +28,7 @@ In `ContactCard.svelte`, add a `name` attribute to each slot:
2828
</article>
2929
```
3030

31-
Then, add elements with corresponding `slot="..."` attributes inside the `<ContactCard>` component:
31+
そして、対応する `slot="...."` 属性を持つ要素を `<ContactCard>` コンポーネント内に追加します。
3232

3333
```svelte
3434
<ContactCard>

content/tutorial/03-advanced-svelte/07-composition/04-optional-slots/README.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,21 @@
22
title: Checking for slot content
33
---
44

5-
> The images in this exercise don't currently work. You can switch to the old tutorial instead: https://svelte.dev/tutorial/optional-slots
5+
> この練習問題の画像の部分が現時点では動作しません。代わりに、既存のチュートリアルをお試しください: https://svelte.jp/tutorial/optional-slots
66
7-
In some cases, you may want to control parts of your component based on whether the parent passes in content for a certain slot. Perhaps you have a wrapper around that slot, and you don't want to render it if the slot is empty. Or perhaps you'd like to apply a class only if the slot is present. You can do this by checking the properties of the special `$$slots` variable.
7+
場合によっては、親が特定のスロットのコンテンツを渡すかどうかに基づいてコンポーネントの一部を制御したいことがあるかもしれません。おそらく、そのスロットの周りにラッパーを持っていて、スロットが空の場合はレンダリングしたくないでしょう。あるいは、スロットが存在する場合にのみクラスを適用したいと考えているかもしれません。これは、特別な変数 `$$slots` のプロパティをチェックすることで実現できます。
88

9-
`$$slots` is an object whose keys are the names of the slots passed in by the parent component. If the parent leaves a slot empty, then `$$slots` will not have an entry for that slot.
9+
`$$slots` は親コンポーネントから渡されたスロットの名前がキーとなるオブジェクトです。親コンポーネントがスロットを空にした場合、 `$$slots` はそのスロットのエントリを持ちません。
1010

11-
Notice that both instances of `<Project>` in this example render a container for comments and a notification dot, even though only one has comments. We want to use `$$slots` to make sure we only render these elements when the parent `<App>` passes in content for the `comments` slot.
11+
この例の `<Project>` のインスタンスは、片方だけにしかコメントがないにも関わらず、両方ともコメント用のコンテナと通知用のドットをレンダリングしていることに注目してください。親の `<App>` `comments` スロットにコンテンツを渡した場合にのみ、これらの要素をレンダリングするように `$$slots` を使用したいと思います。
1212

13-
In `Project.svelte`, update the `class:has-discussion` directive on the `<article>`:
13+
`Project.svelte`において、`<article>``class:has-discussion` ディレクティブを更新してください。
1414

1515
```svelte
1616
<article class:has-discussion={$$slots.comments}>
1717
```
1818

19-
Next, wrap the `comments` slot and its wrapping `<div>` in an `if` block that checks `$$slots`:
19+
次に、`comments` スロットとそれを囲んでいる `<div>` `$$slots` をチェックする `if` ブロックで囲みます。
2020

2121
```svelte
2222
{#if $$slots.comments}
@@ -27,4 +27,4 @@ Next, wrap the `comments` slot and its wrapping `<div>` in an `if` block that ch
2727
{/if}
2828
```
2929

30-
Now the comments container and the notification dot won't render when `<App>` leaves the `comments` slot empty.
30+
これで、`<App>` `comments` スロットが空の時は、コメントコンテナと通知ドットがレンダリングされなくなりました。

content/tutorial/03-advanced-svelte/07-composition/05-slot-props/README.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,19 @@
22
title: Slot props
33
---
44

5-
In this app, we have a `<Hoverable>` component that tracks whether the mouse is currently over it. It needs to pass that data _back_ to the parent component, so that we can update the slotted contents.
5+
このアプリには、現在マウスがその上に乗ったかどうかを追跡する `<Hoverable>` コンポーネントがあります。スロットの中身を更新できるように、そのデータを親コンポーネントに *戻す* 必要があります。
66

7-
For this, we use _slot props_. In `Hoverable.svelte`, pass the `hovering` value into the slot:
7+
これには *slotプロパティ(slot props)* を使います。`Hoverable.svelte` の中で `hovering` の値をスロットに渡します。
88

99
```svelte
1010
<div on:mouseenter={enter} on:mouseleave={leave}>
1111
<slot hovering={hovering}></slot>
1212
</div>
1313
```
1414

15-
> Remember you can also use the `{hovering}` shorthand, if you prefer.
15+
> お好みであれば、`{hovering}` というショートハンドを使えるのを覚えておいてください。
1616
17-
Then, to expose `hovering` to the contents of the `<Hoverable>` component, we use the `let` directive:
17+
そして `<Hoverable>` コンポーネントの内容に `hovering` を公開するには、`let` ディレクティブを使います。
1818

1919
```svelte
2020
<Hoverable let:hovering={hovering}>
@@ -28,7 +28,7 @@ Then, to expose `hovering` to the contents of the `<Hoverable>` component, we us
2828
</Hoverable>
2929
```
3030

31-
You can rename the variable, if you want — let's call it `active` in the parent component:
31+
必要に応じて変数の名前を変更することができます。親コンポーネントでは `active` と呼ぶようにしましょう。
3232

3333
```svelte
3434
<Hoverable let:hovering={active}>
@@ -42,6 +42,6 @@ You can rename the variable, if you want — let's call it `active` in the paren
4242
</Hoverable>
4343
```
4444

45-
You can have as many of these components as you like, and the slotted props will remain local to the component where they're declared.
45+
これらのコンポーネントは好きなだけ持つことができ、slotプロパティは、それらが宣言されているコンポーネントに対してローカルであり続けます。
4646

47-
> Named slots can also have props; use the `let` directive on an element with a `slot="..."` attribute, instead of on the component itself.
47+
> 名前付きスロットはプロパティを持つこともできます。コンポーネント自身ではなく、`slot="...."` 属性を持つ要素に対して `let` ディレクティブを使用してください。

0 commit comments

Comments
 (0)