diff --git a/administrator/components/com_templates/models/template.php b/administrator/components/com_templates/models/template.php
index 8133316d81f75..d2a19763cc548 100644
--- a/administrator/components/com_templates/models/template.php
+++ b/administrator/components/com_templates/models/template.php
@@ -187,7 +187,7 @@ public function &getTemplate()
// Get the template information.
$query = $db->getQuery(true)
- ->select('extension_id, client_id, element, name')
+ ->select('extension_id, client_id, element, name, manifest_cache')
->from('#__extensions')
->where($db->quoteName('extension_id') . ' = ' . (int) $pk)
->where($db->quoteName('type') . ' = ' . $db->quote('template'));
@@ -325,10 +325,12 @@ protected function fixTemplateName()
{
// Rename Language files
// Get list of language files
- $result = true;
- $files = JFolder::files($this->getState('to_path'), '.ini', true, true);
- $newName = strtolower($this->getState('new_name'));
- $oldName = $this->getTemplate()->element;
+ $result = true;
+ $files = JFolder::files($this->getState('to_path'), '.ini', true, true);
+ $newName = strtolower($this->getState('new_name'));
+ $template = $this->getTemplate();
+ $oldName = $template->element;
+ $manifest = json_decode($template->manifest_cache);
jimport('joomla.filesystem.file');
@@ -344,7 +346,7 @@ protected function fixTemplateName()
if (JFile::exists($xmlFile))
{
$contents = file_get_contents($xmlFile);
- $pattern[] = '#\s*' . $oldName . '\s*#i';
+ $pattern[] = '#\s*' . $manifest->name . '\s*#i';
$replace[] = '' . $newName . '';
$pattern[] = '##';
$replace[] = '';