- Issue created by @alberto56
I have an issue when a link to non default language "/en/student-stories" displayed as '/student-stories' on English pages.
In some cases, Linkit thinks that a link should be one way, but the website's logic would prefer another link. Here is an example:
drush site:install -y
mkdir -p modules/custom
cd modules/custom
git clone --branch '7.x' https://git.drupalcode.org/project/linkit.git
cd ../..
drush en -y linkit language content_translation
drush uli
For certain websites, the above behaviour may be reasonable; for other sites, it may be reasonable for a link on the page /en-gb/node/2 to link to /en-gb/node/1, even though neither node 1 or 2 have an explicit "en-gb" translation. For other sites with more complex language structures, one might have en, en-gb, en-ca, fr, fr-ca, fr-fr, es-mx... and there may be custom logic to implement (for example en-ca would revert to en, fr-ca would revert to fr, es-mx would revert to fr).
It should be noted that ./src/Plugin/Filter/LinkitFilter.php::process()
takes the arguments $text, and $langcode, where $langcode is the language of the existing translation.
Therefore, in our example with node 2, if no en-gb translation exists, the filter process function will apply to node/2's English (original) version, and then the original English version of the the node will be displayed whether we are in /en, or /en-gb. (There cannot be two versions of the body text.)
My thought at this point is to modify the link in the frontend using JavaScript.
I shall post my findings as they come about.
Active
7.0
Code
I have an issue when a link to non default language "/en/student-stories" displayed as '/student-stories' on English pages.