Translations Setup using Salesforce
The Storefront record must include the translation URL. On the Storefront record, set Translation URL = /apex/APTS_EcommerceTranslation. This URL points to a static page that contains all translations. See the example code snippet.
<apex:page contentType="application/json; charset=utf-8" language="{!$CurrentPage.parameters.language}">
{
"ERROR": {
"MIN-OPTIONS": "{!$Label.eCom_MIN_OPTIONS}",
"CART": {
"TOO_MANY_ATTEMPTS": "{!$Label.ecom_TOO_MANY_ATTEMPTS}",
"PRICE_CHANGE": "{!$Label.eCom_PRICE_CHANGE}",
"PRICE_CHANGE_TOASTR_TITLE": "{!$Label.eCom_PRICE_CHANGE_TOASTR_TITLE}"
},
"APPLICATION_ERROR_TOASTR_TITLE": "{!$Label.eCom_APPLICATION_ERROR_TOASTR_TITLE}"
},
"SUCCESS": {
"CART": {
"ITEM_ADDED_TOASTR_MESSAGE": "{!$Label.eCom_ITEM_ADDED_TOASTR_MESSAGE}",
"ITEM_ADDED_TOASTR_TITLE": "{!$Label.eCom_ITEM_ADDED_TOASTR_TITLE}"
}
},
"ASSETS": {
"CHANGECONFIGURATION_SUCCESS": "{!$Label.eCom_Assets_ChangeConfigurationSuccess}",
"CHANGECONFIGURATION_START_DATE": "{!$Label.eCom_Assets_ChangeConfigurationStartDate}",
"CHANGECONFIGURATION_END_DATE": "{!$Label.eCom_Assets_ChangeConfigurationEndDate}"
},
"MY_ACCOUNT": {
"LAST_LOGIN_DATE": "{!$Label.eCom_LAST_LOGIN_DATE}"
},
"BUTTON": {
"Change Configuration": "{!$Label.eCom_Button_ChangeConfiguration}"
},
"PRODUCT_CARD": {
"INSTALLED_PRODUCT": "{!$Label.eCom_PRODUCT_CARD_INSTALLED_PRODUCT}",
"STANDARD_PRICE": "{!$Label.eCom_PRODUCT_CARD_STANDARD_PRICE}"
},
"PAGINATION": {
"FIRST": "{!$Label.eCom_PAGINATION_FIRST}"
},
"COMMON": {
"ORDERS": "{!$Label.eCom_COMMON_ORDERS}",
"USERNAME": "{!$Label.eCom_COMMON_USERNAME}",
"QUANTITY": "{!$Label.eCom_COMMON_QUANTITY}",
"CHANGE_CONFIGURATION": "{!$Label.eCom_Common_ChangeConfiguration}",
"ADD_TO_CART": "{!$Label.eCom_Add_to_Cart}"
},
"CONSTRAINT_POPOVER": {
"PRODUCTS_INCLUDED_EXCLUDED_HEADING": "{!$Label.eCom_PRODUCTS_INCLUDED_EXCLUDED_HEADING}"
},
"CART": {
"PAYMENT": {
"PAYMENT_TITLE": "{!$Label.eCom_CART_PAYMENT_TITLE}"
},
"CART_SUMMARY": {
"QUANTITY": "{!$Label.eCom_CART_SUMMARY_QUANTITY}"
},
"CHECKOUT": "{!$Label.eCom_CHECKOUT}",
"BILLING_AND_SHIPPING_INFORMATION": "{!$Label.eCom_BILLING_AND_SHIPPING_INFORMATION}"
},
"MANAGE_CART": {
"CART_SUMMARY": {
"CART_SUMMARY_TITLE": "{!$Label.eCom_Cart_Summary_Title}",
"SUB_TOTAL": "{!$Label.eCom_Sub_Total}"
},
"CART_TABLE": {
"ITEMS_IN_YOURCART": "{!$Label.eCom_ITEMS_IN_YOUR_CART}"
}
},
"FOOTER": {
"PRODUCTS": "{!$Label.eCom_FOOTER_PRODUCTS}"
},
"HEADER": {
"SUBMIT": "{!$Label.eCom_HEADER_SUBMIT}",
"ENTER_YOUR_SEARCH_TERM": "{!$Label.eCom_ENTER_YOUR_SEARCH_TERM}",
"LAST_LOGIN": "{!$Label.eCom_HEADER_LAST_LOGIN}",
"HOME": "{!$Label.eCom_HEADER_HOME}",
"LOG_OUT": "{!$Label.eCom_HEADER_LOG_OUT}",
"LOG_IN": "{!$Label.eCom_HEADER_LOG_IN}"
},
"PROMOTION": {
"PROMO_CODE": "{!$Label.eCom_PROMOTION_PROMO_CODE}",
"PROMOTION_APPLIED": "{!$Label.eCom_PROMOTION_APPLIED}",
"APPLIED_PROMOTION": "{!$Label.eCom_APPLIED_PROMOTION}"
},
"LOGIN": {
"USERNAME": "{!$Label.eCom_LOGIN_USERNAME}",
"SIGN_IN": "{!$Label.eCom_LOGIN_SIGN_IN}",
"INCORRECT_CREDENTIALS_TOASTR_MESSAGE": "{!$Label.eCom_INCORRECT_CREDENTIALS_TOASTR_MESSAGE}"
},
"PRODUCT_DETAILS": {
"PRODUCT_DETAIL": "{!$Label.eCom_PRODUCT_DETAIL}",
"PRODUCT_CODE": "{!$Label.eCom_PRODUCT_CODE}",
"STANDARD_PRICE": "{!$Label.eCom_PRODUCT_DETAILS_STANDARD_PRICE}",
"UPDATE_CONFIGURATION": "{!$Label.eCom_PRODUCT_DETAILS_UPDATE_CONFIGURATION}"
},
"INSTALLED_PRODUCTS": {
"PRODUCT_FAMILY": "{!$Label.eCom_INSTALLED_PRODUCTS_PRODUCT_FAMILY}"
},
"MINI_CART": {
"YOUR_CART_IS_EMPTY": "{!$Label.eCom_MINI_CART_YOUR_CART_IS_EMPTY}"
}
}
</apex:page>Wherever you are displaying a label on the UI, a translation pipe is used.
This translation pipe calls the translation loader service, which uses the translation get method to look for the translation URL whether it is in the code base or defined on the storefront object. The translation get method looks at the URL, reads the file, gets all the key values, and displays the response on the template.
Defining Translations using Custom Labels
- Go to Setup > App Setup > Create and click Custom Labels.
- Click New Custom Label.
- Enter a Short Description for the custom label you are creating.
- Enter a Name for the custom label.
- The default language is English.
- In Categories, enter text to categorize the label.
- In the Value text box, enter text. This value can be translated into any language that Salesforce supports.
- Click Save.
Translations for Custom Labels
You translate custom labels to control the text displayed for users in different languages. This task helps you add or edit translations so that when a user's default language matches a translation, Salesforce displays the translated text instead of the default label value.
- Go to Setup > App Setup > Create and click Custom Labels.
- Select the name of the custom label to open.
- In the Translations related list, click New to enter a new translation or Edit next to the language to change a translation.
- Select the Language you are translating into.
- Enter the Translation Text. This text overrides the value specified in the label's Value field when a user's default language is the translation language.
- Click Save.
Define Translations for Custom Objects
Salesforce supports Product Translations, Category Translations, and Attribute Group Translations.
Defining Translations for Products
Now when you browse a product on the cart for which you have defined translations in Salesforce, the translated text is displayed.
For illustration purposes, the translated categories are prefixed with es_ in the above image. In the actual scenario, the correct language is displayed.
Similarly, you can define category translations.
Defining Translations for Categories
- Go to the Product tab, select a product for which you want to define the category translation.
- Go to the Categories related list and click the category classification Id.
- From the Product Classification page, click the Category or Go to the Categories tab and select the Category for which you want to define translations.
- From the Category Translations related list, click New Category Translation.
- Enter a Category Translation Name.
- Search and select the Category Hierarchy.
- Enter a Language and a Label.
- Select a currency.
- Click Save.
Defining Translations for Product Attribute Group
- Go to the Product Attribute Groups tab and select a product attribute group for which you want to define the attribute group translation.
- Go to the Attribute Group Translations related list and click New Attribute Group Translation.
- Enter a Translation Name.
- The Product Attribute Group field is already populated.
- In Name, enter the translated attribute group name.
- Enter a Language.
- Select a currency.
- Click Save.
