Skip to content

Commit c7e7f2e

Browse files
takumiz19kazupon
andauthored
docs: Tooling > Single File Components の翻訳 (#88)
* single-file-component.mdの日本語訳 * 修正漏れの対応 * 余分な文字、スペースの削除 * Update src/guide/single-file-component.md 翻訳トーンの調整による修正 Co-authored-by: kazuya kawaguchi <kawakazu80@gmail.com> Co-authored-by: kazuya kawaguchi <kawakazu80@gmail.com>
1 parent 2775e20 commit c7e7f2e

File tree

1 file changed

+31
-30
lines changed

1 file changed

+31
-30
lines changed

src/guide/single-file-component.md

Lines changed: 31 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,39 @@
1-
# Single File Components
1+
# 単一ファイルコンポーネント
22

3-
## Introduction
3+
## 前書き
44

5-
In many Vue projects, global components will be defined using `app.component()`, followed by `app.mount('#app')` to target a container element in the body of every page.
5+
多くの Vue プロジェクトでは、 グローバルコンポーネントは `app.mount('#app')` の後に各ページの body においてコンテナ要素のターゲットすることに続いて、`app.component()` を使用して定義されています。
66

7-
This can work very well for small to medium-sized projects, where JavaScript is only used to enhance certain views. In more complex projects however, or when your frontend is entirely driven by JavaScript, these disadvantages become apparent:
7+
これはある view を拡張するためだけに JavaScript が利用された中小規模のプロジェクトにおいてはとても有効です。しかしながら、あなたのフロントエンドで JavaScript 全体を操作するようなもっと複雑なプロジェクトでは、これらの点において不利益になります。:
88

9-
- **Global definitions** force unique names for every component
10-
- **String templates** lack syntax highlighting and require ugly slashes for multiline HTML
11-
- **No CSS support** means that while HTML and JavaScript are modularized into components, CSS is conspicuously left out
12-
- **No build step** restricts us to HTML and ES5 JavaScript, rather than preprocessors like Pug (formerly Jade) and Babel
9+
- **グローバル宣言**は全てのコンポーネントに一意な名前を強制すること
10+
- シンタックスハイライトがない**文字列テンプレート**と複数行 HTML の時の醜いスラッシュが強要されること
11+
- **CSS サポート無し**だと HTML JavaScript がコンポーネントにモジュール化されている間、これ見よがしに無視されること
12+
- **ビルド処理がない**と Pug(前 Jade)と Babel のようなプリプロセッサよりむしろ、 HTML ES5 JavaScript を制限されること
1313

14-
All of these are solved by **single-file components** with a `.vue` extension, made possible with build tools such as Webpack or Browserify.
14+
これらは全ては Webpack や Browserify のビルドツールにより実現された `.vue`拡張子の**単一ファイルコンポーネント**によって解決されます。
1515

16-
Here's an example of a file we'll call `Hello.vue`:
16+
こちらが `Hello.vue` と呼ばれたファイルの例です:
1717

1818
<a href="https://codepen.io/team/Vue/pen/3de13b5cd0133df4ecf307b6cf2c5f94" target="_blank" rel="noopener noreferrer"><img src="/images/sfc.png" width="403" alt="Single-file component example (click for code as text)" style="display: block; margin: 15px auto; max-width: 100%"></a>
1919

20-
Now we get:
20+
さて次にこちらに入ります:
2121

22-
- [Complete syntax highlighting](https://github.com/vuejs/awesome-vue#source-code-editing)
23-
- [CommonJS modules](https://webpack.js.org/concepts/modules/#what-is-a-webpack-module)
24-
- [Component-scoped CSS](https://vue-loader.vuejs.org/en/features/scoped-css.html)
22+
- [完全版シンタックスハイライト](https://github.com/vuejs/awesome-vue#source-code-editing)
23+
- [CommonJS モジュール](https://webpack.js.org/concepts/modules/#what-is-a-webpack-module)
24+
- [コンポーネントスコープ CSS](https://vue-loader.vuejs.org/en/features/scoped-css.html)
2525

26-
As promised, we can also use preprocessors such as Pug, Babel (with ES2015 modules), and Stylus for cleaner and more feature-rich components.
26+
約束した通り、PugBabel (ES2015 モジュールと一緒に) や Stylus など 綺麗で機能が豊富なコンポーネントもプリプロセッサとして利用することができます。
2727

2828
<a href="https://codesandbox.io/s/vue-single-file-component-with-pre-processors-mr3ik?file=/src/App.vue" target="_blank" rel="noopener noreferrer"><img src="/images/sfc-with-preprocessors.png" width="563" alt="Single-file component with pre-processors example (click for code as text)" style="display: block; margin: 15px auto; max-width: 100%"></a>
2929

30-
These specific languages are only examples. You could as easily use TypeScript, SCSS, PostCSS, or whatever other preprocessors that help you be productive. If using Webpack with `vue-loader`, it also has first-class support for CSS Modules.
30+
これらの特定の言語は単なる一例です。TypeScriptSCSSPostCSS などの生産的なプリプロセッサも簡単に使うことができます。もし `vue-loader` で Webpack を使用しているならば、CSS Modules 向けに素晴らしいサポートがあります。
3131

32-
### What About Separation of Concerns?
32+
### 関心の分離について
3333

34-
One important thing to note is that **separation of concerns is not equal to separation of file types.** In modern UI development, we have found that instead of dividing the codebase into three huge layers that interweave with one another, it makes much more sense to divide them into loosely-coupled components and compose them. Inside a component, its template, logic and styles are inherently coupled, and collocating them actually makes the component more cohesive and maintainable.
34+
注意すべき重要な点の1つは、**関心の分離がファイルタイプの分離とは等しくないことです。** 現代の UI 開発では、私たちはコードベースを互いに織りなす3つの巨大なレイヤーに分割するのではなく、それらを疎結合なコンポーネントに分割して構成する方がはるかに理にかなっていることを発見しました。コンポーネントの内部では、そのテンプレート、ロジック、スタイルが本質的に結合しており、実際にそれらを配置することでコンポーネントの一貫性と保守性が高くなります。
3535

36-
Even if you don't like the idea of Single-File Components, you can still leverage its hot-reloading and pre-compilation features by separating your JavaScript and CSS into separate files:
36+
単一ファイルコンポーネントのアイディアが好きではなくても、JavaScript CSS を別々ファイルに分けることによってホットリロードとプリコンパイル機能を活用することができます:
3737

3838
``` html
3939
<!-- my-component.vue -->
@@ -44,24 +44,25 @@ Even if you don't like the idea of Single-File Components, you can still leverag
4444
<style src="./my-component.css"></style>
4545
```
4646

47-
## Getting Started
47+
## はじめる
4848

49-
### Example Sandbox
49+
### サンドボックスの例
5050

51-
If you want to dive right in and start playing with single-file components, check out [this simple todo app](https://codesandbox.io/s/vue-todo-list-app-with-single-file-component-vzkl3?file=/src/App.vue) on CodeSandbox.
51+
すぐに触ってそして単一ファイルコンポーネントを試したい方は、CodeSandBox 上の [この単純な todo アプリケーション](https://codesandbox.io/s/vue-todo-list-app-with-single-file-component-vzkl3?file=/src/App.vue)
52+
をチェックしてみてください。
5253

53-
### For Users New to Module Build Systems in JavaScript
54+
### JavaScript でモジュールビルドシステムが初めてなユーザ向け
5455

55-
With `.vue` components, we're entering the realm of advanced JavaScript applications. That means learning to use a few additional tools if you haven't already:
56+
`.vue` コンポーネントにより、高度な JavaScript アプリケーションの分野へ入っていきます。 これはあなたがまだ使ったことのない、いくつかの追加のツールの使い方を学ぶことを意味します:
5657

57-
- **Node Package Manager (NPM)**: Read the [Getting Started guide](https://docs.npmjs.com/packages-and-modules/getting-packages-from-the-registry) section about how to get packages from the registry.
58+
- **Node Package Manager (NPM)**: レジストリからパッケージを取得する方法については[Getting Started guide](https://docs.npmjs.com/packages-and-modules/getting-packages-from-the-registry) のセクションを読んでください。
5859

59-
- **Modern JavaScript with ES2015/16**: Read through Babel's [Learn ES2015 guide](https://babeljs.io/docs/en/learn). You don't have to memorize every feature right now, but keep this page as a reference you can come back to.
60+
- **ES2015/16 を使ったモダンな JavaScript**: Babel[Learn ES2015 guide](https://babeljs.io/docs/en/learn)を読んでみてください。今すぐには全ての機能を暗記する必要はないですが、参考として戻れるようにしておいてください。
6061

61-
After you've taken a day to dive into these resources, we recommend checking out [Vue CLI](https://cli.vuejs.org/). Follow the instructions and you should have a Vue project with `.vue` components, ES2015, webpack and hot-reloading in no time!
62+
これらのリソースに没頭した後は、[Vue CLI](https://cli.vuejs.org/)を確認することをお勧めします。 指示に従うことであっという間に `.vue` コンポーネントと ES2015、 Webpack、ホットリローティングを備えた Vue プロジェクトを手に入れられるはずです!
6263

63-
### For Advanced Users
64+
### 上級ユーザ向け
6465

65-
The CLI takes care of most of the tooling configurations for you, but also allows fine-grained customization through its own [config options](https://cli.vuejs.org/config/).
66+
CLI はツールの設定の大部分の面倒を見てくれますが、[設定オプション](https://cli.vuejs.org/config/)を通してよりきめ細かいカスタマイズをすることもできます。
6667

67-
In case you prefer setting up your own build setup from scratch, you will need to manually configure webpack with [vue-loader](https://vue-loader.vuejs.org). To learn more about webpack itself, check out [their official docs](https://webpack.js.org/configuration/) and [webpack learning academy](https://webpack.academy/p/the-core-concepts).
68+
あなたが独自のビルドセットアップをゼロから作ることを好む場合、webpack [vue-loader](https://vue-loader.vuejs.org)を手動で設定する必要があるでしょう。webpackについてもっと学びたいときは、[公式ドキュメント](https://webpack.js.org/configuration/)[webpack learning academy](https://webpack.academy/p/the-core-concepts)を参照してください。

0 commit comments

Comments
 (0)