Description
Preconditions (*)
- 2.2.3 (still present in 2.3-beta)
- Those sites which uses more than 1 stores (languages).
Steps to reproduce (*)
-
Setup a two-store site where the default store uses "en_Us" as the language and the second store uses "es_ES" (Spanish ).
-
Add Spanish translation for the text: "Not yet calculated" through the design section. i.e, in the file:
app/design/frontend/<Package>/<theme>/i18n/es_ES.csv
."Not yet calculated","Aún no calculado"
-
Now on the frontend, switch to Spanish store. Then add a product to the cart and go for checkout.
-
In the payment step, under the summary section, you will see "Not yet calculated" is not translated for the Tax eventhough the same text corresponding to Shipping is translated.
Expected result (*)
- In the summary section in the checkout, we should see
Aún no calculado
for the Tax total.
Actual result (*)
- But what we see there is
Not yet calculated
Why this is happened
The issue occured because of there is no translation applied for the text: "Not yet calculated" in the UiComponent Magento_Tax/js/view/checkout/summary/tax
.
This is how the text is called on the template. File: vendor/magento/module-tax/view/frontend/web/template/checkout/summary/tax.html
<!-- ko ifnot: isCalculated() -->
<span class="not-calculated" data-bind="text: getValue()"></span>
<!-- /ko -->
So getValue()
is providing the text here. So if we check in the component js file: vendor/magento/module-tax/view/frontend/web/js/view/checkout/summary/tax.js
return Component.extend({
defaults: {
...
notCalculatedMessage: 'Not yet calculated',
...
},
...
/**
* @return {*}
*/
getValue: function () {
var amount;
if (!this.isCalculated()) {
return this.notCalculatedMessage;
}
amount = totals.getSegment('tax').value;
return this.getFormattedPrice(amount);
},
....
As you can see the text does not have any translations applied.
How can fix this?
Apparently adding translation in the component will fix the issue. Example is shown:
File: vendor/magento/module-tax/view/frontend/web/js/view/checkout/summary/tax.js
define([
'ko',
'mage/translate',
'Magento_Checkout/js/view/summary/abstract-total',
'Magento_Checkout/js/model/quote',
'Magento_Checkout/js/model/totals'
], function (ko, $t, Component, quote, totals) {
return Component.extend({
defaults: {
notCalculatedMessage: $t('Not yet calculated'),
},
...
});
});
Awaiting the response. Thank you. :)