12

I'm trying to implement a preview screen with a picklist of available languages and a textbox with translated text. The problem is System.Label.My_Preview_Text or $Label.My_Preview_Text are already translated to current User's locale. Is there a way to retrieve a translation for the specified locale, something like System.Label.getValue('My_Preview_Text','en_US'). Like we can do this in .NET or Java. Is there a way to do that in Apex/VisualForce?

10

You can set the language for your preview apex:page. This documentation says that the language attribute determines:

The language used to display labels that have associated translations in Salesforce. This value overrides the language of the user viewing the page. Possible values for this attribute include any language keys for languages supported by Salesforce, for example, "en" or "en-US".

Based on this unimplemented idea, it looks like there isn't an Apex API where you can specify the language, so in Apex you always get the current User's language.

5

Unfortunately this is not possible currently in Apex.

This is already posted on IdeaExchange and you can vote on this idea.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.