
The Summer’23 update of Salesforce has introduced a new feature called Access Labels in Apex Dynamically. This feature allows developers to use the System.Label.get(namespace, label, language)
method to get a custom label, optionally specifying a language. This means that developers can now dynamically resolve label names at runtime, including overriding the user’s current language if a translation exists for the requested language.
For example, let’s say you have a custom label called greeting
with translations in multiple languages. With this new feature, you can now dynamically access the label in Apex code like this:
String greetingLabel = System.Label.get(null, 'greeting', 'fr');
This code will retrieve the French translation of the greeting
label. This can be useful in situations where you need to display information to users in different languages based on their preferences or location.
I hope this helps!
About the blog
SFDCLessons is a blog where you can find various Salesforce tutorials and tips that we have written to help beginners and experienced developers alike. we also share my experience and knowledge on Salesforce best practices, troubleshooting, and optimization. Don’t forget to follow us on:
Newsletter
Subscribe to our email newsletter to be notified when a new post is published.