snowflake.snowpark.functions.ai_translate

snowflake.snowpark.functions.ai_translate(text: Union[Column, str], source_language: Union[Column, str], target_language: Union[Column, str]) Column[source]

Translates the given input text from one supported language to another.

Parameters:
  • text – A string or Column containing the text to be translated.

  • source_language – A string or Column specifying the language code for the source language. Specify an empty string '' to automatically detect the source language.

  • target_language – A string or Column specifying the language code for the target language.

Returns:

A string containing a translation of the original text into the target language.

See details in AI_TRANSLATE.

Examples:

>>> # Translate literal text from English to German
>>> df = session.range(1).select(
...     ai_translate('Hello world', 'en', 'de').alias('translation')
... )
>>> df.collect()[0][0].lower()
'hallo welt'

>>> # Auto-detect source language and translate to English
>>> df = session.range(1).select(
...     ai_translate('Hola mundo', '', 'en').alias('translation')
... )
>>> df.collect()[0][0].lower()
'hi world'
Copy