magento / magento2

Prior to making any Submission(s), you must sign an Adobe Contributor License Agreement, available here at: https://opensource.adobe.com/cla.html. All Submissions you make to Adobe Inc. and its affiliates, assigns and subsidiaries (collectively “Adobe”) are subject to the terms of the Adobe Contributor License Agreement.
http://www.magento.com
Open Software License 3.0
11.58k stars 9.32k forks source link

Magento 2.2.0: Translations for 'Item in Cart' missing in mini cart. #12081

Closed jhruehl closed 6 years ago

jhruehl commented 7 years ago

Since updating one of our stores to Magento 2.2 the translations for 'Item in Cart' are not compiled into the var/view_processed/pub/static/frontend/{Magento-Theme}/{language code}/js-translation.json files, though the translations for 'Items in Cart' are correctly loaded.

Preconditions

  1. Magento 2.2.0
  2. PHP 7.0 and 7.1 (different local setups and different testservers)
  3. MySQL 5.5.5-10.1.23-MariaDB

Steps to reproduce

  1. Have a store view in another language than en_US.
  2. Set a translation for 'Item in Cart' for that language.
  3. Open your store with the store view according to language, where you expect the translation to be done.
  4. Add exactly one item to your cart.
  5. Open the mini cart.

Expected result

  1. 'Item to Cart' translated to store view given language.

Actual result

  1. 'Item to Cart' is not translated.

Details

So the problem or at least a symptom of the problem seems to be in the 'vendor/magento/module-checkout/view/frontend/web/template/minicart/content.html' template. Strangely not all 'translate'-nodes are triggering the Magento 2 Content Compiler to actually set the requested translations into the theme and language given js-translations.json files. Though the lines 33 - <translate args="'Item in Cart'" if="getCartLineItemsCount() === 1"/> and 34 - <translate args="'Items in Cart'" if="getCartLineItemsCount() > 1"/> are almost completely identical, the translations for 'Items in Cart' are loaded, but not for 'Item in Cart'.

magento-engcom-team commented 7 years ago

@jhruehl, thank you for your report. We've created internal ticket(s) MAGETWO-83448 to track progress on the issue.

avestique commented 7 years ago

The problem is that there was not js translation before <translate> tag.

I solved it temporary by overriding template src/vendor/magento/module-checkout/view/frontend/web/template/minicart/content.html

and add there js translation:

<div class="items-total"> to 
<div class="items-total" data-translate-hidden="attr: { item_in_cart: $t('Item in Cart') }"

you can use any name for attribute here.

This solution works for me.

emmathepossum commented 7 years ago

@avestique Unfortunately your solution doesn't work for me.

The translation also doesn't work in the checkout. The code is the same:

magento/module-checkout/view/frontend/web/template/summary/cart-items.html

<strong role="heading">
    <translate args="maxCartItemsToDisplay" if="maxCartItemsToDisplay < getCartLineItemsCount()"/>
    <translate args="'of'" if="maxCartItemsToDisplay < getCartLineItemsCount()"/>
    <span data-bind="text: getCartLineItemsCount()"></span>
    <translate args="'Item in Cart'" if="getCartLineItemsCount() === 1"/>
    <translate args="'Items in Cart'" if="getCartLineItemsCount() > 1"/>
</strong>
jhruehl commented 7 years ago

Ok. A quite easy temporary solution, to get the missing js translations actually compiled and loaded, is to create an extension, which adds a basic js file to the head via view/frontend/layout/default.xml: `

Githubissues.
  • Githubissues is a development platform for aggregating issues.