Can I translate nodes and provide access to their translated content without the use of a site-wide language switcher? Intended behaviour / question


Writer creates /node/5001
Translator translates /node/5001 to french using all the niceties of the Content Translation backend system
Visitor goes to /node/5001 and sees a link in the sidebar to the french version
Visitor arrives at /fr/node/5001, reads it, and then clicks away using one of the main menu links or anything in the sidebar
Visitor is now browsing the website in English, since that's the main language of the website, and the language menu links are written in. The viewing of translated content behaves just like viewing any other page on the website; it doesn't change languages for good.


Things are going wrong between steps 4 and 5, since step 4 puts the website in "French mode" which means all menu links point to french versions of content. In theory, all subsequent browsing will be in French (which is not what I want), and in practice the language will switch back and forth between French and English depending on the availability of translations (which is even worse), even though the URL will include the /fr/ prefix no matter what is actually displayed.

Is there a practical solution to this?

Background / supplemental

I've enabled Drupal 8's Content Translation and Language modules. Language detection &amp; selection is done using the default mechanism, which recognizes language code prefixes in the first component of the website's path (for example, /fr/node/1, for the french version of node 1).

I'm now wondering if there's any way, without going toe to toe in a fight to the death with the Drupal final boss, to provide translations ONLY of the content on select pages, but NOT of the entire site, such that the content is made available through links on my website, with the default language being restored to English when navigating away from those same pages?

The intention is to use Drupal's built-in (though other non-core suggestions are welcome) translation management features to create and manage subordinate multilingual content on the backend, but then access these translations on a case by case basis through links in a block for example, without having these navigation actions trigger persistent language selection events (from a user perspective) which rewrite all the menu URLs to match.

Basically, I'm trying to get something to work that would be the Content Translation module equivalent of a bunch of multilingual PDFs attached to a single piece of English content. Except I don't want to link to PDFs, I want to link to ordinary web pages, with the only real difference being that they're written in another language, and linked to an English version behind the scenes.

Am I wasting my time with this, or is there a way to translate just a subset of my content, with access opened up to those translations from the english site, minus the persistence of a full-on language switch for the remainder of the browsing session?
A simple solution in such cases would be to remove the language switcher and provide for translated content only modal links:

&lt;a class="use-ajax" data-dialog-type="modal" data-dialog-options="{&amp;quot;width&amp;quot;:800}" href="/fr/node/1"&gt;French version&lt;/a&gt;


You could add the links to the node, in a template or preprocess hook. Or create a block (View or custom block plugin), which lists the available translations of the current node as modal links.

How to build such links see How to open a popup form from a view link?