Skip to content

Commit 15fb1c0

Browse files
authored
Japanese translation (Components section) (#43)
* Japanese translation (Components section) * fix: link title
1 parent cfdd8ba commit 15fb1c0

File tree

5 files changed

+94
-94
lines changed

5 files changed

+94
-94
lines changed

.vitepress/locales/ja.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,17 +60,17 @@ export default {
6060
]
6161
},
6262
{
63-
text: 'Components',
63+
text: 'コンポーネント',
6464
items: [
6565
{
66-
text: 'Functional Components',
66+
text: '関数型コンポーネント',
6767
link: '/ja/breaking-changes/functional-components'
6868
},
6969
{
70-
text: 'Async Components',
70+
text: '非同期コンポーネント',
7171
link: '/ja/breaking-changes/async-components'
7272
},
73-
{ text: 'emits Option', link: '/ja/breaking-changes/emits-option' }
73+
{ text: 'emits オプション', link: '/ja/breaking-changes/emits-option' }
7474
]
7575
},
7676
{

src/ja/breaking-changes/async-components.md

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -3,27 +3,27 @@ badges:
33
- new
44
---
55

6-
# Async Components <MigrationBadges :badges="$frontmatter.badges" />
6+
# 非同期コンポーネント <MigrationBadges :badges="$frontmatter.badges" />
77

8-
## Overview
8+
## 概要
99

10-
Here is a high level overview of what has changed:
10+
変更点の概要は次のとおりです:
1111

12-
- New `defineAsyncComponent` helper method that explicitly defines async components
13-
- `component` option renamed to `loader`
14-
- Loader function does not inherently receive `resolve` and `reject` arguments and must return a Promise
12+
- 非同期コンポーネントを明示的に定義する新しいヘルパーメソッド `defineAsyncComponent`
13+
- `component` オプションは `loader` に名称変更されました
14+
- ローダー関数は `resolve` `reject` の引数を受け取らず、Promise を返す必要があります
1515

16-
For a more in-depth explanation, read on!
16+
より詳しい説明は続きをお読みください!
1717

18-
## Introduction
18+
## はじめに
1919

20-
Previously, async components were created by simply defining a component as a function that returned a promise, such as:
20+
以前は、以下のように promise を返す関数としてコンポーネントを定義するだけで、非同期コンポーネントが作成できました:
2121

2222
```js
2323
const asyncModal = () => import('./Modal.vue')
2424
```
2525

26-
Or, for the more advanced component syntax with options:
26+
もしくはオプションのついた、より高度なコンポーネント構文の場合は:
2727

2828
```js
2929
const asyncModal = {
@@ -35,19 +35,19 @@ const asyncModal = {
3535
}
3636
```
3737

38-
## 3.x Syntax
38+
## 3.x の構文
3939

40-
Now, in Vue 3, since functional components are defined as pure functions, async components definitions need to be explicitly defined by wrapping it in a new `defineAsyncComponent` helper:
40+
Vue 3 では、関数型コンポーネントは純粋な関数として定義されるため、非同期コンポーネントの定義は、新しい `defineAsyncComponent` ヘルパーでラップして明示的に定義する必要があります:
4141

4242
```js
4343
import { defineAsyncComponent } from 'vue'
4444
import ErrorComponent from './components/ErrorComponent.vue'
4545
import LoadingComponent from './components/LoadingComponent.vue'
4646

47-
// Async component without options
47+
// オプションなし非同期コンポーネント
4848
const asyncModal = defineAsyncComponent(() => import('./Modal.vue'))
4949

50-
// Async component with options
50+
// オプションあり非同期コンポーネント
5151
const asyncModalWithOptions = defineAsyncComponent({
5252
loader: () => import('./Modal.vue'),
5353
delay: 200,
@@ -57,11 +57,11 @@ const asyncModalWithOptions = defineAsyncComponent({
5757
})
5858
```
5959

60-
::: tip NOTE
61-
Vue Router supports a similar mechanism for asynchronously loading route components, known as *lazy loading*. Despite the similarities, this feature is distinct from Vue's support for async components. You should **not** use `defineAsyncComponent` when configuring route components with Vue Router. You can read more about this in the [Lazy Loading Routes](https://router.vuejs.org/guide/advanced/lazy-loading.html) section of the Vue Router documentation.
60+
::: tip 注意
61+
Vue Router は、ルート(route)コンポーネントを非同期にロードするための同様のメカニズムをサポートしており、*lazy loading* として知られています。類似しているとはいえ、この機能は Vue の非同期コンポーネントのサポートとは異なるものです。Vue Router でルートコンポーネントを設定する際、`defineAsyncComponent`**使用しないで**ください。これについては、Vue Router ドキュメントの [Lazy Loading Routes](https://router.vuejs.org/guide/advanced/lazy-loading.html) セクションで詳しく説明されています。
6262
:::
6363

64-
Another change that has been made from 2.x is that the `component` option is now renamed to `loader` in order to accurately communicate that a component definition cannot be provided directly.
64+
2.x からのもう 1 つの変更点は、コンポーネント定義を直接提供できないことを正確に伝えるために、`component` オプションが `loader` に名称変更されたことです。
6565

6666
```js{4}
6767
import { defineAsyncComponent } from 'vue'
@@ -75,15 +75,15 @@ const asyncModalWithOptions = defineAsyncComponent({
7575
})
7676
```
7777

78-
In addition, unlike 2.x, the loader function no longer receives the `resolve` and `reject` arguments and must always return a Promise.
78+
また、2.x とは異なり、loader 関数は `resolve` `reject` の引数を受け取らなくなり、常に Promise を返す必要があります。
7979

8080
```js
81-
// 2.x version
81+
// 2.x バージョン
8282
const oldAsyncComponent = (resolve, reject) => {
8383
/* ... */
8484
}
8585

86-
// 3.x version
86+
// 3.x バージョン
8787
const asyncComponent = defineAsyncComponent(
8888
() =>
8989
new Promise((resolve, reject) => {
@@ -92,7 +92,7 @@ const asyncComponent = defineAsyncComponent(
9292
)
9393
```
9494

95-
For more information on the usage of async components, see:
95+
非同期コンポーネントの使用方法の詳細については、こちらをご覧ください:
9696

97-
- [Guide: Async Components](https://ja.vuejs.org/guide/components/async.html)
98-
- [Migration build flag: `COMPONENT_ASYNC`](../migration-build.html#compat-configuration)
97+
- [ガイド: 非同期コンポーネント](https://ja.vuejs.org/guide/components/async.html)
98+
- [移行ビルドのフラグ: `COMPONENT_ASYNC`](../migration-build.html#compat-configuration)
Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
---
2-
title: emits Option
2+
title: emits オプション
33
badges:
44
- new
55
---
66

7-
# `emits` Option <MigrationBadges :badges="$frontmatter.badges" />
7+
# `emits` オプション <MigrationBadges :badges="$frontmatter.badges" />
88

9-
## Overview
9+
## 概要
1010

11-
Vue 3 now offers an `emits` option, similar to the existing `props` option. This option can be used to define the events that a component can emit to its parent.
11+
Vue 3 では、既存の `props` オプションと同様に、`emits` オプションを提供するようになりました。このオプションを使用してコンポーネントが親に発行可能なイベントを定義できます。
1212

13-
## 2.x Behavior
13+
## 2.x の動作
1414

15-
In Vue 2, you can define the props that a component receives, but you can't declare which events it can emit:
15+
Vue 2 ではコンポーネントが受け取るプロパティを定義できますが、そのコンポーネントが発行可能なイベントは宣言できません:
1616

1717
```vue
1818
<template>
@@ -28,9 +28,9 @@ In Vue 2, you can define the props that a component receives, but you can't decl
2828
</script>
2929
```
3030

31-
## 3.x Behavior
31+
## 3.x の動作
3232

33-
Similar to props, the events that the component emits can now be defined with the `emits` option:
33+
プロパティと同様に、コンポーネントが発行するイベントを `emits` オプションで定義できるようになりました:
3434

3535
```vue
3636
<template>
@@ -47,51 +47,51 @@ Similar to props, the events that the component emits can now be defined with th
4747
</script>
4848
```
4949

50-
The option also accepts an object, which allows the developer to define validators for the arguments that are passed with the emitted event, similar to validators in `props` definitions.
50+
このオプションにはオブジェクトも指定できます。開発者は、`props` 定義のバリデーターと同じように、発行されるイベントに渡される引数のバリデーターを定義できます。
5151

52-
For more information on this, please read the [API documentation for this feature](https://ja.vuejs.org/api/options-state.html#emits).
52+
詳細については、[この機能の API ドキュメント](https://ja.vuejs.org/api/options-state.html#emits)をお読みください。
5353

54-
## Migration Strategy
54+
## 移行手順
5555

56-
It is highly recommended that you document all the events emitted by each of your components using `emits`.
56+
`emits` を使って、各コンポーネントが発行するすべてのイベントをドキュメント化することを強くお勧めします。
5757

58-
This is especially important because of [the removal of the `.native` modifier](./v-on-native-modifier-removed.md). Any listeners for events that aren't declared with `emits` will now be included in the component's `$attrs`, which by default will be bound to the component's root node.
58+
特に、[`.native` 修飾子が削除される](./v-on-native-modifier-removed.md)ため重要です。`emits` で宣言されていないイベントリスナーは、コンポーネントの `$attrs` に含まれるようになり、デフォルトではコンポーネントのルートノードにバインドされます。
5959

60-
### Example
60+
###
6161

62-
For components that re-emit native events to their parent, this would now lead to two events being fired:
62+
ネイティブイベントを親に再発行するコンポーネントの場合、2 つのイベントが発生することになります:
6363

6464
```vue
6565
<template>
6666
<button v-on:click="$emit('click', $event)">OK</button>
6767
</template>
6868
<script>
6969
export default {
70-
emits: [] // without declared event
70+
emits: [] // イベント宣言なし
7171
}
7272
</script>
7373
```
7474

75-
When a parent listens for the `click` event on the component:
75+
親がコンポーネントの `click` イベントを購読する場合:
7676

7777
```html
7878
<my-button v-on:click="handleClick"></my-button>
7979
```
8080

81-
it would now be triggered _twice_:
81+
これは**2 回**トリガーされます:
8282

83-
- Once from `$emit()`.
84-
- Once from a native event listener applied to the root element.
83+
- `$emit()` から 1 回。
84+
- ルート要素に適用されるネイティブイベントリスナーから 1 回。
8585

86-
Here you have two options:
86+
ここで、2 つの選択肢があります:
8787

88-
1. Properly declare the `click` event. This is useful if you actually do add some logic to that event handler in `<my-button>`.
89-
2. Remove the re-emitting of the event, since the parent can now listen for the native event easily, without adding `.native`. Suitable when you really only re-emit the event anyway.
88+
1. `click` イベントを適切に宣言する。これは実際に `<my-button>` のイベントハンドラーに何らかのロジックを追加する場合に便利です。
89+
2. イベントの再発行を削除する。`.native` を追加しなくても、親は簡単にネイティブイベントを購読できるようになりました。とにかくイベントを再発行するだけの場合に適しています。
9090

91-
## See also
91+
## 参照
9292

93-
- [Relevant RFC](https://github.com/vuejs/rfcs/blob/master/active-rfcs/0030-emits-option.md)
94-
- [Migration guide - `.native` modifier removed](./v-on-native-modifier-removed.md)
95-
- [Migration guide - `$listeners` removed](./listeners-removed.md)
96-
- [Migration guide - `$attrs` includes `class` & `style`](./attrs-includes-class-style.md)
97-
- [Migration guide - Changes in the Render Functions API](./render-function-api.md)
93+
- [関連 RFC](https://github.com/vuejs/rfcs/blob/master/active-rfcs/0030-emits-option.md)
94+
- [移行ガイド - `.native` 修飾子の削除](./v-on-native-modifier-removed.md)
95+
- [移行ガイド - `$listeners` の削除](./listeners-removed.md)
96+
- [移行ガイド - `$attrs` `class` `style` を含有](./attrs-includes-class-style.md)
97+
- [移行ガイド - レンダー関数 API の変更点](./render-function-api.md)

src/ja/breaking-changes/functional-components.md

Lines changed: 36 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -3,36 +3,36 @@ badges:
33
- breaking
44
---
55

6-
# Functional Components <MigrationBadges :badges="$frontmatter.badges" />
6+
# 関数型コンポーネント <MigrationBadges :badges="$frontmatter.badges" />
77

8-
## Overview
8+
## 概要
99

10-
In terms of what has changed, at a high level:
10+
変更点の概要は次のとおりです:
1111

12-
- Performance gains from 2.x for functional components are now negligible in 3.x, so we recommend just using stateful components
13-
- Functional components can only be created using a plain function that receives `props` and `context` (i.e., `slots`, `attrs`, `emit`)
14-
- **BREAKING:** `functional` attribute on single-file component (SFC) `<template>` is removed
15-
- **BREAKING:** `{ functional: true }` option in components created by functions is removed
12+
- 関数型コンポーネントは 2.x からパフォーマンス向上し、3.x では無視できる程度になってので、ステートフルコンポーネントのみ使用することを推奨します
13+
- 関数型コンポーネントは、`props` `context`(つまり `slot`, `attrs`, `emit`)を受け取るプレーンな関数だけで作成できます
14+
- **破壊的変更:** 単一ファイルコンポーネント(SFC)における `<template>` `functional` 属性は削除されました
15+
- **破壊的変更:** 関数によって作成されたコンポーネントの `{ Functional: true }` オプションは削除されました
1616

17-
For more information, read on!
17+
詳細については続きをお読みください!
1818

19-
## Introduction
19+
## はじめに
2020

21-
In Vue 2, functional components had two primary use cases:
21+
Vue 2 では、関数型コンポーネントには 2 つの主なユースケースがありました:
2222

23-
- as a performance optimization, because they initialized much faster than stateful components
24-
- to return multiple root nodes
23+
- ステートフルコンポーネントよりもはるかに高速に初期化されるので、パフォーマンスの最適化として
24+
- 複数のルートノードを返すため
2525

26-
However, in Vue 3, the performance of stateful components has improved to the point that the difference is negligible. In addition, stateful components now also include the ability to return multiple root nodes.
26+
しかし Vue 3 では、ステートフルコンポーネントのパフォーマンスは、その差が無視できるほどに向上しています。さらに、ステートフルなコンポーネントには、複数のルートノードを返す機能も追加されました。
2727

28-
As a result, the only remaining use case for functional components is simple components, such as a component to create a dynamic heading. Otherwise, it is recommended to use stateful components as you normally would.
28+
その結果、関数型コンポーネントに残った唯一のユースケースは、動的な見出しを作成するコンポーネントのような単純なコンポーネントだけです。それ以外の場合は、通常通りステートフルコンポーネントを使用することをおすすめします。
2929

30-
## 2.x Syntax
30+
## 2.x の構文
3131

32-
Using the `<dynamic-heading>` component, which is responsible for rendering out the appropriate heading (i.e., `h1`, `h2`, `h3`, etc.), this could have been written as a single-file component in 2.x as:
32+
適切な見出し(`h1`, `h2`, `h3` など)をレンダリングする `<dynamic-heading>` コンポーネントを例にすると、2.x では単一ファイルコンポーネントとして以下のように記述できました:
3333

3434
```js
35-
// Vue 2 Functional Component Example
35+
// Vue 2 の関数型コンポーネントの例
3636
export default {
3737
functional: true,
3838
props: ['level'],
@@ -42,10 +42,10 @@ export default {
4242
}
4343
```
4444

45-
Or, for those who preferred the `<template>` in a single-file component:
45+
あるいは、単一ファイルコンポーネントの `<template>` を好む場合は:
4646

4747
```vue
48-
<!-- Vue 2 Functional Component Example with <template> -->
48+
<!-- Vue 2 <template> を使った関数型コンポーネントの例 -->
4949
<template functional>
5050
<component
5151
:is="`h${props.level}`"
@@ -61,17 +61,17 @@ export default {
6161
</script>
6262
```
6363

64-
## 3.x Syntax
64+
## 3.x の構文
6565

66-
### Components Created by Functions
66+
### 関数で作られるコンポーネント
6767

68-
Now in Vue 3, all functional components are created with a plain function. In other words, there is no need to define the `{ functional: true }` component option.
68+
Vue 3 では、すべての関数型コンポーネントはプレーンな関数で作成されるようになりました。つまり、`{ functional: true }` というコンポーネントオプションを定義する必要はありません。
6969

70-
They will receive two arguments: `props` and `context`. The `context` argument is an object that contains a component's `attrs`, `slots`, and `emit` properties.
70+
これらは 2 つの引数(`props` `context`)を受け取ります。`context` 引数は、コンポーネントの `attrs`, `slots`, `emit` プロパティを含むオブジェクトです。
7171

72-
In addition, rather than implicitly provide `h` in a `render` function, `h` is now imported globally.
72+
また、`render` 関数内で暗黙的に `h` を提供するのではなく、`h` はグローバルにインポートされるようになりました。
7373

74-
Using the previously mentioned example of a `<dynamic-heading>` component, here is how it looks now.
74+
前述の `<dynamic-heading>` コンポーネントの例を使用すると、以下のようになります。
7575

7676
```js
7777
import { h } from 'vue'
@@ -85,11 +85,11 @@ DynamicHeading.props = ['level']
8585
export default DynamicHeading
8686
```
8787

88-
### Single File Components (SFCs) {#single-file-components-sfcs}
88+
### 単一ファイルコンポーネント (SFC) {#single-file-components-sfcs}
8989

90-
In 3.x, the performance difference between stateful and functional components has been drastically reduced and will be insignificant in most use cases. As a result, the migration path for developers using `functional` on SFCs is to remove the attribute and rename all references of `props` to `$props` and `attrs` to `$attrs`.
90+
3.x では、ステートフルコンポーネントと関数型コンポーネントの性能差は大幅に減少し、ほとんどのユースケースで重要ではなくなります。その結果、SFC で `functional` を使用している開発者は、この属性を削除し、`props` の参照をすべて `$props` に、`attrs``$attrs` にリネームすることが移行手順となります。
9191

92-
Using our `<dynamic-heading>` example from before, here is how it would look now.
92+
先ほどの `<dynamic-heading>` の例を使うと、次のようになります。
9393

9494
```vue{1,3,4}
9595
<template>
@@ -106,15 +106,15 @@ export default {
106106
</script>
107107
```
108108

109-
The main differences are that:
109+
主な違いは以下の通りです:
110110

111-
1. `functional` attribute removed on `<template>`
112-
1. `listeners` are now passed as part of `$attrs` and can be removed
111+
1. `<template>``functional` 属性を削除
112+
1. `listeners` `$attrs` の一部として渡されるようになったので、削除できます
113113

114-
## Next Steps
114+
## 次のステップ
115115

116-
For more information on the usage of the new functional components and the changes to render functions in general, see:
116+
新しい関数型コンポーネントの使用方法やレンダー関数全般の変更点に関する詳細は、こちらをご覧ください:
117117

118-
- [Migration: Render Functions](./render-function-api.html)
119-
- [Guide: Render Functions](https://ja.vuejs.org/guide/extras/render-function.html#render-functions-jsx)
120-
- [Migration build flag: `COMPONENT_FUNCTIONAL`](../migration-build.html#compat-configuration)
118+
- [移行ガイド: レンダー関数](./render-function-api.html)
119+
- [ガイド: レンダー関数](https://ja.vuejs.org/guide/extras/render-function.html#render-functions-jsx)
120+
- [移行ビルドのフラグ: `COMPONENT_FUNCTIONAL`](../migration-build.html#compat-configuration)

0 commit comments

Comments
 (0)