Translate text between languages with automatic source language detection, using Amazon Translate.
TTranslateClient.ListLanguagesto populate the language selectorsTTranslateClient.TranslateTextto translate input text- Source language auto-detection by passing
'auto'as the source language code
Client := TTranslateClient.Create;
LRequest := TTranslateTranslateTextRequest.Create('auto', 'fr', 'Hello, world!');
LResponse := Client.TranslateText(LRequest);
if LResponse.IsSuccessful then
begin
WriteLn(LResponse.TranslatedText); // "Bonjour, monde !"
WriteLn(LResponse.SourceLanguageCode); // "en"
end;- Open "Translate.dproj" in Delphi or RAD Studio.
- Select "Run > Run" from the menu or press F9.
- Select a target language from the combo list on the top-right.
- Write some text to translate in the left memo and hit enter to translate.
translate:ListLanguagestranslate:TranslateText
