Description
The TranslateString
method is a static utility function provided by the Editor.EditorUtility
class. It is designed to translate a given input string into a specified language. This method is asynchronous and returns a Task<string>
, which represents the translated string once the task is completed.
Usage
To use the TranslateString
method, you need to provide two parameters:
input
: The string that you want to translate.
language
: The target language code (e.g., "en" for English, "fr" for French) into which the input string should be translated.
Since this method is asynchronous, you should await the result or handle it using a continuation task.
Example
// Example usage of TranslateString
public async Task ExampleUsage()
{
string inputText = "Hello, world!";
string targetLanguage = "es"; // Spanish
string translatedText = await Editor.EditorUtility.TranslateString(inputText, targetLanguage);
// Use the translated text
// e.g., display it in the UI
// DisplayTranslatedText(translatedText);
}