Skip to content

Commit d495682

Browse files
committed
translate 03-advanced-svelte/10-module-context into Japanese
1 parent 42c21ce commit d495682

File tree

2 files changed

+8
-8
lines changed
  • content/tutorial/03-advanced-svelte/10-module-context

2 files changed

+8
-8
lines changed

content/tutorial/03-advanced-svelte/10-module-context/01-sharing-code/README.md

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

5-
In all the examples we've seen so far, the `<script>` block contains code that runs when each component instance is initialised. For the vast majority of components, that's all you'll ever need.
5+
これまで見てきたすべての例では、`<script>` ブロックには各コンポーネントのインスタンスが初期化されたときに実行されるコードが含まれています。大部分のコンポーネントでは、これだけで十分です。
66

7-
Very occasionally, you'll need to run some code outside of an individual component instance. For example, you can play all five of these audio players simultaneously; it would be better if playing one stopped all the others.
7+
ごく稀に、個々のコンポーネントのインスタンスの外でコードを実行する必要があることがあります。例えば、5つのオーディオプレーヤーを同時に再生することができますが、1つを再生すると他のすべてのオーディオプレーヤーが停止した方がより良いでしょう。
88

9-
We can do that by declaring a `<script context="module">` block. Code contained inside it will run once, when the module first evaluates, rather than when a component is instantiated. Place this at the top of `AudioPlayer.svelte`:
9+
これを実現するには、`<script context="module">` ブロックを宣言します。ここに含まれるコードは、コンポーネントがインスタンス化されたときではなく、モジュールが最初に評価されたときに一度だけ実行されます。これを `AudioPlayer.svelte` の先頭に配置してください。
1010

1111
```svelte
1212
<script context="module">
1313
let current;
1414
</script>
1515
```
1616

17-
It's now possible for the components to 'talk' to each other without any state management:
17+
これで状態を管理することなく、コンポーネント同士がお互いに「話す」ことが可能になりました。
1818

1919
```js
2020
function stopOthers() {

content/tutorial/03-advanced-svelte/10-module-context/02-module-exports/README.md

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

5-
Anything exported from a `context="module"` script block becomes an export from the module itself. If we export a `stopAll` function from `AudioPlayer.svelte`...
5+
`context="module"` スクリプトブロックからエクスポートされたものはすべてモジュール自体からのエクスポートになります。もし、`AudioPlayer.svelte` から `stopAll` 関数をエクスポートすると…
66

77
```svelte
88
<script context="module">
@@ -16,20 +16,20 @@ Anything exported from a `context="module"` script block becomes an export from
1616
</script>
1717
```
1818

19-
...we can then import it from `App.svelte`...
19+
…そしてそれを `App.svelte` でインポートすることができます…
2020

2121
```svelte
2222
<script>
2323
import AudioPlayer, { stopAll } from './AudioPlayer.svelte';
2424
</script>
2525
```
2626

27-
...and use it in an event handler:
27+
…さらにそれをイベントハンドラで使うことができます。
2828

2929
```svelte
3030
<button on:click={stopAll}>
3131
stop all audio
3232
</button>
3333
```
3434

35-
> You can't have a default export, because the component _is_ the default export.
35+
> default export は使うことはできません、なぜならコンポーネント ** default export だからです。

0 commit comments

Comments
 (0)