From 08e239fcf4cda7a475b5bdfea0ce0cf24a315b56 Mon Sep 17 00:00:00 2001 From: Andy Miller Date: Thu, 2 Jul 2015 15:53:05 -0600 Subject: [PATCH] Added lang template paths for theme by default --- system/src/Grav/Common/Twig.php | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/system/src/Grav/Common/Twig.php b/system/src/Grav/Common/Twig.php index 6a92f86a0..1a31be124 100644 --- a/system/src/Grav/Common/Twig.php +++ b/system/src/Grav/Common/Twig.php @@ -57,6 +57,7 @@ class Twig public function __construct(Grav $grav) { $this->grav = $grav; + $this->twig_paths = []; } /** @@ -72,7 +73,19 @@ class Twig $locator = $this->grav['locator']; $debugger = $this->grav['debugger']; - $this->twig_paths = $locator->findResources('theme://templates'); + /** @var Language $language */ + $language = $this->grav['language']; + + // handle language templates if available + if ($language->enabled()) { + $lang_templates = $locator->findResource('theme://templates/'.$language->getActive()); + if ($lang_templates) { + $this->twig_paths[] = $lang_templates; + } + } + + $this->twig_paths = array_merge($this->twig_paths, $locator->findResources('theme://templates')); + $this->grav->fireEvent('onTwigTemplatePaths'); $this->loader = new \Twig_Loader_Filesystem($this->twig_paths);