1

I have 2 store views (english and another language) in one of my Magento 2 projects.

The problem I'm facing is that one of the categories has the name "Role", which is also an English word.

So when I visit the category view page the category title gets translated to the other language's equivalent of the word "Role".

Shouldn't page/category headings be non-translatable through the built-in CSV translation mechanism that Magento provides?

I mean they already are translatable through the Admin store view functionality...

In any case, I've tracked this down to Magento_Theme::html/title.phtml and the function getPageHeading() in module-theme/Block/Html/Title.php

public function getPageHeading()
    {
        if (!empty($this->pageTitle)) {
            return __($this->pageTitle);
        }
        return __($this->pageConfig->getTitle()->getShortHeading());
    }

Is it possible to disable the translation via catalog_category_view.xml with a referenceBlock name="page.main.title"?

The only solution I can think of atm is to remove the page.main.title block from category view pages and add the non-translated title in Magento_Catalog::product/list.phtml.

EDIT

I fixed this temporarily by removing the page.main.title block and inserting this to list.phtml:

$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$category = $objectManager->get('Magento\Framework\Registry')->registry('current_category');

if ($category) { ?>
    <h1><?php echo $category->getName(); ?></h1>
<?php } ?>

But this isn't the best solution...

Seems like a Magento 2.2. bug to me.

Any suggestions would be appreciated.

  • You can achieve this by edit the category storewise and add the category name according to store language – Purushotam Sharma Mar 1 '18 at 13:27
  • @PurushotamSharma If I understand you correctly, you mean through the Admin? The categories are already properly named (translated) there. The problem happens only on the frontend - on the category view page of the category "Role" - which gets translated, because "Role" is also an english word and is translated in CSV. – Lez Mar 1 '18 at 13:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.