2

I was created simple custom module in magento 2.1. And it's working fine in magento 2.1.9.

But today I tried to installe in magento 2.2 and it's shows this error:

1 exception(s): Exception #0 (Magento\Framework\Config\Dom\ValidationException): Element 'item', attribute 'translate': The attribute 'translate' is not allowed. Line: 1920

Exception #0 (Magento\Framework\Config\Dom\ValidationException): Element 'item', attribute 'translate': The attribute 'translate' is not allowed. Line: 1920

Here is file where generate this error

<referenceBlock name="checkout.root">
    <arguments>
        ...
        ...
            <item name="fee" xsi:type="array">
                <item name="component"  xsi:type="string">Vendor_Module/js/view/checkout/cart/totals/myfile</item>
                <item name="config" xsi:type="array">
                    <item name="title" xsi:type="helper" translate="true" helper="Vendor\Module\Helper\Data::getCustomText"/>
                </item>
            </item>
        ...
        ...                    
    </arguments>
</referenceBlock>

1 Answer 1

4

You are not allowed to use translate attributes for <item> nodes that have xsi:type anything else other than string.
Just remove translate="true" from this line

<item name="title" xsi:type="helper" translate="true" helper="Vendor\Module\Helper\Data::getCustomText"/>
2
  • Thanks for replay. It's working if I remove translate="true". But it's working translation in multilanguage?
    – Rahul
    Nov 3, 2017 at 11:01
  • you should include the translation in your helper class. So this line of xml just returns the result of Vendor\Module\Helper\Data::getCustomText. use __('Text here') inside your getCustomText method and the text will be translated without the need of the translate tag,
    – Marius
    Nov 3, 2017 at 12:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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