cancel
Showing results for 
Search instead for 
Did you mean: 

Convert languages (Chines) into English

danishnov
Rocketeer

Hi Team,

I am looking to convert languages (Chines) into English or any other format. Do we have any function in incorta to use in formula column or any other suggestion. 

2 REPLIES 2

JoeM
Community Manager
Community Manager

@danishnov - Here's a video and script of my solution:

 

 

import pandas as pd
from translate import Translator
df = read("Translation.Translations")
pdf = df.toPandas()
def translate_to_english(chinese_text):
    try:
        translator = Translator(to_lang="en", from_lang="zh")
        translation = translator.translate(chinese_text)
        return translation
    except Exception as e:
        print(f"Error translating '{chinese_text}': {e}")
        return ""
# Apply translation function to the 'Chinese_Phrase' column and create a new 'English_Translation' column
pdf['Machine_Translation'] = pdf['Chinese_Phrase'].apply(translate_to_english)
df_all = spark.createDataFrame(pdf)
save(df_all)

 

shashidhar_sris
Partner
Partner

Thank you @JoeM ,

The Code you have shared is obsolutely working fine. Below is the screenshot how it translated.

Regards,

Shashidhar.S