diff --git a/libraries/src/Document/HtmlDocument.php b/libraries/src/Document/HtmlDocument.php
index ed018d81a18bc..aaf3c1bde4341 100644
--- a/libraries/src/Document/HtmlDocument.php
+++ b/libraries/src/Document/HtmlDocument.php
@@ -775,9 +775,12 @@ protected function _fetchTemplate($params = [])
// 1.5 or core then 1.6
$lang->load('tpl_' . $template, JPATH_BASE)
- || ($inherits !== '' && $lang->load('tpl_' . $inherits, JPATH_BASE))
- || $lang->load('tpl_' . $template, $directory . '/' . $template)
- || ($inherits !== '' && $lang->load('tpl_' . $inherits, $directory . '/' . $inherits));
+ || $lang->load('tpl_' . $template, $directory . '/' . $template);
+
+ if ($inherits) {
+ $lang->load('tpl_' . $inherits, $directory . '/' . $inherits)
+ || $lang->load('tpl_' . $inherits, JPATH_BASE);
+ }
// Assign the variables
$this->baseurl = Uri::base(true);
diff --git a/libraries/src/MVC/View/HtmlView.php b/libraries/src/MVC/View/HtmlView.php
index a926f17fc6ea4..af7021c21f60c 100644
--- a/libraries/src/MVC/View/HtmlView.php
+++ b/libraries/src/MVC/View/HtmlView.php
@@ -369,16 +369,22 @@ public function loadTemplate($tpl = null)
$file = preg_replace('/[^A-Z0-9_\.-]/i', '', $file);
$tpl = isset($tpl) ? preg_replace('/[^A-Z0-9_\.-]/i', '', $tpl) : $tpl;
- try {
- // Load the language file for the template
- $lang = $this->getLanguage();
- } catch (\UnexpectedValueException $e) {
- $lang = Factory::getApplication()->getLanguage();
- }
+ if (Factory::getApplication()->getDocument()->getType() !== 'html') {
+ try {
+ // Load the language file for the template
+ $lang = $this->getLanguage();
+ } catch (\UnexpectedValueException $e) {
+ $lang = Factory::getApplication()->getLanguage();
+ }
+
+ $lang->load('tpl_' . $template->template, JPATH_BASE)
+ || $lang->load('tpl_' . $template->template, JPATH_THEMES . '/' . $template->template);
- $lang->load('tpl_' . $template->template, JPATH_BASE)
- || $lang->load('tpl_' . $template->parent, JPATH_THEMES . '/' . $template->parent)
- || $lang->load('tpl_' . $template->template, JPATH_THEMES . '/' . $template->template);
+ if ($template->parent) {
+ $lang->load('tpl_' . $template->parent, JPATH_THEMES . '/' . $template->parent)
+ || $lang->load('tpl_' . $template->parent, JPATH_BASE);
+ }
+ }
// Change the template folder if alternative layout is in different template
if (isset($layoutTemplate) && $layoutTemplate !== '_' && $layoutTemplate != $template->template) {