Possibility to localize dynamic routes
See original GitHub issueWhat problem does this feature solve?
I’m not sure if it is possible 😃
I have a route /article/:slug
(en) and I’d like to translate it to other languages with translated slug
Eg: (en) /article/first-article
and (de) /de/artikel/erste-artikel
Now I can do this:
article.vue
i18n: {
paths: {
de: '/artikel/:slug'
}
},
data () {
return {
article: { // it comes from asyncData
// title: { en: '...', de: '...' },
// slug: { en: '...', de: '...' }
}
}
}
but I can’t change the slug
based on the article’s data
What does the proposed changes look like?
I think the i18n.paths[locale]
should accept a function with the access of this
(data) and should return some Object:
de () {
return {
path: '/artikel/:slug',
params: {
slug: this.article.slug.de
}
}
}
<div align="right">This feature request is available on Nuxt.js community (#c74)</div>Issue Analytics
- State:
- Created 5 years ago
- Reactions:9
- Comments:12
Top Results From Across the Web
Possibility to localize dynamic routes · Issue #79 - GitHub
I'm not sure if it is possible :) I have a route /article/:slug (en) and I'd like to translate it to other languages...
Read more >How to generate localized dynamic routes with nuxt and nuxt ...
I'm trying to make nuxt generate localized dynamic routes. I used nuxt-i18n to translate each route. Here is my nuxt-i18n configuation:
Read more >Dynamic content localization | Apostrophe 3 Documentation
Localizing content is only possible if the Apostrophe app has configured locales. If you are looking for information on configuring locales, ...
Read more >[vue-router] localized urls and dynamic routes - Get Help
It will enable you to have localized URLs pointing to the same route, while setting i18n locale based on URL. No route duplication...
Read more >Lang Switcher - i18n-module
Dynamic route parameters. Dealing with dynamic route parameters requires a bit more work because you need to provide parameters translations to @nuxtjs/i18n.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Here’s my attempt at supporting dynamic parameters translation in nuxt-i18n: https://github.com/nuxt-community/nuxt-i18n/pull/345
Please read the PR description to see how you can try it yourselves. I’d love to have some feedback on this!
Any news? Also looking for dynamic route paths translation.
The proposed solution to pass a function to
paths:
is what I had in mind aswell. Rookie here, though… so I don’t know if it’s possible to expose context, i18n etc. to this function under the hood.