October CMS resources and help articles

Simple and to the point. Optimized by the community.

Generate a page URL in a specific locale

by OFFLINE, last modified on June 11th, 2021

Use the rewriteTranslatablePageUrl method to get a page URL in a specific locale.

$locale = 'de';
$pageName = 'target-cms-page';
// If your model slug is translatable use
// $params = ['slug' => $model->locale($locale)->slug];
$params = ['slug' => 'your-model-slug'];

$theme = Theme::getActiveThemeCode();
$cmsPage = Page::loadCached($theme, $pageName);


$router = new \October\Rain\Router\Router;
$localeUrl = $router->urlFromPattern($cmsPage->url, $params);
// If you need the locale prefix use 
// $localeUrl = $router->urlFromPattern(sprintf("/%s%s", $locale, $page->url), $params);

echo url($localeUrl);



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