public function getPathInLocale($path, $locale = null)
{
$segments = explode('/', $path);
$segments = array_values(array_filter($segments, function ($v) {
return $v != '';
}));
if (is_null($locale) || !Locale::isValid($locale)) {
$locale = $this->defaultLocale;
}
if (count($segments) == 0 || Locale::isValid($segments[0])) {
$segments[0] = $locale;
} else {
array_unshift($segments, $locale);
}
return implode('/', $segments);
}