Be sure to checkout our newest add-on Reading Time Pro!

EE4 compatibility updates:

  • Publisher is EE4 and EE5 compatible, but it does not currently support the Fluid field (it's in the works).
  • Reel is EE4 and EE5 compatible, but it does not currently support the Fluid field.

Ticket: Language switcher un-translating the translated url_title

Status To Do
Add-on / Version Publisher 2.10.8
Severity
EE Version 5.2.2

Mary Ellen Slater

Apr 26, 2019

mod.publisher.php:375   $languageVar[‘switch_language_url’] = htmlspecialchars($url.’&lang_id=’.$languageId.’&’).$currentUrl;

When browsing this URL: /article/young-woman-fights-melanoma-and-gives-back
The {translated_url} variable for our lang_id=2 produces this url correctly:
/es/artículo/una-joven-combate-el-melanoma-y-ayuda-a-los-demas
We are translating the template article to artículo and the url_title is being translated as well.
That’s all correct.

The language switcher is producing a url with ACT=27, which for us is the set_language function:
ACT=27&site_id=1&lang_id=2&url=aHR0cHMlM0ElMkYlMkZtYWdhemluZS5tZWRsaW5lcGx1cy5nb3YlMkZlcyUyRmFydCVDMyVBRGN1bG8lMkZ1bmEtam92ZW4tY29tYmF0ZS1lbC1tZWxhbm9tYS15LWF5dWRhLWEtbG9zLWRlbWFz

When we base64_decode this:
aHR0cHMlM0ElMkYlMkZtYWdhemluZS5tZWRsaW5lcGx1cy5nb3YlMkZlcyUyRmFydCVDMyVBRGN1bG8lMkZ1bmEtam92ZW4tY29tYmF0ZS1lbC1tZWxhbm9tYS15LWF5dWRhLWEtbG9zLWRlbWFz
We get the correct URL, with both the PATH and URL_TITLE translated:
/es%2Fart%C3%ADculo%2Funa-joven-combate-el-melanoma-y-ayuda-a-los-demas
But when the browser loads, it places us here:
/es/artículo/young-woman-fights-melanoma-and-gives-back

The content is correctly in lang_id = 2, but the URL title had reverted back to the lang_1 title, even though what was passed was the correct url.

/es/artículo/young-woman-fights-melanoma-and-gives-back
should have been.
/es/artículo/una-joven-combate-el-melanoma-y-ayuda-a-los-demas

When we are returned to this url:
/es/artículo/young-woman-fights-melanoma-and-gives-back
and shown lang_2 content, the language switcher will then generate an incorrect URL for the translation back to lang_id = 1.
Giving us this URL value:
/artículo/young-woman-fights-melanoma-and-gives-back
which produces a 404 error.
From that point onward the language switcher function can’t create a correctly path’ed url that doesn’t produce a 404 error.

We’ve found that adjusting the switcher like this works better for our needs (as it translates the PATH as well), but with the same issue, we are losing the translated URL TITLE upon redirect.
$languageVar[‘switch_language_url_custom’] = htmlspecialchars($url.’&lang_id=’.$languageId.’&’).‘url=’.base64_encode(urlencode($translatedUrl) );
Calling it with: {switch_language_url_custom} in our template, and only for the language id that isn’t active (so it’s a toggle).

on this URL: /article/young-woman-fights-melanoma-and-gives-back
shows the switch url as:
%2Fes%2Fart%C3%ADculo%2Funa-joven-combate-el-melanoma-y-ayuda-a-los-demas
however when I click that link, I am brought here:
/es/artículo/young-woman-fights-melanoma-and-gives-back

Why did it translate back the url_title to lang_id = 1 value when the whole page is in lang_id = 2 value?
Without our switcher code change the toggle does not work for our urls, it produces incorrectly pathed urls that throw 404s.

Please advise.  Thank you.

#1

BoldMinded (Brian)

Apr 26, 2019

Thanks again for the detailed report. I’ll try to replicate this locally and get back to you in a few days.

#2

Mary Ellen Slater

Apr 26, 2019

Thank you.  We may not be using this switch correctly, since we are using it as a toggle.
We have 2 languages, if one isn’t active, then it’s the other.
The sticking point for us is that the URL wasn’t correct, so we made that code adjustment from:

mod.publisher.php:375  
$languageVar[‘switch_language_url’] = htmlspecialchars($url.’⟨_id=’.$languageId.’&’).$currentUrl;
to include our custom tag:
$languageVar[‘switch_language_url_custom’] = htmlspecialchars($url.’⟨_id=’.$languageId.’&’).‘url=’.base64_encode(urlencode($translatedUrl) );

Basically using the translated url instead of the current url.

In either case, it’s ignoring the translated url_title, and we are only successful with the adjusted/new tag and not the standard tag.

Thanks

Login to reply

Contact

For add-on support, please use the Support section. General inquries and pre-sale questions can be sent to support@boldminded.com.