Reading list Switch to dark mode

    Custom Labels In Salesforce

    Updated 16 July 2021

    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.

    Searching for an experienced
    Salesforce Company ?
    Find out More
    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 add a ticket, we will be happy to help you https://webkul.uvdesk.com/en/customer/create-ticket/.

    . . .

    Leave a Comment

    Your email address will not be published. Required fields are marked*


    Be the first to comment.

    Back to Top

    Message Sent!

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

    Back to Home

    Table of Content