このページは現在英語版のみで提供されており、日本語版も近日中に提供される予定です。ご利用いただきありがとうございます。

翻訳

Feature Description

The message translation feature currently supports the translation of text messages only, which can be triggered by manual API calls. Non-text messages such as image, video, file, audio, and custom messages cannot be translated.
Note:
Text translation is a value-added paid feature, which is still in the beta phase. You can contact us through the Telegram technical exchange group to enable and experience the full feature.

Display Effect



translateText

Translating Text Messages

API
chat.translateText(options);
Parameter
The options parameter is of the Object type. It contains the following attribute values:
Name
Type
Description
sourceTextList
Array<String>
List of texts to be translated.
sourceLanguage
String
Source Language. 'auto' indicates the SDK automatically identifies the source language.
targetLanguage
String
Target Language. For example:
English - 'en'
Simplified Chinese - 'zh'
French - 'fr'
German - 'de'
Returned Value
Promise
Sample
// Translate Arabic to Chinese
let promise = chat.translateText({
sourceTextList: ['مرحبًا'],
sourceLanguage: 'auto',
targetLanguage: 'en'
});
promise.then(function(imResponse) {
const { translatedTextList } = imResponse.data;
}).catch(function(imError) {
// error code 2117 indicates translation failed
console.warn('translateText error:', imError);
});
// Translate English to Chinese
let promise = chat.translateText({
sourceTextList: ['Hello Tencent', 'Build in-app chat with Tencent Cloud Chat'],
sourceLanguage: 'auto',
targetLanguage: 'zh'
});
promise.then(function(imResponse) {
const { translatedTextList } = imResponse.data;
}).catch(function(imError) {
// error code 2117 indicates translation failed
console.warn('translateText error:', imError);
});

Supported Text Translation Languages

Source Language
Supported Target Language
zh (Simplified Chinese)
en (English), ja (Japanese), ko (Korean), fr (French), es (Spanish), it (Italian), de (German), tr (Turkish), ru (Russian), pt (Portuguese), vi (Vietnamese), id (Bahasa Indonesian), th (Thai), and ms (Malay)
zh-TW (Traditional Chinese)
en (English), ja (Japanese), ko (Korean), fr (French), es (Spanish), it (Italian), de (German), tr (Turkish), ru (Russian), pt (Portuguese), vi (Vietnamese), id (Bahasa Indonesian), th (Thai), and ms (Malay)
en (English)
zh (Simplified Chinese), ja (Japanese), ko (Korean), fr (French), es (Spanish), it (Italian), de (German), tr (Turkish), ru (Russian), pt (Portuguese), vi (Vietnamese), id (Bahasa Indonesian), th (Thai), ms (Malay), ar (Arabic), and hi (Hindi)
ja (Japanese)
zh (Simplified Chinese), en (English), ko (Korean)
ko (Korean)
zh (Simplified Chinese), en (English), ja (Japanese)
fr (French)
zh (Simplified Chinese), en (English), es (Spanish), it (Italian), de (German), tr (Turkish), ru (Russian), and pt (Portuguese)
es (Spanish)
zh (Simplified Chinese), en (English), fr (French), it (Italian), de (German), tr (Turkish), ru (Russian), and pt (Portuguese)
it (Italian)
zh (Simplified Chinese), en (English), fr (French), es (Spanish), de (German), tr (Turkish), ru (Russian), and pt (Portuguese)
de (German)
zh (Simplified Chinese), en (English), fr (French), es (Spanish), it (Italian), tr (Turkish), ru (Russian), and pt (Portuguese)
tr (Turkish)
zh (Simplified Chinese), en (English), fr (French), es (Spanish), it (Italian), de (German), ru (Russian), and pt (Portuguese)
ru (Russian)
zh (Simplified Chinese), en (English), fr (French), es (Spanish), it (Italian), de (German), tr (Turkish), and pt (Portuguese)
pt (Portuguese)
zh (Simplified Chinese), en (English), fr (French), es (Spanish), it (Italian), de (German), tr (Turkish), and ru (Russian)
vi (Vietnamese)
zh (Simplified Chinese), en (English)
id (Bahasa Indonesian)
zh (Simplified Chinese), en (English)