Cert++
Close

Setting and switching the request locale in storefront code

Key Takeaway

Each storefront request runs in one locale, which comes from the URL. request.setLocale() changes it only when the locale is valid, active, and allowed for the current site. If any of those fails, the call returns false and the request keeps its locale.

In B2C Commerce, every storefront request runs in one locale, such as en_US or fr. That request locale decides which translated strings, templates, static files, product data and currency the shopper sees. Storefront code reads the current locale and can switch the request to another locale. It also builds the links that let shoppers switch, by pointing each link at a URL for a different allowed locale.

What a locale is

en is a language-specific locale. en_US means English in the United States. en_IE means English in Ireland. Locale IDs combine an ISO 639 language code with an ISO 3166 country code.

B2C Commerce Developer Study Guide

Checklist progress

0/237Learned

Given localization requirements, implement and enhance templates, form definitions, static files, properties files, and persistent object attributes to ensure that pages are displayed in the expected language

0/8

Prepare for the Exam

Play Today's Certle

Study Community

Ask questions and get the latest info from other B2C Commerce Developer studiers.