Fixed issue saving page with non-standard language #1667

This commit is contained in:
Andy Miller
2019-04-29 18:00:12 -06:00
parent 7cee46bd59
commit 42179435eb
2 changed files with 12 additions and 11 deletions

View File

@@ -631,7 +631,7 @@ class AdminBaseController
// now the first 4 chars of base contain the lang code. // now the first 4 chars of base contain the lang code.
// if redirect path already contains the lang code, and is != than the base lang code, then use redirect path as-is // if redirect path already contains the lang code, and is != than the base lang code, then use redirect path as-is
if (Utils::pathPrefixedByLangCode($base) && Utils::pathPrefixedByLangCode($this->redirect) if (Utils::pathPrefixedByLangCode($base) && Utils::pathPrefixedByLangCode($this->redirect)
&& 0 !== strpos($this->redirect, substr($base, 0, 4)) && !Utils::startsWith($this->redirect, $base)
) { ) {
$redirect = $this->redirect; $redirect = $this->redirect;
} else { } else {

View File

@@ -2375,18 +2375,19 @@ class AdminController extends AdminBaseController
*/ */
public function determineFilenameIncludingLanguage($current_filename, $language) public function determineFilenameIncludingLanguage($current_filename, $language)
{ {
$filename = substr($current_filename, 0, -strlen('.md')); $ext = '.md';
$filename = substr($current_filename, 0, -strlen($ext));
$languages_enabled = $this->grav['config']->get('system.languages.supported', []);
if (substr($filename, -3, 1) === '.') { $parts = explode('.', trim($filename, '.'));
$filename = str_replace(substr($filename, -2), $language, $filename); $lang = array_pop($parts);
} elseif (substr($filename, -6, 1) === '.') {
$filename = str_replace(substr($filename, -5), $language, $filename); if ($lang === $language) {
} else { return $filename . $ext;
$filename .= '.' . $language; } elseif (in_array($lang, $languages_enabled)) {
$filename = implode('.', $parts);
} }
return $filename . '.md'; return $filename . '.' . $language . $ext;
} }
} }