cancel
Showing results for 
Search instead for 
Did you mean: 

Title tag in layout is not translated

Title tag in layout is not translated

Hello, I don't know if this a bug, but title tag in layout is not translated.

 

For example, 

 

<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="1column" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
    <head>
        <title>Forgot Your Password</title>
    </head>
    <body>....</body>
</page>

Can you confirm if this a bug or not?

 

Thanks

Jaime

1 REPLY 1

Re: Title tag in layout is not translated

I use the following fix for this bug. You have to override Magento 2 Page renderer. Create a model file in your module `Company/Module/Model/Page/Renderer.php`:

 

<?php

namespace Company\Module\Model\Page;
class Renderer extends \Magento\Framework\View\Page\Config\Renderer {
/**
* @return string
*/
public function renderTitle()
{
return '<title>' . $this->escaper->escapeHtml(__($this->pageConfig->getTitle()->get())) . '</title>' . "\n";
}
}

And then add a following line to the `etc/frontend/di.xml` file:

<preference for="Magento\Framework\View\Page\Config\Renderer" type="Company\Module\Model\Page\Renderer" />