SimpleT Detect Language Component

Language Detection identifies the language of a given text. This feature enhance global support and collaboration, enabling seamless communication between teams and customers.

Salesforce Translation Options:

  • Flow-Based Language Detection: It enables users to set up language detection through straightforward, declarative tools, making automation simple and code-free.
  • Apex-Based Language Detection: Provides developers with an easy method for detecting the language of the text.

APEX-Based Language Detection

To use the ST_DetectLanguageInvocable class and its st_getSourceLanguage method, create a list of ST_DetectLanguageWrapper 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:

// Create a list of strings in which we will add the texts we would like to detect the language of.
List<String> texts = new List<String>();
// Add texts to the list.
texts.add('Hello');
texts.add('Help');
// Create the ST_DetectLanguageWrapper object, which will contain all the required data for the language detection callout.
simpleT.ST_DetectLanguageWrapper stDetectLanguageWrapper = new simpleT.ST_DetectLanguageWrapper();
// Add the prepared list of texts to the wrapper object.
stDetectLanguageWrapper.texts = texts;
// Select engine for language detection.
stDetectLanguageWrapper.engine = 'ST Google Translate Default';
// Create a list of ST_DetectLanguageWrapper objects because invocable methods must have parameters set up as a list.
List<simpleT.ST_DetectLanguageWrapper> detectLanguageWrappers = new List<simpleT.ST_DetectLanguageWrapper>();
// Add previously created wrapper to the list.
detectLanguageWrappers.add(stDetectLanguageWrapper);
// Call the ST_DetectLanguageInvocable.stDetectLanguages method and send the created list of detectLanguageWrappers.
List<ST_DetectLanguageResponseWrapper> resultWrappers = ST_DetectLanguageInvocable.stDetectLanguages(detectLanguageWrappers);
The picture shows us the apex-based language detection class.

FLOW-Based Language Detection

  1. Navigate to "Salesforce Flows" to enable language detection.
  2. Create a new flow or modify an existing one.
  3. For record-triggered flows, select "Optimize the Flow for Actions and Related Records."
  4. Set the flow to run asynchronously.
  5. Use the language detection functionality in Flow Actions.
  6. In the Flow Action search bar, type "Simple Translate Source Language detection".
  7. "Simple Translate Source Language Detection" detects the language of the given text.
  8. The method takes a List<ST_DetectLanguageWrapper> parameter. See the "ST_DetectLanguageWrapper Class" section below for more details.
The picture shows us the flow-based language detection panel.

ST_DetectLanguageWrapper Class

  • Encapsulates detected_lan, engine, and texts.
  • Required: engine and texts.
  • Available engines: ST AWS Default, ST Google Translate Default, ST DeepL Default.
  • Check supported language ISO codes per engine in the Simple Translate app.
  • detected_lan is a list of ST_DetectLanguageResponseWrapper.Detected_lan objects. Each object contains a languageCode and a score indicating detection confidence.
Illustration of the ST_DetectLanguageWrapper class.