polyglot icon indicating copy to clipboard operation
polyglot copied to clipboard

Feature request: ability to translate urls

Open kermorgant opened this issue 8 years ago • 9 comments

Woudn't it be a good thing if each translation of a page/post could have its url also translated ? From what I've read, this would be better for search engine optimization. I've tried a solution which is not perfect. Suppose that english is the default language, and I have a contact page translated in swedish

permalink: /kontakt/ lang: sv ref: contact

I use the ref as a common denominator to get translated pages, but this will generate a "kontakt" folder at the root of "_site", which is not what I'd want.

What do you think of that problem ? Do you think there's an easy way to keep using the plugin while achieving that ?

kermorgant avatar Sep 22 '16 18:09 kermorgant

Just a side note : maybe it would be a good idea to let the user decide if the language suffix is added to the permalink ? Maybe it would sove my issue with "kontakt" appearing in the root folder, and it would also probably help mix this plugin with others, like jekyll-redirect-from (it uses the permalink in a page, and cannot guess the link will be prefixed by a language tag)

kermorgant avatar Sep 22 '16 19:09 kermorgant

Hi @kermorgant! Other people have asked for this feature. I intend to add it and do a big update to polyglot soon.

There are other big changes coming to Jekyll, including official support for parallelized builds. This is a feature that will define how future polyglot does it's parallelization, and will ideally provide a roadmap to making it compatible with github pages (!!!)

As for your solution: there does need to be a common identifier between corresponding pages. using ref is a good idea, but it requires another frontmatter tag. At the moment that key is the permalink, but you're right that it should be something else. differently named permalinks also means that going to /sv/contact from /contactdoes not implicitly redirect to /sv/kontakt. A versatile permalink requires either

  • an officially supported tag to add a smart language switcher on the page (something like {% translations %} to generate the View in: English | Deutsch | Español | Français) that can ensure users are taken to the correct page when they switch languages.
  • implicit redirects from /sv/contact to /sv/kontakt

There are problems with both options, but I like the first a lot more. It means more work though, and it may mean users loose out on how they style their language switching.

Removing the language prefix is another feature some users have requested. This requires a solution to the above problem to work correctly to allow pages to switch languages at all. And there is still the auxillery problem of a user leaving permalink: /contact/ on both their english and swedish pages. Doesn't mean it can't be done (it will be), it's just edgecasey as hell.

Either way, the next version of polyglot is probably going to be a 2.0 release. There are a lot of big features I want to add, but I have other things on my plate I'm working on. Thanks for taking the time to leave a feature request! It should happen after more pieces move into play with the jekyll project, and my free time.

Cheers! @untra

untra avatar Sep 22 '16 20:09 untra

Is this now possible? The docs state that permalink must be provided always.

rriemann avatar Aug 10 '17 15:08 rriemann

No, it's currently not available. The permalink must remain the same across related translated pages.

untra avatar Aug 10 '17 15:08 untra

Any news on this @untra?

@kermorgant did you manage to make it work using ref:?

Cheers,

BeMrTeal avatar Nov 13 '17 14:11 BeMrTeal

Would be also interested in this. Any news?

martignoni avatar Dec 28 '17 19:12 martignoni

I've worked on the v2 version sporadically over the past few months. The new implementation will use the ref pattern as described above.

The v2 work is currently stuck on a different feature; replicating pages to appropriately build each website language. v2 will no longer fork to split execution for each language, which now makes designating the appropriate pages easier. The singlethreaded version of this task is surprisingly harder to achieve :/

The v2 branch is on this repo. Anyone can take a look at it. Sorry I haven't been actively working on this enough :/

untra avatar Dec 29 '17 02:12 untra

It seems progress stalled. I will try to have a look at this. Any pointer on the status is welcomed :). Can't promise anything though.

antoniovazquezblanco avatar Oct 04 '23 12:10 antoniovazquezblanco

I believe this issue can be closed. Changes added in https://github.com/untra/polyglot/pull/180 allows for the usage of a translation key and different permalinks.

Documentation can be found at https://github.com/untra/polyglot#using-different-permalinks-per-language

antoniovazquezblanco avatar Jan 09 '24 09:01 antoniovazquezblanco