Custom labels enable developers to create multilingual applications by automatically presenting information (for example, help text or error messages) in a user’s native language. Custom labels are custom text values that can be accessed from Apex classes, Visualforce pages, Lightning pages, or Lightning components. The values can be translated into any language Salesforce supports.
Main advantage of using Custom Label offers flexibility in code and values being fetched dynamically in code can be changed anytime without need to change code itself.
You can create up to 5,000 custom labels for your organization, and they can be up to 1,000 characters in length. Custom labels from managed packages don’t count toward this limit.
How you add a custom label to your application depends on the user interface. For more information on the following syntax, see the corresponding developer guides.
- In Apex use the System.Label.Label_name syntax. You can also use methods in the System.Label class to check for and retrieve translated labels. To check if translation exists for a label and language in a namespace, use translationExists(namespace, label, language). To retrieve the label for a default language setting or for a language and namespace, use get(namespace, label, language).
- In Flow Builder, use the $Label global variable.
- In Visualforce, use the $Label global variable.
- In Aura components, use the $Label.c.labelName syntax for the default namespace or $Label.namespace.labelName if your org has a namespace or to access a label in a managed package.
- In Lightning web components, import the label using the @salesforce/label/namespace.Label_name syntax.
- In Lightning App Builder component labels and attributes, use the {!$Label.customLabelName} expression.
How to Create Custom Label in Salesforce
Step 1 :- Go to the Setup, Quick Find Box, Search for Custom Label
Step 2 :- Click and Open it and Click on New Button
Step 3 :- Fille the Below details :-
Short Description :- Custom label Demo
Name :- Custom_label_Demo
Language :- English
Categories :- Demo
Values :- Custom Label Demo Values
click on Save
Step 4 :- Go to the Setup, Quick Find Box, Search for Language Settings and both Enable checkbox, select the language you want to display for available, click on save
Step 5 :- If you need to add Translation of the custom label, go to the Setup, Quick Find Box, Search for Translation WorkBench ==> Translate, Click on Enable it,
Step 6 :- Go to the Translation Language Settings click on Add and add the language and User and click on save
Step 7 :- Now go back to the Custom Label and in Translation Section click on New
Language :- German
Translate text :- Demowerte für benutzerdefinierte Etiketten
click on Save
Step 8 :- Go to the Setup Quick find Box, Search for User and Edit and Select its Language as German
then reference how we can use custom label :- https://www.mytutorialrack.com/custom-labels-in-salesforce/









