0

I have an application where a user can add clients in both Arabic and English, my use-case is simple:

  • user fill-in the client first name and last name in Arabic
  • behind the scene, I call my backend to get the equivalent of names in English
  • English first name and last name will be filled automatically from the server response, user can edit them of course

For that, I am using Google Cloud Translation API

using System;
using System.Threading.Tasks;
using Google.Apis.Auth.OAuth2;
using Google.Cloud.Translation.V2;


class Program
{
    static async Task Main(string[] args)
    {
        var jsonPath = "C:/gcloud/key.json";
        var credential = GoogleCredential.FromFile(jsonPath);
        var client = TranslationClient.Create(credential);
        var text = "مراد"; // arabic name that is spelled "Mourad"
        var response = client.TranslateText(text,  LanguageCodes.English, LanguageCodes.Arabic, TranslationModel.ServiceDefault);
        Console.WriteLine(response.TranslatedText);
        // current output "Intend"
        // expected output "Mourad"

    }
}

So the main obstacle for me is how to get the equivalent name and not the translation of the text (names) to illustrate that via an example using Google translate: enter image description here

So this translates the Arabic name مراد to the Inend which is incorrect, In my case I want "Mourad".

I had a hard time searching for that since I don't know how to express this kind of translation. So My question is shortly: How to translate names based on their spelling and their meaning using Google Cloud Translation Service in C#?

Benzara Tahar
  • 2,058
  • 1
  • 17
  • 21
  • 1
    So you don't actually want a translation, you want a phonetic representation of the name, i.e. what it sounds like, then represented in English? I'm not sure there's a service that actually does that, or even if it's possible. – stuartd Feb 19 '21 at 21:45
  • yes that's exactly what I want .. from Google translate page I can see (and here) how an Arabic name is displayed (spelled) in English so they have this feautre already. I just didn't find how to express my request using their api – Benzara Tahar Feb 19 '21 at 22:04
  • see the left bottom of the image in my question (murad, accuracy doesn't matter here since I want mourad and it will work for most of times). – Benzara Tahar Feb 19 '21 at 22:06

0 Answers0