Skip to content

Commit

Permalink
fix(docs): add info on using dynamic translations with _.vue
Browse files Browse the repository at this point in the history
Fixes #1400
  • Loading branch information
rchl committed Feb 19, 2022
1 parent 091944c commit b6039d2
Showing 1 changed file with 19 additions and 3 deletions.
22 changes: 19 additions & 3 deletions docs/content/en/lang-switcher.md
Expand Up @@ -85,9 +85,25 @@ export default {
en: { postId: 'my-post' },
fr: { postId: 'mon-article' }
})
return {
// your data
}
}
}
</script>
```

Note that for the special case of the catch-all route named `_.vue`, the key of the object needs to say `pathMatch`. For example:

```vue
<template>
<!-- pages/_.vue -->
</template>
<script>
export default {
async asyncData ({ store }) {
await store.dispatch('i18n/setRouteParams', {
en: { pathMatch: 'my-post/abc' },
fr: { pathMatch: 'mon-article/xyz' }
})
}
}
</script>
Expand Down

0 comments on commit b6039d2

Please sign in to comment.