robisim74 / qwik-speak

Translate your Qwik apps into any language
https://robisim74.gitbook.io/qwik-speak/
MIT License
133 stars 15 forks source link

[Feature Request] Localized routing with dynamic URL rewriting #94

Closed nelsonprsousa closed 1 year ago

nelsonprsousa commented 1 year ago

Scenario

Currently, it is possible to localize routing with the static URL rewriting feature (en->pt): /home -> /inicio /about-us -> /sobre-nos

However, we would like to localize dynamic routing, with slugs. Example (en->pt): /vacations/[countryName]/packages -> /ferias/[countryName]/pacotes

Attempt: image

export const rewriteRoutes = [
  {
    prefix: 'pt',
    paths: {
      'vacations/[countryName]/packages': 'ferias/[countryName]/pacotes',
      // other paths
    }
  }
]

Request

Is it possible to have localized routing with dynamic URL rewriting? This should help with SEO on multiple scenarios.

Available to help and even submit a PR, after receiving feedback regarding this feature request (and some guidance would help 🙏 )

Thank you!

robisim74 commented 1 year ago

Hi Nelson,

when translating paths in rewriteRoutes, you must use path segments:

export const rewriteRoutes = [
  {
    prefix: 'pt',
    paths: {
      'vacations': 'ferias',
      'packages': 'pacotes'
      // other paths
    }
  }
]

Then slugs should work out of the box: https://qwik.builder.io/docs/routing/#rewrite-routes

Example: https://qwik-speak.pages.dev/page/123/

nelsonprsousa commented 1 year ago

Indeed, I thought we had to integrate somehow with this lib. Awesome, thanks for your help. 🙏