By continuing to navigate on this website, you accept the use of cookies to serve you more relevant services & content.
For more information and to change the setting of cookies on your computer, please read our Cookie Policy.

How to use custom labels in salesforce

Custom labels are custom text values, which can be called from apex classes, visual force pages or lightning components. These text values can be translated into any language that Salesforce supports.

Custom labels can be used to create multilanguage applications, which are useful to translate information in user's native language.

Create a custom label:

Click on Setup --> Build --> Create --> Custom Label

In the new Custom Label enter the label description, categories(Text entered in this field can be used in filter criteria when creating Custom Label list views), mark the component as protected and value which is used to represent whenever this custom label is called upon in Apex or Visualforce pages.

When you click on Custom Label which is already created, you can find translations or else enable translation in Translation Workbench.

Create Translations:

Enter into the custom label to which you want to create translation.

Click on the new and select the language(languages that have been previously activated in the Translation Workbench, and languages that do not have a local translation or override already created) and provide the translation text.

Note:

The translation language should be added and make it active in the Translation workbench.

Whenever this selected language is called upon using language code and custom label in apex or visual force page it shows the text which we provided in custom label translation text.

Syntax for custom label:

In Apex use System.Label.Labelname

In Visualforce page use {!$Label.Label_name}

Note:

We can create up to 5000 labels in an organization and they can be 1000 characters in length.

Custom Labels in managed packages doesn't come in count with the limit mentioned above.

Custom Label is called upon in an apex or visual force page so that the values mentioned on the custom label are returned as output. This text value can be changed by editing custom label and creating translation text with required language.

Whenever, language with its code like language="code" is called upon in an apex or visual force page along with custom label then the text value is represented in the specified language. So, by this way we can change the application into multilingual.

    Posted On
  • 28 February 2018
  • By
  • Micropyramid

Need any Help in your Project?Let's Talk

Latest Comments
Related Articles
How to set up Email-to-Case and On-Demand Email-to-Case

In any Organization, Support is important to enhance good relationship with their customers. In Salesforce, whenever a customer mails any need of support or interaction ...

Continue Reading...
Field Update Workflow in Salesforce

In Salesforce, field update is used to change or update field records. This can be done by a creating field update actions and associating them ...

Continue Reading...
How to create Master-detail relationship in Salesforce?

In Salesforce, relationships are used to create a link between objects. Whenever user clicks on particular object they can view its data and related data ...

Continue Reading...
open source packages

Subscribe To our news letter

Subscribe and Stay Updated about our Webinars, news and articles on Django, Python, Machine Learning, Amazon Web Services, DevOps, Salesforce, ReactJS, AngularJS, React Native.
* We don't provide your email contact details to any third parties