Skip to content

Commit

Permalink
docs: Add details on routes translation (nuxt-modules#99)
Browse files Browse the repository at this point in the history
  • Loading branch information
Gabin Desserprit authored and paulgv committed Jun 22, 2018
1 parent fd51e3e commit 461fe7e
Showing 1 changed file with 68 additions and 1 deletion.
69 changes: 68 additions & 1 deletion docs/routing.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,19 @@ Make sure you set the `parsePages` option to `false` to disable acorn parsing an
}]
```
Note that each key in the `pages` object should correspond to the full file path in your page directory, say you have some nested page like:
Note that each key in the `pages` object should correspond to the full file path in your `pages/` directory.
Make sure all keys:
1. Are relative to the `pages/` directory and don't start with a `/`
2. Point directly to their corresponding file without `.vue` (make sure you add `/index` when translating root paths)
Localized routes are full URIs, so keep in mind that:
1. They need to start with a `/`
2. You must repeat the full URI for each child route
#### Example 1
Say you have some nested page like:
```asciidoc
pages/
Expand All @@ -130,6 +142,61 @@ Here's how you would configure this particular page in the configuration:
}]
```
#### Example 2
With the following `pages` directory:
```asciidoc
pages/
├── about.vue
├── services/
├──── index.vue
├──── development/
├────── index.vue
├────── app/
├──────── index.vue
├────── website/
├──────── index.vue
├──── coaching/
├────── index.vue
```
You would need to set up your `pages` property as follows:
```js
// nuxt.config.js
['nuxt-i18n', {
parsePages: false,
pages: {
about: {
en: '/about',
fr: '/a-propos',
},
'services/index': {
en: '/services',
fr: '/offres',
},
'services/development/index': {
en: '/services/development',
fr: '/offres/developement',
},
'services/development/app/index': {
en: '/services/development/app',
fr: '/offres/developement/app',
},
'services/development/website/index': {
en: '/services/development/website',
fr: '/offres/developement/site-web',
},
'services/coaching/index': {
en: '/services/coaching',
fr: '/offres/formation',
}
}
}]
```
## Ignore routes
Expand Down

0 comments on commit 461fe7e

Please sign in to comment.