Cert++
Close

Resource bundles versus locale-specific templates for storefront text

Key Takeaway

Salesforce recommends one template set with its text in resource bundles. When a shopper's locale has no template folder, B2C Commerce uses the default template, and its messages fall back from the locale-specific folder to the language-specific folder, then to the default folder.

Storefront text, such as button labels and error messages, has to appear in the shopper's language. B2C Commerce gives developers two ways to do this. You can keep one template set and pull the text from translated properties files called resource bundles. You can also keep a separate copy of the templates for each locale. Salesforce recommends the single template set with resource bundles, and SFRA is built that way.

One template set or multiple template sets

With one template set, you move localizable strings out of the templates into resource bundles. The resource bundles are translated, not the templates. With multiple template sets, each locale of the storefront has its own copy of the templates in its own folder.

Salesforce recommends one template set as the best practice, for these reasons:

  • Templates, which can hold complex logic, don't change as text is localized.
  • The display logic lives in one template that isn't language-specific.
  • The strings sit in a simple file format you can send to translation providers.
  • You add a translation back by copying the translated file into the cartridge, without risk of breaking the logic.

A template set per locale has a real cost. Every change to the display logic must be made again in each locale-specific copy.

SFRA uses a single template set for all locales. Its templates reference text in the resource bundles by key. The storefront then uses a different translation of the properties file depending on the current locale. Projects typically start from SFRA code, so use this approach consistently.

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.