From 97a4e7387844bd987efe315947ff459e5f014201 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ste=CC=81phane=20Goetz?= Date: Tue, 10 Jan 2017 10:28:58 +0100 Subject: [PATCH] Fix multilanguage, make an example, fixes #416 --- examples/multilanguage/_index.md | 3 +++ examples/multilanguage/config.json | 9 +++++++++ examples/multilanguage/en/00_Getting_Started.md | 1 + examples/multilanguage/en/Configuration/Options.md | 1 + examples/multilanguage/fr/00_Commencer.md | 1 + examples/multilanguage/fr/Configuration/Options.md | 1 + libs/Daux.php | 3 ++- libs/Format/HTML/ContentPage.php | 7 +++---- templates/layout/05_page.php | 2 +- 9 files changed, 22 insertions(+), 6 deletions(-) create mode 100644 examples/multilanguage/_index.md create mode 100644 examples/multilanguage/config.json create mode 100644 examples/multilanguage/en/00_Getting_Started.md create mode 100644 examples/multilanguage/en/Configuration/Options.md create mode 100644 examples/multilanguage/fr/00_Commencer.md create mode 100644 examples/multilanguage/fr/Configuration/Options.md diff --git a/examples/multilanguage/_index.md b/examples/multilanguage/_index.md new file mode 100644 index 00000000..bb38d90d --- /dev/null +++ b/examples/multilanguage/_index.md @@ -0,0 +1,3 @@ +This is our landing page. + +Welcome to this awesome multilanguage documentation. diff --git a/examples/multilanguage/config.json b/examples/multilanguage/config.json new file mode 100644 index 00000000..43c5c53f --- /dev/null +++ b/examples/multilanguage/config.json @@ -0,0 +1,9 @@ +{ + "title": "Multilanguage Example", + "tagline": "The Easiest Way To Document Your Project", + + "languages": { + "en": "English", + "fr": "Français" + } +} diff --git a/examples/multilanguage/en/00_Getting_Started.md b/examples/multilanguage/en/00_Getting_Started.md new file mode 100644 index 00000000..834f612b --- /dev/null +++ b/examples/multilanguage/en/00_Getting_Started.md @@ -0,0 +1 @@ +It starts here. diff --git a/examples/multilanguage/en/Configuration/Options.md b/examples/multilanguage/en/Configuration/Options.md new file mode 100644 index 00000000..1c8c6b43 --- /dev/null +++ b/examples/multilanguage/en/Configuration/Options.md @@ -0,0 +1 @@ +Some configuration options diff --git a/examples/multilanguage/fr/00_Commencer.md b/examples/multilanguage/fr/00_Commencer.md new file mode 100644 index 00000000..ca047ef0 --- /dev/null +++ b/examples/multilanguage/fr/00_Commencer.md @@ -0,0 +1 @@ +C'est ici que tout commence. diff --git a/examples/multilanguage/fr/Configuration/Options.md b/examples/multilanguage/fr/Configuration/Options.md new file mode 100644 index 00000000..88709d0f --- /dev/null +++ b/examples/multilanguage/fr/Configuration/Options.md @@ -0,0 +1 @@ +Quelques options de configuration diff --git a/libs/Daux.php b/libs/Daux.php index 65e74eb3..9a561069 100644 --- a/libs/Daux.php +++ b/libs/Daux.php @@ -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); } diff --git a/libs/Format/HTML/ContentPage.php b/libs/Format/HTML/ContentPage.php index 04bc6504..e07aac76 100644 --- a/libs/Format/HTML/ContentPage.php +++ b/libs/Format/HTML/ContentPage.php @@ -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; } diff --git a/templates/layout/05_page.php b/templates/layout/05_page.php index 600ef684..ac680d1b 100755 --- a/templates/layout/05_page.php +++ b/templates/layout/05_page.php @@ -20,7 +20,7 @@ $path = ''; if ($page['language'] !== '') { - $rendertree = $tree->value[$page['language']]; + $rendertree = $tree[$page['language']]; $path = $page['language']; }