Access Labels
Import labels from the @salesforce/label
scoped module. Custom labels are text values stored in Salesforce that can be translated into any language that Salesforce supports. Use custom labels to create multilingual applications that present information (for example, help text or error messages) in a user’s native language.
labelName
—A name that refers to the label.labelReference
—The name of the label in your org in the formatnamespace.labelName
. We use this format because it’s the same format used in managed packages, in Visualforce, and in other Salesforce technologies. You can use the same format to access labels,myns.labelName
, regardless of where you’re accessing them.
This sample code imports two labels.
To use the labels in the template, use the same {property}
syntax that you use to reference any JavaScript property.
In a Salesforce DX project, label files can live in any subdirectory of force-app/main/default
. For example, this file named ExampleLabels.labels-meta.xml
lives in force-app/main/default/mylabels
.
See Also
- Salesforce DX Developer Guide: Salesforce DX Project Structure and Source Format
- Salesforce Help: Custom Labels
- @salesforce Modules