Custom Labels In Salesforce
In this blog we are going to learn about custom labels in salesforce. If you want to translate the language of visualforce page then you must be knowing about custom labels and its implementation in salesforce.
Prerequisites
Before proceed you must enable the translation workbench and add the supported language. To enable the translation workbench go through Translation Workbench In Salesforce.
Custom Labels
–> Custom labels are simple text values which is used by user to translate in any salesforce supported language.
–> It present the information in user native language.
–> It can be used in salesforce visualforce page by three ways.
- In Visualforce Page
- In Apex Class
- In JavaScript
Example:
Let’s see an example to use it.
Step 1: First create custom labels for the content. Goto||Setup||Create||Custom Labels.
Step 2: Create visualforce page and apex class to show the label as shown in below code.
# Visualforce Page Code
<apex:page language="de" controller="exampleCustomLabel"> <!-- /** * Webkul Software. * * @category Webkul * @author Webkul * @copyright Copyright (c) 2010-2016 Webkul Software Private Limited (https://webkul.com) * @license https://store.webkul.com/license.html */ --> <!-- If your org has a name space $Label.namespace.labelName --> <apex:form> <p > Render By Visualforce Page : {!$Label.German} </p> <p > Render By Apex Class : {!cstmLabel} </p> </apex:form> </apex:page>
# Apex Class :
public class exampleCustomLabel { /** * Webkul Software. * * @category Webkul * @author Webkul * @copyright Copyright (c) 2010-2016 Webkul Software Private Limited (https://webkul.com) * @license https://store.webkul.com/license.html */ public String cstmLabel {get; set;} public exampleCustomLabel () { // If you have namespace use System.Label.your_namespace.label_name // Here German is custom label name cstmLabel = System.Label.German; } }
Support
That’s all for Custom Labels In Salesforce, still if you have any further query feel free to contact us, we will be happy to help you https://wedgecommerce.com/contact-us/.