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'));
}
Leave a Reply