Skip to content

Commit 32111da

Browse files
committed
translate pipeline/hooks.md
1 parent a94d9cb commit 32111da

File tree

1 file changed

+29
-30
lines changed

1 file changed

+29
-30
lines changed

โ€Ždocs/ja/pipeline/hooks.md

Lines changed: 29 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
# Transition Hooks
1+
# ใƒˆใƒฉใƒณใ‚ธใ‚ทใƒงใƒณใƒ•ใƒƒใ‚ฏ
22

3-
A `<router-view>` component involved in a transition can control / react to the transition by implementing appropriate transition pipeline hooks. These hooks include:
3+
`<router-view>` ใ‚ณใƒณใƒใƒผใƒใƒณใƒˆใฏใ€้ฉๅˆ‡ใชใƒˆใƒฉใƒณใ‚ธใ‚ทใƒงใƒณใƒ‘ใ‚คใƒ—ใƒฉใ‚คใƒณใƒ•ใƒƒใ‚ฏใ‚’ๅฎŸ่ฃ…ใ™ใ‚‹ใ“ใจใซใ‚ˆใฃใฆใƒˆใƒฉใƒณใ‚ธใ‚ทใƒงใƒณใ‚’ๅˆถๅพกใ™ใ‚‹(ใซๅๅฟœใ™ใ‚‹)ใ“ใจใŒใงใใพใ™ใ€‚ใ“ใ‚Œใ‚‰ใฎใƒ•ใƒƒใ‚ฏใŒๅซใพใ‚Œใพใ™:
44

55
- `data`
66
- `activate`
@@ -9,11 +9,11 @@ A `<router-view>` component involved in a transition can control / react to the
99
- `canDeactivate`
1010
- `canReuse`
1111

12-
You can implement these hooks under your component's `route` option:
12+
ใ‚ใชใŸใฎใ‚ณใƒณใƒใƒผใƒใƒณใƒˆใฎไธ‹ใง `route` ใ‚ชใƒ—ใ‚ทใƒงใƒณใ‚’ใ“ใ‚Œใ‚‰ใฎใƒ•ใƒƒใ‚ฏใงๅฎŸ่ฃ…ใ™ใ‚‹ใ“ใจใŒใงใใพใ™:
1313

1414
``` js
1515
Vue.component('hook-example', {
16-
// ... other options
16+
// ... ไป–ใฎใ‚ชใƒ—ใ‚ทใƒงใƒณ
1717
route: {
1818
activate: function (transition) {
1919
console.log('hook-example activated!')
@@ -27,80 +27,79 @@ Vue.component('hook-example', {
2727
})
2828
```
2929

30-
### Transition Object
30+
### ใƒˆใƒฉใƒณใ‚ธใ‚ทใƒงใƒณใ‚ชใƒ–ใ‚ธใ‚งใ‚ฏใƒˆ
3131

32-
Each transition hook will receive a `transition` object as the only argument. The transition object exposes the following properties & methods:
32+
ใƒˆใƒฉใƒณใ‚ธใ‚ทใƒงใƒณใƒ•ใƒƒใ‚ฏใ”ใจใซๅ”ฏไธ€ๅผ•ๆ•ฐใจใ—ใฆ `transition` ใ‚ชใƒ–ใ‚ธใ‚งใ‚ฏใƒˆใ‚’ๅ—ใ‘ๅ–ใ‚Šใพใ™ใ€‚ใƒˆใƒฉใƒณใ‚ธใ‚ทใƒงใƒณใ‚ชใƒ–ใ‚ธใ‚งใ‚ฏใƒˆใฏไปฅไธ‹ใฎใƒ—ใƒญใƒ‘ใƒ†ใ‚ฃใจใƒกใ‚ฝใƒƒใƒ‰ใ‚’ๅ…ฌ้–‹ใ—ใพใ™:
3333

3434
- **transition.from**
3535

36-
A [route object](../route.md) representing the route we are transitioning from.
36+
from ใ‹ใ‚‰ใƒˆใƒฉใƒณใ‚ธใ‚ทใƒงใƒณใ—ใฆใ„ใ‚‹ route ใ‚’่กจใ™ [route ใ‚ชใƒ–ใ‚ธใ‚งใ‚ฏใƒˆ](../route.md)ใ€‚
3737

3838
- **transition.to**
3939

40-
A route object representing the target path.
40+
ใ‚ฟใƒผใ‚ฒใƒƒใƒˆใƒ‘ใ‚นใ‚’่กจใ™ route ใ‚ชใƒ–ใ‚ธใ‚งใ‚ฏใƒˆใ€‚
4141

4242
- **transition.next()**
4343

44-
Call this method to progress to the next step of the transition.
44+
ใƒˆใƒฉใƒณใ‚ธใ‚ทใƒงใƒณใฎๆฌกใฎใ‚นใƒ†ใƒƒใƒ—ใซ้€ฒใ‚€ใŸใ‚ใซใ“ใฎใƒกใ‚ฝใƒƒใƒ‰ใ‚’ๅ‘ผใณๅ‡บใ—ใพใ™ใ€‚
4545

4646
- **transition.abort([reason])**
4747

48-
Call this method to cancel / reject the transition.
48+
ใƒˆใƒฉใƒณใ‚ธใ‚ทใƒงใƒณใ‚’ใ‚ญใƒฃใƒณใ‚ปใƒซ/ๆ‹’ๅฆใ™ใ‚‹ใซใฏใ“ใฎใƒกใ‚ฝใƒƒใƒ‰ใ‚’ๅ‘ผใณๅ‡บใ—ใพใ™ใ€‚
4949

5050
- **transition.redirect(path)**
5151

52-
Cancel current transition and redirect to a different target route instead.
52+
็พ็Šถใฎใƒˆใƒฉใƒณใ‚ธใ‚ทใƒงใƒณใ‚’ใ‚ญใƒฃใƒณใ‚ปใƒซใ—ใฆใ€ไปฃใ‚ใ‚Šใซๅˆฅใฎใ‚ฟใƒผใ‚ฒใƒƒใƒˆ route ใซใƒชใƒ€ใ‚คใƒฌใ‚ฏใƒˆใ—ใพใ™ใ€‚
5353

54-
All transition hooks are considered asynchronous by default. In order to signal the transition to progress, you have three options:
54+
ๅ…จใฆใฎใƒˆใƒฉใƒณใ‚ธใ‚ทใƒงใƒณใƒ•ใƒƒใ‚ฏใฏใƒ‡ใƒ•ใ‚ฉใƒซใƒˆใง้žๅŒๆœŸใจ่ฆ‹ใชใ•ใ‚Œใพใ™ใ€‚ใƒˆใƒฉใƒณใ‚ธใ‚ทใƒงใƒณใฎ้€ฒ่กŒใ‚’้€š็Ÿฅใ™ใ‚‹ใŸใ‚ใซใ€3ใคใฎใ‚ชใƒ—ใ‚ทใƒงใƒณใŒใ‚ใ‚Šใพใ™:
5555

56-
1. Explicitly call one of `next`, `abort` or `redirect`.
56+
1. ๆ˜Ž็คบ็š„ใซ `next` ใ€`abort` ใพใŸใฏ `redirect` ใฎใ„ใšใ‚Œใ‹ใ‚’ๅ‘ผใณๅ‡บใ—ใพใ™ใ€‚
5757

58-
2. Return a Promise. Details below.
58+
2. Promise ใ‚’่ฟ”ใ—ใพใ™ใ€‚่ฉณ็ดฐใฏไปฅไธ‹ใง่ชฌๆ˜Žใ—ใพใ™ใ€‚
5959

60-
3. For validation hooks (`canActivate` and `canDeactivate`), you can synchronously return a Boolean value.
60+
3. ๆคœ่จผใƒ•ใƒƒใ‚ฏ (`canActivate` ใจ `canDeactivate`) ใงใ€ๅŒๆœŸ็š„ใซ Boolean ๅ€คใ‚’่ฟ”ใ—ใพใ™ใ€‚
6161

62-
### Returning Promise in Hooks
62+
### ใƒ•ใƒƒใ‚ฏใง Promise ใ‚’่ฟ”ใ™
6363

64-
When you return a Promise in a transition hook, `transition.next` will be called for you when the Promise resolves. If the Promise is rejected during validation phase, it will call `transition.abort`; if it is rejected during activation phase, it will call `transition.next`.
64+
ใƒˆใƒฉใƒณใ‚ธใ‚ทใƒงใƒณใƒ•ใƒƒใ‚ฏใง Promise ใ‚’่ฟ”ใ™ใจใใ€`transition.next` ใฏ Promise ใŒ่งฃๆฑบใ™ใ‚‹ใจใใซๅ‘ผใณๅ‡บใ•ใ‚Œใพใ™ใ€‚ใ‚‚ใ—ใ€Promise ใŒๆคœ่จผใƒ•ใ‚งใƒผใ‚บใฎ้–“ใงๆ‹’ๅฆใ•ใ‚ŒใŸๅ ดๅˆใฏใ€`transition.abort` ใ‚’ๅ‘ผใณใพใ™ใ€‚ใ‚‚ใ—ใ€ๆดปๆ€งๅŒ–ใƒ•ใ‚งใƒผใ‚บใฎ้–“ใงๆ‹’ๅฆใ•ใ‚ŒใŸๅ ดๅˆใฏใ€`transition.next` ใ‚’ๅ‘ผใณใพใ™ใ€‚
6565

66-
For validation hooks (`canActivate` and `canDeactivate`), if the Promise's resolved value is falsy, it will also abort the transition.
66+
ๆคœ่จผใƒ•ใƒƒใ‚ฏ (`canActivate` ใจ `canDeactivate`)ใงใ€ใ‚‚ใ— Promise ใŒๅฝใจใชใ‚Šใ†ใ‚‹ๅ€คใง่งฃๆฑบใ•ใ‚Œใ‚‹ๅ ดๅˆใ€ใƒˆใƒฉใƒณใ‚ธใ‚ทใƒงใƒณใ‚’ไธญๆญขใ—ใพใ™ใ€‚
6767

68-
If a rejected promise has an uncaught error, it will be thrown unless you suppress it with the `suppressTransitionError` option when creating the router.
68+
ใ‚‚ใ—ใ€Promise ใŒใ‚ญใƒฃใƒƒใƒใ•ใ‚Œใฆใ„ใชใ„ใ‚จใƒฉใƒผใ‚’ๆ‹’ๅฆใ—ใŸๅ ดๅˆใฏใ€ใƒซใƒผใ‚ฟใƒผใ‚’ไฝœๆˆใ™ใ‚‹ใจใ `suppressTransitionError` ใ‚ชใƒ—ใ‚ทใƒงใƒณใงๆŠ‘ๅˆถใ—ใชใ„้™ใ‚Šใ‚นใƒญใƒผใ•ใ‚Œใพใ™ใ€‚
6969

70-
**Example:**
70+
**ไพ‹:**
7171

7272
``` js
73-
// inside component definition
73+
// ใ‚ณใƒณใƒใƒผใƒใƒณใƒˆๅฎš็พฉๅ†…้ƒจ
7474
route: {
7575
canActivate: function () {
76-
// assuming the service returns a Promise that
77-
// resolve to either `true` or `false`.
76+
// `true` ใพใŸใฏ `false` ใฎใฉใกใ‚‰ใ‹ใง่งฃๆฑบใ™ใ‚‹
77+
// Promise ใ‚’่ฟ”ใ™ใ‚ตใƒผใƒ“ใ‚นใจไปฎๅฎšใ—ใพใ™ใ€‚
7878
return authenticationService.isLoggedIn()
7979
},
8080
activate: function (transition) {
8181
return messageService
8282
.fetch(transition.to.params.messageId)
8383
.then((message) => {
84-
// set the data once it arrives.
85-
// the component will not display until this
86-
// is done.
84+
// ใใ‚ŒใŒๅฑŠใ„ใŸใ‚‰ใ€ไธ€ๅบฆใ ใ‘ใƒ‡ใƒผใ‚ฟใ‚’่จญๅฎšใ—ใพใ™ใ€‚
85+
// ใ‚ณใƒณใƒใƒผใƒใƒณใƒˆใฏใ“ใ‚ŒใŒ็ต‚ใ‚ใ‚‹ใพใง่กจ็คบใ•ใ‚Œใพใ›ใ‚“ใ€‚
8786
this.message = message
8887
})
8988
}
9089
}
9190
```
9291

93-
We are asynchronously fetching data in the `activate` hook here just for the sake of an example; Note that we also have the [`data` hook](data.md) which is in general more appropriate for this purpose.
92+
ใ“ใ“ใงใฏใกใ‚‡ใ†ใฉไพ‹ใฎใŸใ‚ `activate` ใƒ•ใƒƒใ‚ฏใง้žๅŒๆœŸ็š„ใซใƒ‡ใƒผใ‚ฟใ‚’ใƒ•ใ‚งใƒƒใƒใ—ใฆใ„ใพใ™ใ€‚ไธ€่ˆฌ็š„ใซใฏใ“ใฎ็›ฎ็š„ใฎใŸใ‚ใซใ€ใ‚ˆใ‚Š้ฉๅˆ‡ใช [`data` ใƒ•ใƒƒใ‚ฏ](data.md)ใŒใ‚ใ‚‹ใ“ใจใซๆณจๆ„ใ—ใฆใใ ใ•ใ„ใ€‚
9493

95-
**TIP:** if you are using ES6 you can use argument destructuring to make your hooks cleaner:
94+
**TIP:** ใ‚‚ใ—ใ€ES6 ใ‚’ไฝฟ็”จใ—ใฆใ„ใ‚‹ๅ ดๅˆใ€ใ‚ใชใŸใฎใƒ•ใƒƒใ‚ฏใ‚’ใ‚ฏใƒชใƒผใƒณใชใ‚‚ใฎใซใ™ใ‚‹ใŸใ‚ใซใ€argument destructuring ใ‚’ไฝฟ็”จใ™ใ‚‹ใ“ใจใŒใงใใพใ™:
9695

9796
``` js
9897
route: {
9998
activate ({ next }) {
100-
// when done:
99+
// ใ™ใ‚‹ใจใ:
101100
next()
102101
}
103102
}
104103
```
105104

106-
Check out the [advanced example](https://github.com/vuejs/vue-router/tree/dev/example/advanced) in the vue-router repo.
105+
vue-router ใƒฌใƒใ‚ธใƒˆใƒชใฎ [advanced example](https://github.com/vuejs/vue-router/tree/dev/example/advanced) ใ‚’ใƒใ‚งใƒƒใ‚ฏใ—ใฆใใ ใ•ใ„ใ€‚

0 commit comments

Comments
ย (0)