Skip to main content

messages.translateText

Translate a given text. Styled text entities will only be preserved for Telegram Premium users.

func (c *Client) MessagesTranslateText(ctx context.Context, request *MessagesTranslateTextRequest) (*MessagesTranslateResult, error)

Calling this method​

client.Run(ctx, func(ctx context.Context) error {
api := client.API()

res, err := api.MessagesTranslateText(ctx, &tg.MessagesTranslateTextRequest{
// see Parameters
})
if err != nil {
return err
}
_ = res // *MessagesTranslateResult
return nil
})

Parameters​

NameTypeRequiredDescription
PeerInputPeerClass—If the text is a chat message, the peer ID
ID[]int—A list of message IDs to translate
Text[]TextWithEntities—A list of styled messages to translate
ToLangstringyesTwo-letter ISO 639-1 language code of the language to which the message is translated
Tonestring—Tone field of MessagesTranslateTextRequest.

Returns​

*MessagesTranslateResult

Possible errors​

CodeTypeDescription
400INPUT_TEXT_EMPTYThe specified text is empty.
400INPUT_TEXT_TOO_LONGThe specified text is too long.
400MSG_ID_INVALIDInvalid message ID provided.
400PEER_ID_INVALIDThe provided peer id is invalid.
400TO_LANG_INVALIDThe specified destination language is invalid.
500TRANSLATE_REQ_FAILEDTranslation failed, please try again later.
400TRANSLATE_REQ_QUOTA_EXCEEDEDTranslation is currently unavailable due to a temporary server-side lack of resources.
406TRANSLATIONS_DISABLEDTranslations are unavailable, a detailed and localized description for the error will be emitted via an updateServiceNotification as specified here ».
500TRANSLATION_TIMEOUTA timeout occurred while translating the specified text.

References​