2

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.

2
  • You can achieve this by edit the category storewise and add the category name according to store language Mar 1, 2018 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, 2018 at 13:48

1 Answer 1

1

You can enable / disable title translations in theme configuration:

Content -> Design -> Configuration -> Header -> Translate title (yes/no)

This option is available in Magento 2.4.x but not in the 2.3 line

1
  • Thanks, you made my day!! Jan 20 at 12:45

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.