Hey Team, I’m seeking a solution to translate non-English strings within a column in my dbt model. Here’s the scenario: I have an employee table with an address column containing non-English strings. My goal is to create another column, say address_en, which will hold the English translations using either a dbt model or macros. I’ve attempted various approaches but haven’t found a solution yet. Interestingly, I managed to achieve this using a Databricks notebook with the following function:
from deep_translator import GoogleTranslator
import pandas as pd
def translate_text(row):
if pd.isnull(row):
return ''
if row == '':
return ''
else:
try:
translated = GoogleTranslator(source='auto', target='en').translate(row)
return translated
except:
return row
translate_deep = udf(translate_text)
I’d appreciate any assistance with this, as it’s currently blocking my progress.