yireo / magento2-translatabletitle
Magento 2 extension to make plain string page titles translatable in the frontend
Package info
github.com/yireo/Yireo_TranslatableTitle
Type:magento2-module
pkg:composer/yireo/magento2-translatabletitle
Requires
- php: >=8.2 <8.6
- magento/framework: ^100.1|^101.0|^102.0|^103.0
- magento/module-store: ^101.1
Requires (Dev)
- phpunit/phpunit: ^10.5
- yireo/magento2-integration-test-helper: ~0.0.23
Suggests
None
Provides
None
Conflicts
None
Replaces
None
This package is auto-updated.
Last update: 2026-12-01 22:08:11 UTC
README
Magento 2 extension to make page titles that are set as plain strings translatable in the frontend.
Backgrounds
Magento core already makes page titles defined in XML layout translatable:
<page>
<head>
<title>Example</title>
</head>
</page>
However, titles that are set at runtime as plain strings ($pageConfig->getTitle()->set('Example')) are not translated. This
module adds a plugin to Magento\Framework\View\Page\Title::set() that wraps such strings in a Phrase, so that they are
translated when the title is rendered.
The plugin is only active in the frontend area. Titles that already are a Phrase are left untouched, so that they are
not translated twice. Empty strings and non-string values are left untouched as well.
The page heading (<h1>) is translated by the core block Magento\Theme\Block\Html\Title itself, depending on the
setting design/header/translate_title. This module therefore returns the original text for the page heading, so that
the heading is translated only once and the setting is respected.
Installation
To install this extension, use the following command:
composer require yireo/magento2-translatabletitle
Afterwards, enable this module, run the setup scripts and flush the cache:
./bin/magento module:enable Yireo_TranslatableTitle
./bin/magento setup:upgrade
Status
Stable