Partially multilingual site in D8

Events happening in the community are now at Drupal community events on www.drupal.org.
jhodgdon's picture

Is it possible to create a partially-multilingual site in Drupal 8, without having a bunch of nonsense URLs? Details...

Site setup:
- Most of my content is in the primary site language (English, in this case).
- Some content items have been translated into a second language (Spanish, in this case).
- The rest of the site hasn't been translated into the second language, and there are no plans to do so.
- The pages on the site have URL aliases.

Now, let's say I start in English, and go to node/32, aliased as /my-beautiful-dog, which has been translated into Spanish. I have a language switcher block enabled, so I click on Spanish, and get to page /es/mi-hermoso-perro. So far, so good.

Now I use the site's main navigation to go to the site About page, which is only available in English, at node/3 aliased to /about. However, since I am viewing the site in Spanish, the URL I get to is instead es/node/3 (no alias). Which shows the page in English anyway (since that is all that is available).

So... The problems with this are:
- The URL I am on is ugly (es/node/3)
- Two pages on my site exist with the same exact content (the About page in English), with different URLs. This is terrible for search engines.
- Really the URL of es/node/3 should never be allowed to exist. This page is only in English, so when I visit node 3 I should never be in Spanish.

In a Drupal 7 similar situation, I wrote a quick module of a few lines, I think using hook_init() or hook_boot() or something like that, which noticed I was on an English-only page and did a drupal_goto() that redirected back to the English URL. It worked, though it was a bit brute force...

I'm not sure how to do that in Drupal 8... or even if that is a good idea. Any ideas of how to resolve this? Thanks!

Comments

Got this working!

jhodgdon's picture

I got this working wrote up a blog post about how I did it:
http://poplarware.com/article/partially-multilingual-seo

If anyone is interested, I could post the module on drupal.org... under 200 lines of code (including documentation). I'm not sure how common a situation this is, since I didn't see any responses here or to my tweet about this, so I'm not sure how much of a demand there is... Anyway, at the moment you can download the module on the blog post.

Internationalization

Group organizers

Group categories

Group notifications

This group offers an RSS feed. Or subscribe to these personalized, sitewide feeds: