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.

  1. In Visualforce Page
  2. In Apex Class
  3.  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;
}
}

Output

 

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/.

Leave A Reply

Please verify that you are not a robot.

Tell us about Your Company

How can we help you with your business?




    Message Sent!

    If you have more details or questions, you can reply to the received confirmation email.

    Back to Home