October CMS resources and help articles

Simple and to the point. Optimized by the community.

Translate indexed slugs for alternate hrefs

1
by OFFLINE, last modified on January 29th, 2021

This trick is no longer required as it is now included in RainLab.Translate by default:

https://github.com/rainlab/translate-plugin/commit/c9e4032d443c4f066ffefc3815adab0db5222d16

___

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.

Discussion

0 comments

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