Skip to content

Translate v2 docs in Japanese. #428

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 83 commits into from
Dec 5, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
83 commits
Select commit Hold shift + click to select a range
c29078a
Starting japanese translation.
kitak Oct 29, 2016
0a1d6b6
Move intro.md from v1.0
kitak Oct 29, 2016
f6436b9
Installation.md in Japanese
tadyjp Oct 31, 2016
f311ca0
translate headers
tadyjp Oct 31, 2016
084e85e
Copy docs/en/getting-started.md from 1.0
inouetakuya Nov 11, 2016
917f4ce
Copy docs/en/getting-started.md from 2.0, understanding diff 1.0 and 2.0
inouetakuya Nov 11, 2016
0be72fa
Copy docs/ja/getting-started.md from 1.0
inouetakuya Nov 11, 2016
f371744
Translated the part of getting-started.md which has no diff 1.0 and 2.0
inouetakuya Nov 11, 2016
5322189
Translate getting-started.md
inouetakuya Nov 11, 2016
98d2902
Make getting-started.md more readable
inouetakuya Nov 11, 2016
d93f15b
Tiny change
inouetakuya Nov 11, 2016
aa9d6dc
Translate intro
kitak Nov 20, 2016
ed57506
translate intro
kitak Oct 29, 2016
ab7a095
Copy docs/en/getters.md to ja
inouetakuya Nov 22, 2016
373e5ad
Translate getters.md
inouetakuya Nov 22, 2016
f756709
Translate mapGetters helper
inouetakuya Nov 22, 2016
ccdccb7
Copy docs/en/mutations.md from 1.0
inouetakuya Nov 22, 2016
5f91077
Copy docs/en/mutations.md from 2.0, understanding diff 1.0 and 2.0
inouetakuya Nov 22, 2016
aff1ab5
Copy docs/ja/mutations.md from 1.0
inouetakuya Nov 22, 2016
52f02b6
Translate mutations.md
inouetakuya Nov 22, 2016
bde44a0
Delete unnecessary rows
inouetakuya Nov 23, 2016
9387983
Copy actions.md from 1.0
inouetakuya Nov 23, 2016
84e162b
Copy actions.md from 2.0, understanding diff 1.0 and 2.0
inouetakuya Nov 23, 2016
fc4fc68
Copy docs/ja/actions.md from 1.0
inouetakuya Nov 23, 2016
4b220d0
Translate state
kitak Nov 23, 2016
d381f87
Translate dispatching actions
inouetakuya Nov 23, 2016
d245499
Translate actions.md
inouetakuya Nov 23, 2016
43a6b6e
Merge branch 'translate-ja' of github.com:kitak/vuex into translate-ja
inouetakuya Nov 23, 2016
575fe13
Copy docs/en/modules.md to docs/ja/modules.md
inouetakuya Nov 23, 2016
cea0371
Translate modules.md
inouetakuya Nov 23, 2016
e0927c1
Translate title of docs/ja/modules.md
inouetakuya Nov 23, 2016
b855aa8
Copy docs/en/structure.md of 1.0 to docs/ja/structure.md
inouetakuya Nov 23, 2016
4bd7b11
Copy docs/en/structure.md of 2.0, understanding diff 1.0 and 2.0
inouetakuya Nov 23, 2016
446d71b
Copy version 1.0 of docs/ja/structure.md
inouetakuya Nov 23, 2016
073e7fb
Translate structure.md
inouetakuya Nov 23, 2016
37bdc43
Copy docs/en/testing.md of 1.0 to docs/ja/testing.md
inouetakuya Nov 23, 2016
153225d
Copy docs/en/testing.md of 2.0, understanding diff 1.0 and 2.0
inouetakuya Nov 23, 2016
f6376ea
Copy version 1.0 of docs/ja/testing.md
inouetakuya Nov 23, 2016
1a47bb7
Translate testing mutations
inouetakuya Nov 23, 2016
6924e0a
Translate testing actions
inouetakuya Nov 23, 2016
fd0eaa4
Translate docs/ja/testing.md
inouetakuya Nov 23, 2016
7f7dd64
Copy docs/en/strict.md 1.0 to docs/ja/strict.md
inouetakuya Nov 23, 2016
b53765b
Copy version 1.0 of docs/ja/strict.md
inouetakuya Nov 23, 2016
64286b7
Translate strict.md
inouetakuya Nov 23, 2016
f0fce02
Add hot-reload
kitak Nov 25, 2016
f9ababe
Translate plugins
kitak Nov 25, 2016
dce2205
Translate forms
kitak Nov 26, 2016
8315d4e
Translate SUMMARY
kitak Nov 27, 2016
5a8a51c
Improve intro
kitak Nov 27, 2016
d1f3d60
Improve
kitak Nov 27, 2016
5074893
Improve translation of resolve
inouetakuya Nov 28, 2016
4f50e78
Improve translation of actions.md
inouetakuya Nov 28, 2016
4f735fd
Fix translation of docs/ja/getters.md
inouetakuya Nov 28, 2016
c0b9eb4
Cut off the broken link
inouetakuya Nov 28, 2016
652ef82
Fix typo
inouetakuya Nov 28, 2016
d43c6d2
Improve translation
inouetakuya Nov 28, 2016
23442b8
Improve
kitak Nov 28, 2016
f0e08f6
Improve intro translation
kitak Nov 28, 2016
18cd3b5
Improve translation
kitak Nov 28, 2016
c40ccc7
Improve
kitak Nov 28, 2016
f494098
Improve
kitak Nov 28, 2016
badae50
Link to old japanese document
kitak Nov 28, 2016
0482067
Reflect review by @ktsn
inouetakuya Nov 29, 2016
1b299c0
Reflect #470
inouetakuya Nov 29, 2016
b794c32
Reflect #438
inouetakuya Nov 29, 2016
bef0264
Reflect change of actions.md in #421
inouetakuya Nov 29, 2016
c0b7cbb
Translate docs/ja/api.md
kimikimi714 Nov 29, 2016
657185e
Merge branch 'translate-ja' of ssh://github.com/kitak/vuex into trans…
kimikimi714 Nov 29, 2016
5b9a8e4
Replace プロミス with Promise
kimikimi714 Nov 30, 2016
9c94f93
Improve translation of 'expose'
kimikimi714 Nov 30, 2016
cafbb47
Improve translation of 'component methods options'
kimikimi714 Nov 30, 2016
e755323
Fix indent
kimikimi714 Nov 30, 2016
808c3ba
Improve translation
kimikimi714 Nov 30, 2016
9c2fcba
Replace Vue store with ストア
kimikimi714 Dec 1, 2016
ac3dede
Improve transration
kimikimi714 Dec 1, 2016
dbc71f9
Fix arguments of dispatch and watch
kimikimi714 Dec 1, 2016
acf740d
Improve translation
kimikimi714 Dec 1, 2016
b981ffc
Fix indent
kimikimi714 Dec 1, 2016
a615dd6
Improve translation
kimikimi714 Dec 1, 2016
64e72c4
Improve translation
kimikimi714 Dec 1, 2016
07b5df3
Improve translation
kimikimi714 Dec 3, 2016
5634911
Merge branch 'dev' into translate-ja
kitak Dec 5, 2016
cfba71e
Add README.md and book.json
kitak Dec 5, 2016
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/LANGS.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@
* [2.0 - 简体中文](zh-cn/)
* [2.0 - Français](fr/)
* [2.0 - Русский](ru/)
* [2.0 - 日本語](ja/)
* [1.0 Docs](old/)
1 change: 0 additions & 1 deletion docs/en/getters.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

# Getters

Sometimes we may need to compute derived state based on store state, for example filtering through a list of items and counting them:
Expand Down
1 change: 1 addition & 0 deletions docs/ja/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{% include "./SUMMARY.md" %}
22 changes: 22 additions & 0 deletions docs/ja/SUMMARY.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Vuex

> 注意: これは vuex@2.x のドキュメントです

- [1.0のドキュメントをお探しですか?](https://github.com/vuejs/vuex/tree/1.0/docs/ja)
- [リリースノート](https://github.com/vuejs/vuex/releases)
- [インストール](installation.md)
- [Vuex とは何か?](intro.md)
- [Vuex 入門](getting-started.md)
- コアコンセプト
- [ステート](state.md)
- [ゲッター](getters.md)
- [ミューテーション](mutations.md)
- [アクション](actions.md)
- [モジュール](modules.md)
- [アプリケーションの構造](structure.md)
- [プラグイン](plugins.md)
- [厳格モード](strict.md)
- [フォームの扱い](forms.md)
- [テスト](testing.md)
- [ホットリローディング](hot-reload.md)
- [API リファレンス](api.md)
174 changes: 174 additions & 0 deletions docs/ja/actions.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,174 @@
# アクション

アクションはミューテーションと似ていますが、下記の点で異なります:

- アクションは、状態を変更するのではなく、ミューテーションをコミットします。
- アクションは任意の非同期処理を含むことができます。

シンプルなアクションを登録してみましょう:

``` js
const store = new Vuex.Store({
state: {
count: 0
},
mutations: {
increment (state) {
state.count++
}
},
actions: {
increment (context) {
context.commit('increment')
}
}
})
```

アクションハンドラはストアインスタンスのメソッドやプロパティのセットと同じものを呼び出せるコンテキストオブジェクトを受け取ります。したがって `context.commit` を呼び出すことでミューテーションをコミットできます。あるいは `context.state` や `context.getters` で、状態やゲッターにアクセスできます。なぜコンテキストオブジェクトがストアインスタンスそのものではないのかは、後ほど[モジュール](modules.md)で説明します。

実際にはコードを少しシンプルにするために ES2015 の[引数分割束縛(argument destructuring)](https://github.com/lukehoban/es6features#destructuring)がよく使われます(特に `commit` を複数回呼び出す必要があるとき):

``` js
actions: {
increment ({ commit }) {
commit('increment')
}
}
```

### アクションのディスパッチ

アクションは `store.dispatch` がトリガーとなって実行されます:

``` js
store.dispatch('increment')
```

これは一見ばかげて見えるかもしれません。つまり、カウントをインクリメントしたいときに、どうして直接 `store.commit('increment')` を呼び出してミューテーションをコミットしないのか、と。**ミューテーションは同期的でなければならない**というのを覚えていますか?アクションはそうではありません。アクションの中では**非同期**の操作を行うことができます。

``` js
actions: {
incrementAsync ({ commit }) {
setTimeout(() => {
commit('increment')
}, 1000)
}
}
```

アクションはペイロード形式とオブジェクトスタイルのディスパッチをサポートします:

``` js
// ペイロードを使ってディスパッチする
store.dispatch('incrementAsync', {
amount: 10
})

// オブジェクトを使ってディスパッチする
store.dispatch({
type: 'incrementAsync',
amount: 10
})
```

より実践的な例として、ショッピングカートをチェックアウトするアクションを挙げます。このアクションは**非同期な API の呼び出し**と、**複数のミューテーションのコミット**をします:

``` js
actions: {
checkout ({ commit, state }, products) {
// 現在のカート内の商品を保存する
const savedCartItems = [...state.cart.added]
// チェックアウトのリクエストを送信し、楽観的にカート内をクリアする
commit(types.CHECKOUT_REQUEST)
// shop API は成功時のコールバックと失敗時のコールバックを受け取る
shop.buyProducts(
products,
// 成功時の処理
() => commit(types.CHECKOUT_SUCCESS),
// 失敗時の処理
() => commit(types.CHECKOUT_FAILURE, savedCartItems)
)
}
}
```

一連の非同期の処理を実行しつつ、ミューテーションのコミットによってのみ副作用(状態の変更)を与えていることに注意してください。

### コンポーネント内でのアクションのディスパッチ

`this.$store.dispatch('xxx')` でコンポーネント内でアクションをディスパッチできます。あるいはコンポーネントのメソッドを `store.dispatch` にマッピングする `mapActions` ヘルパーを使うこともできます(ルートの `store` の注入が必要です):

``` js
import { mapActions } from 'vuex'

export default {
// ...
methods: {
...mapActions([
'increment' // this.increment() を this.$store.dispatch('increment') にマッピングする
]),
...mapActions({
add: 'increment' // this.add() を this.$store.dispatch('increment') にマッピングする
})
}
}
```

### アクションを構成する

アクションはしばしば非同期処理を行いますが、アクションが完了したことをどうやって知れば良いのでしょう?そしてもっと重要なことは、さらに複雑な非同期処理を取り扱うために、どうやって複数のアクションを構成させるかということです。

まず知っておくべきことは `store.dispatch` がトリガーされたアクションハンドラによって返された Promise を処理できることと、`store.dispatch` もまた Promise を返すことです。

``` js
actions: {
actionA ({ commit }) {
return new Promise((resolve, reject) => {
setTimeout(() => {
commit('someMutation')
resolve()
}, 1000)
})
}
}
```

すると次のようにできます:

``` js
store.dispatch('actionA').then(() => {
// ...
})
```

また別のアクションで下記のように書くと:

``` js
actions: {
// ...
actionB ({ dispatch, commit }) {
return dispatch('actionA').then(() => {
commit('someOtherMutation')
})
}
}
```

最終的に JavaScript の機能として近く導入される [async / await](https://tc39.github.io/ecmascript-asyncawait/) を使用することで、次のようにアクションを組み合わせることができます:

``` js
// getData() と getOtherData() が Promise を返すことを想定している

actions: {
async actionA ({ commit }) {
commit('gotData', await getData())
},
async actionB ({ dispatch, commit }) {
await dispatch('actionA') // actionA が完了するのを待機する
commit('gotOtherData', await getOtherData())
}
}
```

> `store.dispatch` で異なるモジュール内の複数のアクションハンドラをトリガーすることができます。そのようなケースでは、全てのトリガーされたハンドラが解決されたときに解決する Promise が戻り値として返ってくることになります。
179 changes: 179 additions & 0 deletions docs/ja/api.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,179 @@
# API リファレンス

### Vuex.Store

``` js
import Vuex from 'vuex'

const store = new Vuex.Store({ ...options })
```

### Vuex.Store コンストラクタオプション

- **state**

- 型: `Object`

ストアのための ルートステートオブジェクトです。

[詳細](state.md)

- **mutations**

- 型: `{ [type: string]: Function }`

ストアにミューテーションを登録します。ハンドラ関数は第一引数に `state` を常に受け取り(モジュール内で定義されていれば、モジュールのローカルステートを受け取り)、指定されていれば第二引数に `payload` を受け取ります。

[詳細](mutations.md)

- **actions**

- 型: `{ [type: string]: Function }`

ストアにアクションを登録します。ハンドラ関数は次のプロパティを持つ `context` オブジェクトを受け取ります。:

``` js
{
state, // store.state と同じか、モジュール内にあればローカルステート
rootState, // store.state と同じ。ただしモジュール内に限る
commit, // store.commit と同じ
dispatch, // store.dispatch と同じ
getters // store.getters と同じ
}
```

[詳細](actions.md)

- **getters**

- type: `{ [key: string]: Function }`

ストアにゲッターを登録します. ゲッター関数は次の引数を受け取ります:

```
state, // モジュール内で定義されていればモジュールのローカルステート
getters, // store.getters と同じ
rootState // store.state と同じ
```

登録されたゲッターは `store.getters` 上に公開されます。

[詳細](getters.md)

- **modules**

- 型: `Object`

サブモジュールを含む次のような形式のオブジェクトはストアにマージされます。

``` js
{
key: {
state,
mutations
actions?,
getters?,
modules?

},
...
}
```

各モジュールは、ルートオプションに似た `state` と `mutations` を含むことができます。モジュールの状態は、モジュールのキーを使って、ストアのルートステートに結合されます。モジュールのミューテーションとゲッターは、第一引数としてルートステートの代わりに、モジュールのローカルステートだけを受け取り、モジュールのアクションの `context.state` もローカルステートを指すようになります。

[詳細](modules.md)

- **plugins**

- 型: `Array<Function>`

プラグイン関数の配列は、ストアに適用されます。このプラグインは、ストアだけを引数として受け取り、外部への永続化、ロギング、デバッギングのために、ミューテーションを監視するか、または、 websocket や observable のような外から渡されるデータのためにミューテーションをディスパッチします。

[詳細](plugins.md)

- **strict**

- 型: `Boolean`
- デフォルト: `false`

Vuex ストアを厳格モードにします。厳格モードでは、ミューテーションハンドラ以外で、 Vuex の状態の変更を行うと、エラーが投げられます。

[詳細](strict.md)

### Vuex.Store インスタンスプロパティ

- **state**

- type: `Object`

ルートステート、読み取り専用です。

- **getters**

- type: `Object`

登録されているゲッターを公開します。読み取り専用です。

### Vuex.Store インスタンスメソッド

- **`commit(type: string, payload?: any) | commit(mutation: Object)`**

ミューテーションをコミットします。[詳細](mutations.md)

- **`dispatch(type: string, payload?: any) | dispatch(action: Object)`**

アクションをディスパッチします。すべてのトリガーされたアクションハンドラを解決するPromiseを返します。[詳細](actions.md)

- **`replaceState(state: Object)`**

ストアのルートステートを置き換えます。これは、ステートのハイドレーションやタイムトラベルのためだけに利用すべきです。

- **`watch(getter: Function, cb: Function, options?: Object)`**

リアクティブにゲッター関数の返す値を監視します。値が変わった場合は、コールバックを呼びます。ゲッターはストアの状態のみを引数として受け取ります。 Vue の`vm.$watch`メソッドと同じオプションをオプションのオブジェクトとして受け付けます。

監視を止める場合は、ハンドラ関数の返り値を関数として呼び出します。

- **`subscribe(handler: Function)`**

ストアへのミューテーションを購読します。`handler` は、全てのミューテーションの後に呼ばれ、引数として、ミューテーション ディスクリプタとミューテーション後の状態を受け取ります。

``` js
store.subscribe((mutation, state) => {
console.log(mutation.type)
console.log(mutation.payload)
})
```

プラグインの中でもっともよく利用されます。[詳細](plugins.md)

- **`registerModule(path: string | Array<string>, module: Module)`**

動的なモジュールを登録します。[詳細](modules.md#dynamic-module-registration)

- **`unregisterModule(path: string | Array<string>)`**

動的なモジュールを解除します。[詳細](modules.md#dynamic-module-registration)

- **`hotUpdate(newOptions: Object)`**

新しいアクションとミューテーションをホットスワップします。[詳細](hot-reload.md)

### コンポーネントをバインドするヘルパー

- **`mapState(map: Array<string> | Object): Object`**

ストアのサブツリーを返すコンポーネントの computed オプションを作成します。[詳細](state.md#the-mapstate-helper)

- **`mapGetters(map: Array<string> | Object): Object`**

ゲッターの評価後の値を返すコンポーネントの computed オプションを作成します。[詳細](getters.md#the-mapgetters-helper)

- **`mapActions(map: Array<string> | Object): Object`**

アクションをディスパッチするコンポーネントの methods オプションを作成します。[詳細](actions.md#dispatching-actions-in-components)

- **`mapMutations(map: Array<string> | Object): Object`**

ミューテーションをコミットするコンポーネントの methods オプションを作成します。[詳細](mutations.md#commiting-mutations-in-components)
Loading