Fix multilanguage, make an example, fixes #416

This commit is contained in:
Stéphane Goetz 2017-01-10 10:28:58 +01:00
parent e831e75958
commit 97a4e73878
9 changed files with 22 additions and 6 deletions

View File

@ -0,0 +1,3 @@
This is our landing page.
Welcome to this awesome multilanguage documentation.

View File

@ -0,0 +1,9 @@
{
"title": "Multilanguage Example",
"tagline": "The Easiest Way To Document Your Project",
"languages": {
"en": "English",
"fr": "Français"
}
}

View File

@ -0,0 +1 @@
It starts here.

View File

@ -0,0 +1 @@
Some configuration options

View File

@ -0,0 +1 @@
C'est ici que tout commence.

View File

@ -0,0 +1 @@
Quelques options de configuration

View File

@ -229,7 +229,8 @@ class Daux
$this->tree = new Root($this->getParams()); $this->tree = new Root($this->getParams());
Builder::build($this->tree, $this->options['ignore']); Builder::build($this->tree, $this->options['ignore']);
if (!empty($this->options['languages'])) { // Apply the language name as Section title
if ($this->options->isMultilanguage()) {
foreach ($this->options['languages'] as $key => $node) { foreach ($this->options['languages'] as $key => $node) {
$this->tree->getEntries()[$key]->setTitle($node); $this->tree->getEntries()[$key]->setTitle($node);
} }

View File

@ -9,18 +9,17 @@ class ContentPage extends \Todaymade\Daux\Format\Base\ContentPage
private function isHomepage() private function isHomepage()
{ {
// If we don't have the auto_landing parameter, we don't want any homepage
if (array_key_exists('auto_landing', $this->params['html']) && !$this->params['html']['auto_landing']) { if (array_key_exists('auto_landing', $this->params['html']) && !$this->params['html']['auto_landing']) {
return false; return false;
} }
// If the current page isn't the index, no chance it is the landing page
if ($this->file->getParent()->getIndexPage() != $this->file) { if ($this->file->getParent()->getIndexPage() != $this->file) {
return false; return false;
} }
if ($this->params->isMultilanguage()) { // If the direct parent is root, this is the homage
return $this->file->getParent()->getParent() instanceof Root;
}
return $this->file->getParent() instanceof Root; return $this->file->getParent() instanceof Root;
} }

View File

@ -20,7 +20,7 @@
$path = ''; $path = '';
if ($page['language'] !== '') { if ($page['language'] !== '') {
$rendertree = $tree->value[$page['language']]; $rendertree = $tree[$page['language']];
$path = $page['language']; $path = $page['language'];
} }