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
| Name | Type | Required | Description |
|---|---|---|---|
Peer | InputPeerClass | — | 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 |
ToLang | string | yes | Two-letter ISO 639-1 language code of the language to which the message is translated |
Tone | string | — | Tone field of MessagesTranslateTextRequest. |
Returns
Possible errors
| Code | Type | Description |
|---|---|---|
| 400 | INPUT_TEXT_EMPTY | The specified text is empty. |
| 400 | INPUT_TEXT_TOO_LONG | The specified text is too long. |
| 400 | MSG_ID_INVALID | Invalid message ID provided. |
| 400 | PEER_ID_INVALID | The provided peer id is invalid. |
| 400 | TO_LANG_INVALID | The specified destination language is invalid. |
| 500 | TRANSLATE_REQ_FAILED | Translation failed, please try again later. |
| 400 | TRANSLATE_REQ_QUOTA_EXCEEDED | Translation is currently unavailable due to a temporary server-side lack of resources. |
| 406 | TRANSLATIONS_DISABLED | Translations are unavailable, a detailed and localized description for the error will be emitted via an updateServiceNotification as specified here ». |
| 500 | TRANSLATION_TIMEOUT | A timeout occurred while translating the specified text. |
References
- Official documentation
- Generated Go reference
- TL definition:
messages.translateText#a5eec345