Skip to content

Japanese Translation: ja/routing.md #38

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 2 commits into from
Jun 21, 2017
Merged
Changes from 1 commit
Commits
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
24 changes: 12 additions & 12 deletions ja/routing.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,14 @@ import Vue from 'vue'
import App from './App.vue'
import { createRouter } from './router'
export function createApp () {
// create router instance
// ルーターインスタンスを作成します
const router = createRouter()
const app new Vue({
// inject router into root Vue instance
// ルーターをルートVueインスタンスに注入します
router,
render: h => h(App)
})
// return both the app and the router
// アプリケーションとルーターの両方を返します
return { app, router }
}
```
Expand All @@ -47,21 +47,21 @@ export function createApp () {
// entry-server.js
import { createApp } from './app'
export default context => {
// since there could potentially be asynchronous route hooks or components,
// we will be returning a Promise so that the server can wait until
// everything is ready before rendering.
// 非同期のルートフックまたはコンポーネントが存在する可能性があるため、
// プロミスを返却します。
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ここですが、原文的には、we will be returning a Promise so that the server can wait until everything is ready before rendering. だと思いますので、訳は以下になるのではないでしょうか。

レンダリングする前にすべての準備が整うまでサーバーが待機できるようにプロミスを返します。

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1文が長くなりすぎると思ったため、意訳で文章を分けてしまいました。
原文に忠実にします!

// そのため、サーバーはレンダリングの前に準備ができるまで待つことができます。
return new Promise((resolve, reject) => {
const { app, router } = createApp()
// set server-side router's location
// サーバーサイドのルーターの場所を設定します
router.push(context.url)
// wait until router has resolved possible async components and hooks
// ルーターが非同期コンポーネントとフックを解決するまで待ちます
router.onReady(() => {
const matchedComponents = router.getMatchedComponents()
// no matched routes, reject with 404
// 一致するルートがない場合、404で拒否します
if (!matchedComponents.length) {
reject({ code: 404 })
}
// the Promise should resolve to the app instance so it can be rendered
// プロミスはレンダリングできるようにアプリケーションインスタンスを解決するべきです
resolve(app)
}, reject)
})
Expand Down Expand Up @@ -98,9 +98,9 @@ server.get('*', (req, res) => {
Vue は非同期コンポーネントを最重要コンセプトとして提供しており、 [webpack 2の動的インポートをコード分割点として使用することへのサポート](https://webpack.js.org/guides/code-splitting-async/) と組み合わせることも可能です。そのためにすべきことは以下です。

```js
// changing this...
// これを...
import Foo from './Foo.vue'
// to this:
// このように変えます。
const Foo = () => import('./Foo.vue')
```

Expand Down