0

Which part of code in Magento 2.4.5-p1 sets window.LOCALE ?

vendor/magento/module-catalog/view/base/web/js/price-utils.js defaults to en-US as in locale = window.LOCALE || 'en-US'; where window.LOCALE is my case is undefined.

But I see in Magento 2.4.5-p1 default installation that window.LOCALE is set to (e.g. fr-FR) what it seems I've configured in Admin > Stores > Configuration > General > Locale Options > Locale (fr_FR).

1 Answer 1

1

The window.LOCALE value is set by Magento's JavaScript initialization script located in

pub/static/frontend/[Vendor]/[theme]//requirejs-config.js.

When Magento initializes the JavaScript on a page, it includes this configuration file which sets various JavaScript configuration options, including the window.LOCALE value.

The requirejs-config.js file sets the value of window.LOCALE using the mage/cookies module, which retrieves the user's preferred language from a cookie named mage-translation-storage. This cookie is set when the user selects a language from the language switcher in the storefront or the backend of the site.

So in your case, since the window.LOCALE value is undefined, it may be that the mage-translation-storage cookie is not being set correctly. You can try clearing your browser cookies and refreshing the page to see if the issue resolves. Alternatively, you can check if the mage-translation-storage cookie is being set and if its value matches your desired locale.

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.