Skip to content
This repository has been archived by the owner on Feb 23, 2024. It is now read-only.

Correctly load JS translations from WC core #5910

Merged
merged 2 commits into from
Feb 24, 2022

Conversation

Aljullu
Copy link
Contributor

@Aljullu Aljullu commented Feb 21, 2022

While doing some testing, I noticed translations of JS files were not correctly loaded in some locales. The locale needed to have the strings translated in WC core but not in WC Blocks.

Manual Testing

  1. Go to Settings > General > Language (/wp-admin/options-general.php) and select a language which has WC core translation at 100% but WC Blocks' at 0%. (I tested with Català).
  2. Go to the updates screen (/wp-admin/update-core.php), scroll down and update the language translations.
  3. Visit the Cart or Checkout block in the frontend and verify the texts are translated.
Before After
imatge imatge
  1. Switch to a language where WC core translations already exist (ie: Deutsch, Español or Français) and verify translations are still loaded correctly (you will need to go to the updates screen again).

Changelog

Fix loading WC core translations in locales where WC Blocks is not localized for some strings.

@Aljullu Aljullu added type: bug The issue/PR concerns a confirmed bug. focus: i18n The issue/PR is related to internationalization. block: cart Issues related to the cart block. block: checkout Issues related to the checkout block. labels Feb 21, 2022
@rubikuserbot rubikuserbot requested review from a team and frontdevde and removed request for a team February 21, 2022 15:41
@Aljullu Aljullu requested review from mikejolley and removed request for frontdevde February 21, 2022 15:41
@Aljullu
Copy link
Contributor Author

Aljullu commented Feb 21, 2022

Since this is Cart & Checkout related, I assigned it to you (@mikejolley) for review. Hope you don't mind. 🙂

@github-actions
Copy link
Contributor

github-actions bot commented Feb 21, 2022

Size Change: -1.78 kB (0%)

Total Size: 815 kB

Filename Size Change
build/active-filters.js 6.95 kB +3 B (0%)
build/all-products-frontend.js 18.6 kB -82 B (0%)
build/all-products.js 34.2 kB -6 B (0%)
build/all-reviews.js 8.06 kB +4 B (0%)
build/atomic-block-components/add-to-cart--atomic-block-components/button--atomic-block-components/catego--214e300a.js 152 B +1 B (+1%)
build/atomic-block-components/add-to-cart--atomic-block-components/button--atomic-block-components/image---a7e2bb9b.js 2.66 kB -63 B (-2%)
build/atomic-block-components/add-to-cart-frontend.js 7.02 kB +13 B (0%)
build/atomic-block-components/add-to-cart.js 7.5 kB -6 B (0%)
build/atomic-block-components/button-frontend.js 1.53 kB -1 B (0%)
build/atomic-block-components/button.js 2.15 kB -3 B (0%)
build/atomic-block-components/category-list--atomic-block-components/image--atomic-block-components/ratin--2614069e.js 498 B +26 B (+6%) 🔍
build/atomic-block-components/category-list-frontend.js 922 B +26 B (+3%)
build/atomic-block-components/category-list.js 501 B +1 B (0%)
build/atomic-block-components/image-frontend.js 1.86 kB +26 B (+1%)
build/atomic-block-components/image.js 1.49 kB +3 B (0%)
build/atomic-block-components/price-frontend.js 1.74 kB -4 B (0%)
build/atomic-block-components/price.js 1.7 kB +2 B (0%)
build/atomic-block-components/rating-frontend.js 1.13 kB +23 B (+2%)
build/atomic-block-components/sale-badge-frontend.js 1.09 kB +23 B (+2%)
build/atomic-block-components/sale-badge.js 686 B +1 B (0%)
build/atomic-block-components/sku.js 385 B -1 B (0%)
build/atomic-block-components/stock-indicator-frontend.js 1.04 kB +27 B (+3%)
build/atomic-block-components/summary-frontend.js 1.34 kB +28 B (+2%)
build/atomic-block-components/summary.js 924 B +1 B (0%)
build/atomic-block-components/tag-list-frontend.js 922 B +27 B (+3%)
build/atomic-block-components/title-frontend.js 1.31 kB +25 B (+2%)
build/attribute-filter-frontend.js 16.8 kB +32 B (0%)
build/attribute-filter.js 13.1 kB +27 B (0%)
build/blocks-checkout.js 17.2 kB -363 B (-2%)
build/cart-blocks/accepted-payment-methods-frontend.js 1.14 kB -1 B (0%)
build/cart-blocks/checkout-button-frontend.js 1.15 kB +1 B (0%)
build/cart-blocks/empty-cart-frontend.js 346 B +1 B (0%)
build/cart-blocks/express-payment-frontend.js 5.19 kB +1 B (0%)
build/cart-blocks/filled-cart-frontend.js 765 B -2 B (0%)
build/cart-blocks/items-frontend.js 299 B +1 B (0%)
build/cart-blocks/line-items-frontend.js 5.5 kB -2 B (0%)
build/cart-blocks/order-summary-frontend.js 8.88 kB +12 B (0%)
build/cart-blocks/totals-frontend.js 320 B -1 B (0%)
build/cart-frontend.js 45.2 kB -317 B (-1%)
build/cart.js 43.4 kB -319 B (-1%)
build/checkout-blocks/actions-frontend.js 1.41 kB -1 B (0%)
build/checkout-blocks/billing-address--checkout-blocks/shipping-address-frontend.js 4.12 kB -98 B (-2%)
build/checkout-blocks/billing-address-frontend.js 890 B +3 B (0%)
build/checkout-blocks/contact-information-frontend.js 2.84 kB -102 B (-3%)
build/checkout-blocks/express-payment-frontend.js 5.48 kB -2 B (0%)
build/checkout-blocks/fields-frontend.js 343 B -1 B (0%)
build/checkout-blocks/order-note-frontend.js 1.13 kB -2 B (0%)
build/checkout-blocks/order-summary-frontend.js 11.3 kB +22 B (0%)
build/checkout-blocks/payment-frontend.js 7.76 kB +4 B (0%)
build/checkout-blocks/shipping-address-frontend.js 997 B +23 B (+2%)
build/checkout-blocks/shipping-methods-frontend.js 4.73 kB -79 B (-2%)
build/checkout-blocks/terms-frontend.js 1.22 kB +3 B (0%)
build/checkout-frontend.js 47.4 kB -303 B (-1%)
build/checkout.js 44.8 kB -410 B (-1%)
build/featured-category.js 8.62 kB +16 B (0%)
build/featured-product.js 9.72 kB +97 B (+1%)
build/handpicked-products.js 7.09 kB +1 B (0%)
build/mini-cart-component-frontend.js 14.3 kB -58 B (0%)
build/mini-cart-contents.js 3.83 kB -9 B (0%)
build/mini-cart.js 6.39 kB +2 B (0%)
build/price-filter-frontend.js 12.5 kB -98 B (-1%)
build/price-filter.js 8.48 kB +4 B (0%)
build/price-format.js 1.19 kB +1 B (0%)
build/product-best-sellers.js 7.37 kB +5 B (0%)
build/product-category.js 8.49 kB +3 B (0%)
build/product-new.js 7.67 kB +2 B (0%)
build/product-on-sale.js 7.99 kB +3 B (0%)
build/product-search.js 2.18 kB -1 B (0%)
build/product-tag.js 7.81 kB +1 B (0%)
build/product-top-rated.js 7.9 kB +5 B (0%)
build/products-by-attribute.js 8.39 kB +1 B (0%)
build/reviews-by-category.js 11.5 kB +4 B (0%)
build/reviews-frontend.js 7.34 kB -5 B (0%)
build/single-product-frontend.js 22 kB -63 B (0%)
build/single-product.js 10 kB +1 B (0%)
build/stock-filter-frontend.js 6.49 kB -8 B (0%)
build/vendors--atomic-block-components/add-to-cart--cart-blocks/order-summary--checkout-blocks/billing-ad--c5eb4dcd-frontend.js 19 kB -1 B (0%)
build/vendors--atomic-block-components/add-to-cart-frontend.js 7.51 kB -1 B (0%)
build/vendors--atomic-block-components/price--cart-blocks/line-items--cart-blocks/order-summary--checkout--8a3571de-frontend.js 5.26 kB -450 B (-8%)
build/vendors--cart-blocks/order-summary--checkout-blocks/billing-address--checkout-blocks/order-summary---eb4d2cec-frontend.js 4.75 kB +2 B (0%)
build/wc-blocks-data.js 9.78 kB +941 B (+11%) ⚠️
build/wc-blocks-editor-style-rtl.css 4.84 kB -15 B (0%)
build/wc-blocks-editor-style.css 4.84 kB -13 B (0%)
build/wc-blocks-middleware.js 953 B +4 B (0%)
build/wc-blocks-registry.js 2.7 kB -1 B (0%)
build/wc-blocks-shared-hocs.js 1.14 kB +4 B (0%)
build/wc-blocks-style-rtl.css 22.2 kB +4 B (0%)
build/wc-blocks-style.css 22.2 kB +4 B (0%)
build/wc-blocks-vendors.js 69.3 kB -377 B (-1%)
build/wc-blocks.js 2.62 kB -2 B (0%)
build/wc-settings.js 2.61 kB -1 B (0%)
ℹ️ View Unchanged
Filename Size
build/active-filters-frontend.js 6.27 kB
build/atomic-block-components/add-to-cart--atomic-block-components/category-list--atomic-block-components--68f6c1c4.js 203 B
build/atomic-block-components/rating.js 719 B
build/atomic-block-components/sku-frontend.js 386 B
build/atomic-block-components/stock-indicator.js 624 B
build/atomic-block-components/tag-list.js 499 B
build/atomic-block-components/title.js 933 B
build/checkout-blocks/totals-frontend.js 323 B
build/legacy-template.js 2.18 kB
build/mini-cart-frontend.js 1.71 kB
build/product-categories.js 3.17 kB
build/reviews-by-product.js 12.6 kB
build/stock-filter.js 6.58 kB
build/vendors--cart-blocks/line-items--checkout-blocks/order-summary-frontend.js 3.14 kB
build/wc-blocks-google-analytics.js 1.56 kB
build/wc-blocks-shared-context.js 1.52 kB
build/wc-blocks-vendors-style-rtl.css 1.28 kB
build/wc-blocks-vendors-style.css 1.28 kB
build/wc-payment-method-bacs.js 816 B
build/wc-payment-method-cheque.js 811 B
build/wc-payment-method-cod.js 909 B
build/wc-payment-method-paypal.js 837 B

compressed-size-action

@Aljullu Aljullu self-assigned this Feb 22, 2022
Copy link
Member

@mikejolley mikejolley left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @Aljullu Code looks good but there was an issue causing translations not to work because the scripts were output too early. I added the wp-i18n dependency which fixed it.

@github-actions github-actions bot added this to the 7.1.0 milestone Feb 23, 2022
@Aljullu Aljullu merged commit 5d1e966 into trunk Feb 24, 2022
@Aljullu Aljullu deleted the fix/correctly-load-js-translations-from-core branch February 24, 2022 11:37
tarhi-saad pushed a commit that referenced this pull request Feb 26, 2022
* Correctly load JS translations from WC core

* Needs wp-i18n dependency to load later

Co-authored-by: Mike Jolley <[email protected]>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
block: cart Issues related to the cart block. block: checkout Issues related to the checkout block. focus: i18n The issue/PR is related to internationalization. type: bug The issue/PR concerns a confirmed bug.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants