function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Fabio ScheurelFabio Scheurel 

Set locale/language when querying a custom label

Hi there,

I would like to query a custom label in APEX based on a specific locale/language. Currently, when using Label.My_Label, the My_Label value is always returned using the current user's locale.

However, when performing specific actions like creating Tasks, Events etc. in a trigger, that trigger might run in a system user's or an API user context. However, the content in the Tasks, Events etc. should be localized for a specific contact. I have no idea how I can achieve such thing.

I appreciate your help, thanks!
Fabio
Best Answer chosen by Fabio Scheurel
Fabio ScheurelFabio Scheurel
Hi avidev9,

an idea is referenced (https://success.salesforce.com/ideaView?id=08730000000714W) in the SE thread, thanks for pointing me to it. Yes, it is not possible at the moment.

However, it gave me an idea of a workaround using custom list settings where you provide list values for each required language. Access to that setting should be capsulated into a helper class (utility).

Regards
Fabio

All Answers

Avidev9Avidev9
I think this is not possible, you can have a look at SE thread http://salesforce.stackexchange.com/questions/2187/combine-custom-settings-with-custom-labels
Fabio ScheurelFabio Scheurel
Hi avidev9,

an idea is referenced (https://success.salesforce.com/ideaView?id=08730000000714W) in the SE thread, thanks for pointing me to it. Yes, it is not possible at the moment.

However, it gave me an idea of a workaround using custom list settings where you provide list values for each required language. Access to that setting should be capsulated into a helper class (utility).

Regards
Fabio
This was selected as the best answer