In a lightning component, we have to display some records in a datatable with selectable rows and where the table header will display each column field label. To cater for multi-language, the header column label must be translated in 4 languages (English, French, Dutch, German). Currently in lightning markup we do not have any global variable to access an object field label, so we are trying to retrieve the field label dynamically from apex using getDescribe methods and pass the data as a map to the lightning component.
But there seem to be an issue with getDescribe when accessing field label for standard system field like Owner. Here is the sample code for Account object
for(Schema.SobjectField strFld: Account.SobjectType.getDescribe().fields.getMap().Values()){
Schema.DescribeFieldResult dfield = strFld.getDescribe();
if( dfield.getName()=='OwnerId'){
system.debug('API Name='+dfield.getName()+ ' ,label= ' + dfield.getLabel());// API Name=OwnerId ,label= Owner ID
system.debug('Relationshipname = '+ dField.getRelationshipName()); // Relationshipname = Owner
}
}
The first debug log shows the field label as Owner Id, but we would like to have label "Owner" only so that this get translated to other languages. Currently, this shows as "ID du proprietaire" in French for example.
Now if we try to use the getRelationshipName() method, it shows "Owner" in all languages, so this is not translated at all.
Is there any other workaround besides defining a custom label?
Thank you