Link Search Menu Expand Document

Method: messages.translateText

Back to methods index

Translate a given text

Parameters:

NameTypeDescriptionRequired
peerUsername, chat ID, Update, Message or InputPeerIf the text is a chat message, the peer IDOptional
msg_idintIf the text is a chat message, the message IDOptional
textstringThe text to translateOptional
from_langstringTwo-letter ISO 639-1 language code of the language from which the message is translated, if not set will be autodetectedOptional
to_langstringTwo-letter ISO 639-1 language code of the language to which the message is translatedYes

Return type: messages.TranslatedText

Can bots use this method: NO

MadelineProto Example (now async for huge speed and parallelism!):

if (!file_exists('madeline.php')) {
    copy('https://phar.madelineproto.xyz/madeline.php', 'madeline.php');
}
include 'madeline.php';

$MadelineProto = new \danog\MadelineProto\API('session.madeline');
$MadelineProto->start();

// PHP 8+ syntax, use an array on PHP 7.
$messages_TranslatedText = $MadelineProto->messages->translateText(peer: InputPeer, msg_id: int, text: 'string', from_lang: 'string', to_lang: 'string', );