@@ -337,6 +337,7 @@ def translate_text(
337337 * ,
338338 source_lang : Union [str , Language , None ] = None ,
339339 target_lang : Union [str , Language ],
340+ context : Optional [str ] = None ,
340341 split_sentences : Union [str , SplitSentences , None ] = None ,
341342 preserve_formatting : Optional [bool ] = None ,
342343 formality : Union [str , Formality , None ] = None ,
@@ -357,6 +358,11 @@ def translate_text(
357358 language. If a glossary is used, source_lang must be specified.
358359 :param target_lang: language code to translate text into, for example
359360 "DE", "EN-US", "FR".
361+ :param context: (Optional) Additional contextual text to influence
362+ translations, that is not translated itself. Note: this is an alpha
363+ feature: it may be deprecated at any time, or incur charges if it
364+ becomes generally available. See the API documentation for more
365+ information and example usage.
360366 :param split_sentences: (Optional) Controls how the translation engine
361367 should split input into sentences before translation, see
362368 :class:`SplitSentences`.
@@ -406,6 +412,8 @@ def translate_text(
406412 )
407413 request_data ["text" ] = text
408414
415+ if context is not None :
416+ request_data ["context" ] = context
409417 if split_sentences is not None :
410418 request_data ["split_sentences" ] = str (split_sentences )
411419 if preserve_formatting is not None :
0 commit comments