I have set up translation on a custom picklist field as shown:
The language selected for the Picklist Labels is French, and my User's Language is set to French.
According to my understanding, this code below should output the labels in French, but all I get is English:
Schema.DescribeFieldResult fieldResult =
Absence__c.Reason__c.getDescribe();
List<Schema.PicklistEntry> entries = fieldResult.getPicklistValues();
System.debug(UserInfo.getLanguage());
for (Schema.PicklistEntry entry : entries) {
System.debug(entry.getLabel());
}
Expected Result is:
fr
Congé prévu
Congé non prévu
Maladie
Actual Result is:
fr
Planned Vacation
Unplanned Vacation
Sickness
...
UserInfo.getLanguage()
returns fr
as expected, but why are the labels all in English still?
getLabel()
showed the French translation andgetValue()
showed English. Perhaps you ran your code in a different sandbox from where you made the translation entries? I can't think of any other reason this would occur.