Skip to content

Commit 4a9c346

Browse files
authored
Translate 03-svelte-files.md from en to jp (#13)
* Translate 03-svelte-files.md from en to jp * Remove original english text in 03-svelte-files.md
1 parent 968dd8f commit 4a9c346

File tree

1 file changed

+17
-17
lines changed

1 file changed

+17
-17
lines changed
Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,41 @@
11
---
2-
title: .svelte files
2+
title: .svelte ファイル
33
---
44

5-
Components are the building blocks of Svelte applications. They are written into `.svelte` files, using a superset of HTML.
5+
コンポーネントは Svelte アプリケーションの構成要素です。これらは `.svelte` ファイルに書かれ、HTML のスーパーセットを使って記述されます。
66

7-
All three sections — script, styles and markup — are optional.
7+
以下の3つのセクション — script, styles, markup — は任意です。
88

99
<!-- prettier-ignore -->
1010
```svelte
1111
/// file: MyComponent.svelte
1212
<script module>
13-
// module-level logic goes here
14-
// (you will rarely use this)
13+
// モジュールレベルのロジックはここに書きます
14+
// (ほとんど使うことはありません)
1515
</script>
1616
1717
<script>
18-
// instance-level logic goes here
18+
// インスタンスレベルのロジックはここに書きます
1919
</script>
2020
21-
<!-- markup (zero or more items) goes here -->
21+
<!-- マークアップ (0行以上) はここに書きます -->
2222
2323
<style>
24-
/* styles go here */
24+
/* スタイルはここに書きます */
2525
</style>
2626
```
2727

2828
## `<script>`
2929

30-
A `<script>` block contains JavaScript (or TypeScript, when adding the `lang="ts"` attribute) that runs when a component instance is created. Variables declared (or imported) at the top level can be referenced in the component's markup.
30+
`<script>` ブロックは、コンポーネントインスタンスが作成されたときに実行される JavaScript (または `lang="ts` 属性を追加した時の TypeScript) を含みます。トップレベルで宣言 (またはインポート) された変数は、コンポーネントのマークアップで参照できます。
3131

32-
In addition to normal JavaScript, you can use _runes_ to declare [component props]($props) and add reactivity to your component. Runes are covered in the next section.
32+
通常のJavaScriptに加えて、_runes_ を使用して[コンポーネントのプロパティ]($props)を宣言したり、コンポーネントにリアクティビティを追加したりできます。Runes については次のセクションで説明します。
3333

3434
<!-- TODO describe behaviour of `export` -->
3535

3636
## `<script module>`
3737

38-
A `<script>` tag with a `module` attribute runs once when the module first evaluates, rather than for each component instance. Variables declared in this block can be referenced elsewhere in the component, but not vice versa.
38+
`<script>` タグに `module` 属性を付けると、モジュールが最初に評価される際に1回だけ実行され、各コンポーネントインスタンスごとに実行されるわけではありません。このブロックで宣言された変数は、コンポーネント内の他の場所から参照できますが、その逆はできません。
3939

4040
```svelte
4141
<script module>
@@ -48,24 +48,24 @@ A `<script>` tag with a `module` attribute runs once when the module first evalu
4848
</script>
4949
```
5050

51-
You can `export` bindings from this block, and they will become exports of the compiled module. You cannot `export default`, since the default export is the component itself.
51+
このブロックから `export` バインディングを使用してエクスポートすることができ、それらはコンパイルされたモジュールのエクスポートとして扱われます。ただし、コンポーネント自体にデフォルトエクスポートがされるため `export default` は使用できません。
5252

53-
> [!NOTE] If you are using TypeScript and import such exports from a `module` block into a `.ts` file, make sure to have your editor setup so that TypeScript knows about them. This is the case for our VS Code extension and the IntelliJ plugin, but in other cases you might need to setup our [TypeScript editor plugin](https://www.npmjs.com/package/typescript-svelte-plugin).
53+
> [!NOTE] TypeScriptを使用していて、`module` ブロックからエクスポートされたものを `.ts` ファイルにインポートする場合は、TypeScriptがそれらを認識できるようにエディタの設定を行う必要があります。VS Code拡張機能やIntelliJプラグインを使用している場合はこの設定が必要となりますが、それ以外の場合は [TypeScript エディタープラグイン](https://www.npmjs.com/package/typescript-svelte-plugin) を設定する必要がある場合があります。
5454
5555
> [!LEGACY]
56-
> In Svelte 4, this script tag was created using `<script context="module">`
56+
> Svelte 4 では、このスクリプトタグは `<script context="module">` を使用して作成されました。
5757
5858
## `<style>`
5959

60-
CSS inside a `<style>` block will be scoped to that component.
60+
`<style>` ブロック内のCSSは、そのコンポーネントにスコープされます。
6161

6262
```svelte
6363
<style>
6464
p {
65-
/* this will only affect <p> elements in this component */
65+
/* これはこのコンポネント内の <p> 要素にのみ影響します */
6666
color: burlywood;
6767
}
6868
</style>
6969
```
7070

71-
For more information, head to the section on [styling](scoped-styles).
71+
詳細については、[スタイリング](scoped-styles) のセクションをご覧ください。

0 commit comments

Comments
 (0)