Fixed Page::untranslatedLanguages() not being symmetrical to Page::translatedLanguages()

This commit is contained in:
Matias Griese
2019-10-07 12:36:50 +03:00
parent 7dafa2a207
commit 2a6276a941
2 changed files with 8 additions and 32 deletions

View File

@@ -1,7 +1,12 @@
# v1.7.0-rc.1
## mm/dd/2019
1. [](#bugfix)
* Fixed `Page::untranslatedLanguages()` not being symmetrical to `Page::translatedLanguages()`
# v1.7.0-beta.10
## 10/03/2019
1. [](#new)
1. [](#improved)
* Flex: Removed extra exists check when creating object (messes up "non-existing" pages)
* Support customizable null character replacement in `CSVFormatter::decode()`

View File

@@ -245,38 +245,9 @@ class Page implements PageInterface
$language = $grav['language'];
$languages = $language->getLanguages();
$defaultCode = $language->getDefault();
$translated = array_keys($this->translatedLanguages(!$includeUnpublished));
$name = substr($this->name, 0, -strlen($this->extension()));
$untranslatedLanguages = [];
foreach ($languages as $languageCode) {
$path = $this->path . DS . $this->folder . DS . $name . '.' . $languageCode . '.md';
$exists = file_exists($path);
// Default language may be saved without language file location.
if (!$exists && $languageCode === $defaultCode) {
$path = $this->path . DS . $this->folder . DS . $name . '.md';
$exists = file_exists($path);
}
if ($exists) {
if ($includeUnpublished) {
continue;
}
$aPage = new Page();
$aPage->init(new \SplFileInfo($path), $languageCode . '.md');
if (!$aPage->published()) {
continue;
}
}
$untranslatedLanguages[] = $languageCode;
}
return $untranslatedLanguages;
return array_values(array_diff($languages, $translated));
}
/**