Add pathPrefixedByLangCode to Utils, fix generating pages routes for translated languages

This commit is contained in:
Flavio Copes
2015-08-20 19:55:00 +02:00
parent 26d1973110
commit ce8fd4d3ef
2 changed files with 19 additions and 1 deletions

View File

@@ -154,7 +154,11 @@ class Page
if (file_exists($path)) {
$aPage = new Page();
$aPage->init(new \SplFileInfo($path), $language .'.md');
$translatedLanguages[$language] = isset($aPage->header()->routes['default']) ? $aPage->header()->routes['default'] : $aPage->rawRoute();
$route = isset($aPage->header()->routes['default']) ? $aPage->header()->routes['default'] : $aPage->rawRoute();
if (!$route) $route = $aPage->slug();
$translatedLanguages[$language] = $route;
}
}

View File

@@ -437,4 +437,18 @@ abstract class Utils
}
return $result;
}
public static function pathPrefixedByLangCode($string)
{
$languages_enabled = self::getGrav()['config']->get('system.languages.supported', []);
if ($string[0] == '/' && $string[3] == '/' && in_array(substr($string, 1, 2), $languages_enabled)) {
return true;
}
return false;
}
}