@@ -96,9 +96,10 @@ There are additional optional arguments to control translation, see
9696[ Text translation options] ( #text-translation-options ) below.
9797
9898` 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.
102103
103104``` python
104105# Translate text into a target language, in this case, French:
@@ -107,12 +108,15 @@ print(result.text) # "Bonjour, le monde !"
107108
108109# Translate multiple texts into British English
109110result = translator.translate_text(
110- [" お元気ですか?" , " ¿Cómo estás?" ], target_lang = " EN-GB"
111+ [" お元気ですか?" , " ¿Cómo estás?" ],
112+ target_lang = " EN-GB" ,
111113)
112114print (result[0 ].text) # "How are you?"
113115print (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 "お元気ですか?"
114117print (result[1 ].text) # "How are you?"
115118print (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?"
116120
117121# Translate into German with less and more Formality:
118122print (
0 commit comments