In D8, with the usual translation modules enabled, I have a custom pop-up to change language on our site. Currently, it contains a link and text, like this:
<p><a href="/en-us[current-page:url:alias]">EN</a> | <a href="/es-us[current-page:url:alias]">ES</a></p>
This would work, except that the link of the translated page is different.
Example. If I'm on the English page, "website.com/contact-us" and change my language to Spanish, the page will load "website.com/es-us/contact-us" ... which does not exist. It's a 404 error
But that is incorrect. The Spanish version is correctly spelled 'contáctenos" So, I want the Spanish user to go to "website.com/es-us/contactenos.
Is there a way to do this with the tokens? Or another approach? Some way to know to send the user to the Spanish url translation of the page