October CMS resources and help articles

Simple and to the point. Optimized by the community.

Translate indexed slugs for alternate hrefs

by OFFLINE, last modified on September 2nd, 2019

Currently, URLs with indexed slugs do not get translated in the AlternateHrefLangElments-component of the rainlab translate-plugin. To enhance the component with this functionality, just add the following class and lines to the component.

use Illuminate\Support\Facades\Event;

// ...

$translatedParams = Event::fire('translate.localePicker.translateParams',
    [$page, $params, $this->oldLocale, $locale], true);

if ($translatedParams) {
    $params = $translatedParams;

If you want to use this functionality it is necessary that you have implemented the url parameter translation of the plugin. See https://github.com/rainlab/translate-plugin#url-parameter-translation.



We use cookies to measure the performance of this website. Do you want to accept these cookies?