Localizing Template Resource Bundles

Template resource bundles hold static content for localization. They are stored for each cartridge within the /templates/resources directory. Messages from the bundles are accessible to all templates of the corresponding cartridge via the msg()method, available in the dw.web.Resource class.

Note: Content Warning: The content on this page necessarily engages with noninclusive language that can be emotionally and intellectually challenging.
Note: See the Salesforce B2C Commerce API documentation for more information.

These properties files have already been created for you in the SiteGenesis application. They each contain a list of text that pertains to its corresponding object (template or form) ). They are organized as a single properties file per top level directory.

Tip: If a valid localeID is set by the SendMail API pipelet, the locale is also used inside an email template to resolve localized messages by the Resource.msg() function based on the given locale. If you are using the dw.net.Mail class to send messages, the LocaleID set through Template.setLocaleId or the constructor Template(Template,LocaleID) is used to look up the template resource before the locale linked to the current request.

Account Example

For example, account.properties, which lists the text in the minicartcontent.isml template, looks like this:


	##############################################
	# ISML Directory: account/addressbook/
	##############################################
	editaddress.editaddress=Edit Address
	editaddress.addaddress=Add Address
	editaddress.defaultaddress=Default Address
	editaddress.makedefaultaddress=Make Default
Note: You can name the elements anything you want. In the SiteGenesis application, the elements are named after the files in which they are contained, followed by a descriptive string. For example, a resource bundle referenced in the editaddress.isml template would be editaddress.discriptivestring,

For any text to be included in the storefront using this methodology, you must create a new line within the corresponding language-specific properties file. These language files are named to correspond to the file directory of the language snippet to be used. Each text snippet has a unique key (unique across resource bundle files).

Comments

Comments are preceded by a # character.

For example, in the account.properties file, the text list is separated by the sub directories within the top level directories.

	############################################## 
	# ISML Directory: account/ 
	############################################## 
	accountoverview.welcome=Hello 
	accountoverview.welcome2=, Welcome Back 
	accountoverview.not=Are you not
 
	accountredirect.title=Redirect
	accountredirect.permanent=This account has been permanently removed. You can attempt to login with another account or create a new account by going to the
	accountredirect.accountlogin=login page. 
	account.forbidden=This page has timed out.  You must close the window and login to continue.
	account.createnew=Create Account
	account.editaccount=Edit Account
       
	############################################## 
	# ISML Directory: account/addressbook/ 
	############################################## 
	editaddress.editaddress=Edit Address 
	editaddress.addaddress=Add Address 
	editaddress.defaultaddress=Default Address
	editaddress.makedefaultaddress=Make Default

Properties with the sub directory would be separated, as shown previously.

Form Example

The following is an example of using properties within a German version of a form (forms/default/creditcard_de.xml - forms.properties):

	##############################################
	# Template name: forms/default/creditcard_de 
	##############################################
	creditcard.visa=Visa
	creditcard.mastercard=Mastercard
	creditcard.amex=Amex
	creditcard.discover=Discover
	creditcard.cvn=CVN
	creditcard.savecard=AuοΏ½er Dieser Kreditkarte
Note: Use the same pattern of appending the local identifier when creating of locale specific resource bundles (.properties) files. For example:
  • account_en_GB.properties
  • account_en_US.properties
  • account_en.properties