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
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 'de' and 'hr' to the targetLanguages list as the target language for translation.
targetLanguages.add('de');
targetLanguages.add('hr');
//Assigned the list of target languages to the wrapper's targetLanguages attribute.
wrapper.targetLanguages = targetLanguages;
//Set the source language for translation.
wrapper.sourceLanguage = 'en_US';
//Set the translation engine to use for this translation job.
wrapper.engine = 'ST Google Translate Default';
//Set the Salesforce component flag to indicate the request originates from a Salesforce context
wrapper.salesforceComponent = true;
//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.stTranslate(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
- Encapsulates targetLanguages, sourceLanguage, engine, text, and translations.
- Required: targetLanguages, engine, and text.
- Available engines: ST AWS Default, ST Google Translate Default, ST DeepL Default.
- Check supported language ISO codes per engine in the Simple Translate app.
- translations is a list of ST_TranslationResponseWrapper objects with translated text and language details.
