IssueRaiser

Allow translation of URLS

Hi @wiziple, thanks for this nice plugin. I was wondering if you plan to add url slug's translations too, which is a feature I haven't seen yet in the various gatsby i18n plugins. So, to make it more clear, I mean if you plan to allow this: ``` en/about it/chi-siamo (instead of it/about) ``` same page with two different slugs. I guess is not easy to manage the link routing, but I think it's possible to build a sort of routes map during the `createPages` step and pass it to the pages inside the `intl` context. The link component can then use the `to` prop as a key that would match this routes map. Some super pseudo code: in `src/pages/about/index.en.md` ```yaml url: /about ``` in `src/pages/about/index.it.md` ```yaml url: /chi-siamo ``` Then we would have a routes map in page contexts like: ```js intl = { ..., routes: { 'about': { en: '/about', it: '/chi-siamo' } } } ``` And the Link component would do ```jsx intl => ( Link = ({ to, ... }) => { const toRoute = intl.routes[to][intl.language] } ``` I am curious to see what you think of this approach or if you have any other idea in this regard. Let me know if all this is a bit unclear!

Posted by kuus on Jun 22, 2019, 6:48 AM

Tags

Related issues

Raise real-world problems, find people facing the same issue, and discuss solutions.3,500 issues0 comments

github (Other)

Allow translation of URLS

kuusJun 22, 2019, 6:48 AM

Hi @wiziple, thanks for this nice plugin. I was wondering if you plan to add url slug's translations too, which is a feature I haven't seen yet in the various gatsby i18n plugins. So, to make it more clear, I mean if you plan to allow this: ``` en/about it/chi-siamo (instead of it/about) ``` same page with two different slugs. I guess is not easy to manage the link routing, but I think it's possible to build a sort of routes map during the `createPages` step and pass it to the pages inside the `intl` context. The link component can then use the `to` prop as a key that would match this routes map. Some super pseudo code: in `src/pages/about/index.en.md` ```yaml url: /about ``` in `src/pages/about/index.it.md` ```yaml url: /chi-siamo ``` Then we would have a routes map in page contexts like: ```js intl = { ..., routes: { 'about': { en: '/about', it: '/chi-siamo' } } } ``` And the Link component would do ```jsx intl => ( Link = ({ to, ... }) => { const toRoute = intl.routes[to][intl.language] } ``` I am curious to see what you think of this approach or if you have any other idea in this regard. Let me know if all this is a bit unclear!

Comments (0)

No comments yet. Start the discussion.

Comment on this issue