question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Possibility to localize dynamic routes

See original GitHub issue

What 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:closed
  • Created 5 years ago
  • Reactions:9
  • Comments:12

github_iconTop GitHub Comments

3reactions
paulgvcommented, Jul 1, 2019

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!

0reactions
katerlouiscommented, Nov 4, 2020

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found