3

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>
asked Nov 2, 2017 at 11:30

1 Answer 1

5

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"/>
answered Nov 2, 2017 at 12:00
2
  • Thanks for replay. It's working if I remove translate="true". But it's working translation in multilanguage? Commented 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, Commented Nov 3, 2017 at 12:07

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.