From f56b4ca1ea1b32c8e12cf4a9d293e726ec2fa981 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Tylek?= Date: Wed, 13 Nov 2019 15:36:28 +0100 Subject: [PATCH 01/19] M2C-22090 Translate wishlist and counter label in template --- .../Catalog/CustomerData/CompareProducts.php | 1 - .../templates/product/compare/link.phtml | 12 +++++++++++- .../templates/product/compare/sidebar.phtml | 12 +++++++++++- .../Magento/Wishlist/CustomerData/Wishlist.php | 18 +----------------- .../view/frontend/templates/link.phtml | 10 +++++++++- .../view/frontend/templates/sidebar.phtml | 10 +++++++++- 6 files changed, 41 insertions(+), 22 deletions(-) diff --git a/app/code/Magento/Catalog/CustomerData/CompareProducts.php b/app/code/Magento/Catalog/CustomerData/CompareProducts.php index afbeab8c9070e..2c2715d46559e 100644 --- a/app/code/Magento/Catalog/CustomerData/CompareProducts.php +++ b/app/code/Magento/Catalog/CustomerData/CompareProducts.php @@ -47,7 +47,6 @@ public function getSectionData() $count = $this->helper->getItemCount(); return [ 'count' => $count, - 'countCaption' => $count == 1 ? __('1 item') : __('%1 items', $count), 'listUrl' => $this->helper->getListUrl(), 'items' => $count ? $this->getItems() : [], ]; diff --git a/app/code/Magento/Catalog/view/frontend/templates/product/compare/link.phtml b/app/code/Magento/Catalog/view/frontend/templates/product/compare/link.phtml index 05a5649135ef5..5c0267bd339ca 100644 --- a/app/code/Magento/Catalog/view/frontend/templates/product/compare/link.phtml +++ b/app/code/Magento/Catalog/view/frontend/templates/product/compare/link.phtml @@ -11,7 +11,17 @@ data-bind="attr: {'href': compareProducts().listUrl}, css: {'no-display': !compareProducts().count}" > escapeHtml(__('Compare Products')) ?> - + + + + + escapeHtmlAttr(__(' item')) ?> + + + escapeHtmlAttr(__(' items')) ?> + + + diff --git a/app/code/Magento/Catalog/view/frontend/templates/product/compare/sidebar.phtml b/app/code/Magento/Catalog/view/frontend/templates/product/compare/sidebar.phtml index cc95ae9168558..10bd94dcbc824 100644 --- a/app/code/Magento/Catalog/view/frontend/templates/product/compare/sidebar.phtml +++ b/app/code/Magento/Catalog/view/frontend/templates/product/compare/sidebar.phtml @@ -17,14 +17,8 @@ $viewModel = $block->getData('compare_view_model'); escapeHtml(__('Compare Products')) ?> - - - - escapeHtmlAttr(__(' item')) ?> - - - escapeHtmlAttr(__(' items')) ?> - + + diff --git a/app/code/Magento/Catalog/view/frontend/web/js/view/compare-products.js b/app/code/Magento/Catalog/view/frontend/web/js/view/compare-products.js index 5b73f477dea63..5c333deee91ea 100644 --- a/app/code/Magento/Catalog/view/frontend/web/js/view/compare-products.js +++ b/app/code/Magento/Catalog/view/frontend/web/js/view/compare-products.js @@ -7,9 +7,10 @@ define([ 'uiComponent', 'Magento_Customer/js/customer-data', 'jquery', + 'mage/translate', 'mage/mage', 'mage/decorate' -], function (Component, customerData, $) { +], function (Component, customerData, $, $t) { 'use strict'; var sidebarInitialized = false; @@ -33,6 +34,15 @@ define([ this.compareProducts = customerData.get('compare-products'); initSidebar(); - } + }, + getCounterLabel: function () { + var counter = this.compareProducts().count; + + if (counter === 1) { + return counter + ' ' + $t('item'); + } else { + return $t('%1 items').replace('%1', counter); + } + }, }); }); diff --git a/app/code/Magento/Wishlist/view/frontend/templates/link.phtml b/app/code/Magento/Wishlist/view/frontend/templates/link.phtml index 6c9b3a0b1ef81..6adab82260ab8 100644 --- a/app/code/Magento/Wishlist/view/frontend/templates/link.phtml +++ b/app/code/Magento/Wishlist/view/frontend/templates/link.phtml @@ -9,21 +9,15 @@