Skip to content

Commit eb72d4f

Browse files
HomMarkHuntkazupon
andauthored
docs: Components In-Depth > Component Registration の翻訳 (#75)
* translate component registration. * fix translate and typo. Co-authored-by: kazuya kawaguchi <[email protected]> * Update src/guide/component-registration.md Co-authored-by: kazuya kawaguchi <[email protected]> Co-authored-by: kazuya kawaguchi <[email protected]>
1 parent 15dfa70 commit eb72d4f

File tree

1 file changed

+36
-36
lines changed

1 file changed

+36
-36
lines changed

src/guide/component-registration.md

Lines changed: 36 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
# Component Registration
1+
# コンポーネントの登録
22

3-
> This page assumes you've already read the [Components Basics](component-basics.md). Read that first if you are new to components.
3+
> このページは [コンポーネントの基本](component-basics.md) を読み終えている事を想定しています。もし読み終えていなければ先にそちらをお読みください。
44
5-
## Component Names
5+
## コンポーネント名
66

7-
When registering a component, it will always be given a name. For example, in the global registration we've seen so far:
7+
コンポーネントを登録する際は、必ず名前をつけてください。例えば、グローバル登録の場合は以下のようになります:
88

99
```js
1010
const app = Vue.createApp({...})
@@ -14,52 +14,52 @@ app.component('my-component-name', {
1414
})
1515
```
1616

17-
The component's name is the first argument of `app.component`. In the example above, the component's name is "my-component-name".
17+
`app.component` の第一引数がコンポーネント名になります。 上記の例では、"my-component-name" がコンポーネント名です。
1818

19-
The name you give a component may depend on where you intend to use it. When using a component directly in the DOM (as opposed to in a string template or [single-file component](../guide/single-file-component.html), we strongly recommend following the [W3C rules](https://html.spec.whatwg.org/multipage/custom-elements.html#valid-custom-element-name) for custom tag names:
19+
コンポーネントに付ける名前は使用箇所によって異なります。DOM を直接操作する場合 (文字列テンプレートや [単一ファイルコンポーネント](../guide/single-file-component.html)を除く) は、[W3C rules](https://html.spec.whatwg.org/multipage/custom-elements.html#valid-custom-element-name) に従ったカスタムタグ名を強く推奨します:
2020

21-
1. All lowercase
22-
2. Contains a hyphen (i.e., has multiple words connected with the hyphen symbol)
21+
1. 全て小文字
22+
2. ハイフンを含める (複数の単語をハイフンを用いて繋げる)
2323

24-
By doing so, this will help you avoid conflicts with current and future HTML elements.
24+
こうする事で、既に存在するそして将来的に定義される HTML 要素とのコンフリクトを回避する助けになります。
2525

26-
You can see other recommendations for component names in the [Style Guide](../style-guide/#base-component-names-strongly-recommended).
26+
その他のコンポーネント名の推奨項目は [スタイルガイド](../style-guide/#base-component-names-strongly-recommended) で確認することができます。
2727

28-
### Name Casing
28+
### 命名のケース (Name Casing)
2929

30-
When defining components in a string template or a single-file component, you have two options when defining component names:
30+
コンポーネントを文字列テンプレートか単一ファイルコンポーネントで定義する際は、コンポーネント名に二つの命名規則があります:
3131

32-
#### With kebab-case
32+
#### ケバブケース
3333

3434
```js
3535
app.component('my-component-name', {
3636
/* ... */
3737
})
3838
```
3939

40-
When defining a component with kebab-case, you must also use kebab-case when referencing its custom element, such as in `<my-component-name>`.
40+
コンポーネントをケバブケースで定義する場合は、そのカスタム要素を参照する際も `<my-component-name>` のようにケバブケースを用いなければなりません。
4141

42-
#### With PascalCase
42+
#### パスカルケース
4343

4444
```js
4545
app.component('MyComponentName', {
4646
/* ... */
4747
})
4848
```
4949

50-
When defining a component with PascalCase, you can use either case when referencing its custom element. That means both `<my-component-name>` and `<MyComponentName>` are acceptable. Note, however, that only kebab-case names are valid directly in the DOM (i.e. non-string templates).
50+
コンポーネントをパスカルケースで定義する場合は、そのカスタム要素を参照する際どちらのケースも用いることができます。`<my-component-name>` `<MyComponentName>` のどちらも利用可能です。 ですが、DOM 内で直接使用する場合 (つまり、文字列テンプレート以外の場合) はケバブケースの方が適している点に注意してください。
5151

52-
## Global Registration
52+
## グローバル登録
5353

54-
So far, we've only created components using `app.component`:
54+
ここまでは `app.component` だけを使ってコンポーネントを作成しました:
5555

5656
```js
5757
Vue.createApp({...}).component('my-component-name', {
5858
// ... options ...
5959
})
6060
```
6161

62-
These components are **globally registered** for the application. That means they can be used in the template of any component instance within this application:
62+
これらのコンポーネントはアプリケーションへの **グローバル登録** とされています。つまり、あらゆるコンポーネントインスタンスのテンプレート内で使用できます:
6363

6464
```js
6565
const app = Vue.createApp({})
@@ -85,13 +85,13 @@ app.mount('#app')
8585
</div>
8686
```
8787

88-
This even applies to all subcomponents, meaning all three of these components will also be available _inside each other_.
88+
これはすべてのサブコンポーネントにも当てはまります、つまりこれらの3つのコンポーネントすべてが _相互に使用_ することができます。
8989

90-
## Local Registration
90+
## ローカル登録
9191

92-
Global registration often isn't ideal. For example, if you're using a build system like Webpack, globally registering all components means that even if you stop using a component, it could still be included in your final build. This unnecessarily increases the amount of JavaScript your users have to download.
92+
グローバル登録はしばしば理想的ではありません。例えば、Webpack のようなビルドシステムを利用した場合、全てのコンポーネントをグローバル登録すると、使用していないコンポーネントも最終ビルドに含まれてしまいます。これはユーザーがダウンロードしなければならない JavaScript の量を不必要に増やしてしまう事になります。
9393

94-
In these cases, you can define your components as plain JavaScript objects:
94+
以下のケースでは、プレーン JavaScript としてコンポーネントを定義することができます:
9595

9696
```js
9797
const ComponentA = {
@@ -105,7 +105,7 @@ const ComponentC = {
105105
}
106106
```
107107

108-
Then define the components you'd like to use in a `components` option:
108+
次に `components` オプション内に使用したいコンポーネントを定義します:
109109

110110
```js
111111
const app = Vue.createApp({
@@ -116,9 +116,9 @@ const app = Vue.createApp({
116116
})
117117
```
118118

119-
For each property in the `components` object, the key will be the name of the custom element, while the value will contain the options object for the component.
119+
`components` オブジェクト内のそれぞれのプロパティは、キーがカスタム要素の名前になり、値はコンポーネントのオプションオブジェクトが含まれます。
120120

121-
Note that **locally registered components are _not_ also available in subcomponents**. For example, if you wanted `ComponentA` to be available in `ComponentB`, you'd have to use:
121+
**ローカル登録されたコンポーネントはサブコンポーネントでは利用 _できない_** という点に注意してください。例えば、`ComponentA` `ComponentB` 内で使用可能にしたいときは、以下のように使用する必要があります:
122122

123123
```js
124124
const ComponentA = {
@@ -133,7 +133,7 @@ const ComponentB = {
133133
}
134134
```
135135

136-
Or if you're using ES2015 modules, such as through Babel and Webpack, that might look more like:
136+
または、Babel Webpack のようなものを用いて ES2015 モジュールを利用している場合は、このようになります:
137137

138138
```js
139139
import ComponentA from './ComponentA.vue'
@@ -146,20 +146,20 @@ export default {
146146
}
147147
```
148148

149-
Note that in ES2015+, placing a variable name like `ComponentA` inside an object is shorthand for `ComponentA: ComponentA`, meaning the name of the variable is both:
149+
ES2015 以降の場合、`ComponentA` のような変数名をオブジェクト内に配置することは `ComponentA: ComponentA` の省略記法にあたり、変数の名前は次のどちらも意味することに注意して下さい:
150150

151-
- the custom element name to use in the template, and
152-
- the name of the variable containing the component options
151+
- テンプレート内で使用されるカスタム要素名
152+
- コンポーネントオプションを含む変数の名前
153153

154-
## Module Systems
154+
## モジュールシステム
155155

156-
If you're not using a module system with `import`/`require`, you can probably skip this section for now. If you are, we have some special instructions and tips just for you.
156+
もし `import`/`require` を使用したモジュールシステムを使わないのであれば, このセクションはスキップすることができます。そうでなければ、いくつかのインストラクションとコツを教えます。
157157

158-
### Local Registration in a Module System
158+
### モジュールシステム内のローカル登録
159159

160-
If you're still here, then it's likely you're using a module system, such as with Babel and Webpack. In these cases, we recommend creating a `components` directory, with each component in its own file.
160+
もしまだこの記事を読んでいるということは、Webpack や Babel のようなモジュールシステムを利用している可能性が高いでしょう。このような場合は、それぞれのコンポーネントを独自のファイルに持つ `components` ディレクトリを作成することをお勧めします。
161161

162-
Then you'll need to import each component you'd like to use, before you locally register it. For example, in a hypothetical `ComponentB.js` or `ComponentB.vue` file:
162+
次にローカル登録をする前に、使用するコンポーネントごとにインポートする必要があります。例えば、`ComponentB.js` もしくは `ComponentB.vue` ファイルの場合:
163163

164164
```js
165165
import ComponentA from './ComponentA'
@@ -174,4 +174,4 @@ export default {
174174
}
175175
```
176176

177-
Now both `ComponentA` and `ComponentC` can be used inside `ComponentB`'s template.
177+
これで `ComponentA` `ComponentC` `ComponentB` のテンプレート内で利用できるようになりました。

0 commit comments

Comments
 (0)