Try this below code it is English to Arabic.
public void modifiedField(FieldId _fieldId)
{
super(_fieldId);
switch(_fieldId)
{
case fieldNum(HCMInsuranceCompanies, CompanyNameEN):
this.CompanyNameAR = this.CompanyNameEN;
this.CompanyNameAR = this.TranslateText(this.CompanyNameEN);
break;
case fieldNum(HCMInsuranceCompanies, CompanyAddressEN ):
if(this.CompanyAddressEN)
this.CompanyAddressAR = this.CompanyAddressEN;
else
this.CompanyAddressAR = "";
break;
}
}
private str TranslateText(str inputStr, str _sourceLang = "en", str _targetLang = "ar")
{
System.String result;
int len, OutputLen;
str resultActual, url = "https://translate.googleapis.com/translate_a/single?client=gtx&sl=" _sourceLang "&tl=" _targetLang "&dt=t&q=" inputStr;
System.Net.WebClient webClient = new System.Net.WebClient();
webClient.set_Encoding(System.Text.Encoding::get_UTF8());
result = webClient.DownloadString(url);
len = result.get_Length();
resultActual = result;
OutputLen = strScan(resultActual, inputStr, 0, len);
//subStr(resultActual, OutputLen, len);
//info(strFmt("actual : %1", resultActual));
resultActual = subStr(resultActual, 0, (OutputLen - 2));
resultActual = strRem(resultActual, "[");
resultActual = strRem(resultActual, '"');
resultActual = strRem(resultActual, ",");
if(strLen(resultActual) == 0)
{
this.CompanyNameEN = this.orig().CompanyNameEN;
checkFailed("Enter the dictionary input for arabic transaltion!");
return this.orig().CompanyNameAR;
}
return resultActual;
}