0

I want to fetch the translated value of custom label based on user locale i have created one custom label and provided the default language in English and i added a spanish translation into that custom label now i want to fetch the spanish translated label if logged in user locale is spanish i am using Label.labelName and System.Label.LabelName both are always returning the label value in english even user locale is spanish

I am assuming might be the issue is my code is running in platform integration user context not in logged in user context

1 Answer 1

0

Translations are stored in another object called "ExternalStringLocalization" but this object is accessible via "Tooling API" only for example you can query like below from your developer console (Remember to mark tooling api checkbox to true) :

SELECT Id
  ,ExternalStringId
  ,ExternalString.MasterLabel
  ,ExternalString.Value
  ,Value
  ,Language 
FROM ExternalStringLocalization 

Similarly from apex you can make a callout to below endpoint in Salesforce (just an example with query).

/services/data/v56.0/tooling/query/?q= 'Select+id,Name,Value,Language+from+ExternalString'

enter image description here

1
  • Thanks this will work but to get spanish translation its not good approach to do service call.
    – Guest
    Commented Apr 4, 2023 at 5:48

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .