Skip to content

Commit

Permalink
Fix multilanguage, make an example, fixes #416
Browse files Browse the repository at this point in the history
  • Loading branch information
onigoetz committed Jan 10, 2017
1 parent e831e75 commit 97a4e73
Show file tree
Hide file tree
Showing 9 changed files with 22 additions and 6 deletions.
3 changes: 3 additions & 0 deletions examples/multilanguage/_index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
This is our landing page.

Welcome to this awesome multilanguage documentation.
9 changes: 9 additions & 0 deletions examples/multilanguage/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"title": "Multilanguage Example",
"tagline": "The Easiest Way To Document Your Project",

"languages": {
"en": "English",
"fr": "Français"
}
}
1 change: 1 addition & 0 deletions examples/multilanguage/en/00_Getting_Started.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
It starts here.
1 change: 1 addition & 0 deletions examples/multilanguage/en/Configuration/Options.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Some configuration options
1 change: 1 addition & 0 deletions examples/multilanguage/fr/00_Commencer.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
C'est ici que tout commence.
1 change: 1 addition & 0 deletions examples/multilanguage/fr/Configuration/Options.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Quelques options de configuration
3 changes: 2 additions & 1 deletion libs/Daux.php
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,8 @@ public function generateTree()
$this->tree = new Root($this->getParams());
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) {
$this->tree->getEntries()[$key]->setTitle($node);
}
Expand Down
7 changes: 3 additions & 4 deletions libs/Format/HTML/ContentPage.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,17 @@ class ContentPage extends \Todaymade\Daux\Format\Base\ContentPage

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']) {
return false;
}

// If the current page isn't the index, no chance it is the landing page
if ($this->file->getParent()->getIndexPage() != $this->file) {
return false;
}

if ($this->params->isMultilanguage()) {
return $this->file->getParent()->getParent() instanceof Root;
}

// If the direct parent is root, this is the homage
return $this->file->getParent() instanceof Root;
}

Expand Down
2 changes: 1 addition & 1 deletion templates/layout/05_page.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
$path = '';

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

Expand Down

0 comments on commit 97a4e73

Please sign in to comment.