@@ -96,9 +96,10 @@ There are additional optional arguments to control translation, see
96
96
[ Text translation options] ( #text-translation-options ) below.
97
97
98
98
` translate_text() ` returns a ` TextResult ` , or a list of ` TextResult ` s
99
- corresponding to your input text(s). ` TextResult ` has two properties: ` text ` is
100
- the translated text, and ` detected_source_lang ` is the detected source language
101
- code.
99
+ corresponding to your input text(s). ` TextResult ` has the following properties:
100
+ - ` text ` is the translated text,
101
+ - ` detected_source_lang ` is the detected source language code,
102
+ - ` billed_characters ` is the number of characters billed for the translation.
102
103
103
104
``` python
104
105
# Translate text into a target language, in this case, French:
@@ -107,12 +108,15 @@ print(result.text) # "Bonjour, le monde !"
107
108
108
109
# Translate multiple texts into British English
109
110
result = translator.translate_text(
110
- [" お元気ですか?" , " ¿Cómo estás?" ], target_lang = " EN-GB"
111
+ [" お元気ですか?" , " ¿Cómo estás?" ],
112
+ target_lang = " EN-GB" ,
111
113
)
112
114
print (result[0 ].text) # "How are you?"
113
115
print (result[0 ].detected_source_lang) # "JA" the language code for Japanese
116
+ print (result[0 ].billed_characters) # 7 - the number of characters in the source text "お元気ですか?"
114
117
print (result[1 ].text) # "How are you?"
115
118
print (result[1 ].detected_source_lang) # "ES" the language code for Spanish
119
+ print (result[1 ].billed_characters) # 12 - the number of characters in the source text "¿Cómo estás?"
116
120
117
121
# Translate into German with less and more Formality:
118
122
print (
0 commit comments