Access labels in apex dynamically

swagataray Avatar

Here is the way by which you can access labels dynamically using APEX

To find the Value of the label and the translation use this. This has been added as part of the Summer 23 feature.

System.debug('Label English --->' +System.Label.get('', 'lbl_City', 'English'));
if(Label.translationExists('', 'lbl_City', 'Fr')) {
    System.debug('Label Translation Exist?  --->' +Label.translationExists('', 'lbl_City', 'Fr'));
    System.debug('Label French  --->' +System.Label.get('', 'lbl_City', 'Fr'));
}
swagataray Avatar

Leave a Reply

Related articles

Discover more from Tech Talk

Subscribe now to keep reading and get access to the full archive.

Continue reading