RealTime Data Translation
Salesforce RealTime Data Translation provides real-time translation across various languages within Salesforce. This feature strengthen global support and collaboration, facilitating smooth communication between teams and customers.
Salesforce Translation Options:
- Flow-Based Translation: Enables easy, no-code translation setup using declarative tools.
- Apex-Based Translation: Provides full control with custom logic and code for translations.
Setup Salesforce
APEX-Based Translation
To use st_translate method, create a List<ST_TranslationJobWrapper> with the required data.
For more information about the ST_DetectLanguageWrapper class, see the section below.
The code below provides an example of how to use the st_translate method:
//Created a new instance of the ST_TranslationJobWrapper object, which will hold translation job details.
simpleT.ST_TranslationWrapper wrapper = new simpleT.ST_TranslationWrapper();
//Created a list of target languages for translation.
List<String> targetLanguages = new List<String>();
//Added 'en-us' to the targetLanguages list as the target language for translation.
targetLanguages.add('en-us')
targetLanguages.add('de-de');
targetLanguages.add('hr');
targetLanguages.add('en');
//Assigned the list of target languages to the wrapper's targetLanguages attribute.
wrapper.targetLanguages = targetLanguages;
//Set the source language for translation.
wrapper.sourceLanguage = 'de';
//Set the translation engine to use for this translation job.
wrapper.engine = 'ST Google Translate Default';
//Added the text that will be translated (including HTML content) to the wrapper.
wrapper.text = '<hello><div><br>Simple Translate helps to simplify translation</br></div></hello>';
//Created a list of ST_TranslationJobWrapper objects, which is necessary because invocable methods require a list as a parameter.
List<simpleT.ST_TranslationWrapper> translationWrappers = new List<simpleT.ST_TranslationWrapper>();
translationWrappers.add(wrapper);
//Called the st_translate method to start the translation using the provided list of translation wrappers.
It will return the translated text for all selected target languages.
simpleT.ST_TranslateInvocable.st_translate(translationWrappers);

FLOW-Based Translation
- Navigate to "Salesforce Flows" to enable real-time data translation.
- Create or modify a flow.
- For record-triggered flows, select "Optimize the Flow for Actions and Related Records".
- Set the flow to run asynchronously.
- Use the data translation functionality in Flow Actions.
- In the Flow Action search bar, type "Simple Translate RealTime Data Translation".
- Use the "Simple Translate Real-Time Translation" method to translate text.
- The method takes a List<ST_TranslationWrapper> parameter.

ST_TranslationWrapper class
- The ST_TranslationWrapper class includes the attributes: targetLanguages, sourceLanguage, engine, text, and translations.
- Required attributes: targetLanguages, engine, and text.
- The sourceLanguage is optional, and translations is a list of ST_TranslationResponseWrapper containing translations, target language info, and the translated text.
