Click here to Skip to main content
15,896,557 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
Maybe uploading the text to Google Translate and getting the language they think the text is in.

I made a translation program, that translates to many languages the user chooses at the same time, but it must predict the language of the source text.

What I have tried:

I used this

Google Translator[^]

To translate, I want something similar that downloads the prediction of the source language instead...
Posted
Updated 13-Mar-17 23:37pm
Comments
Graeme_Grant 14-Mar-17 4:33am    
You want to look at a block of text and be able to identify the language???

To help you post clear questions, please take the time to read these:
* Some guidelines for posting questions in the forums[^]
* Tales from the Evil Empire - Asking questions is a skill[^]
john1990_1 14-Mar-17 11:50am    
I want please a C# code that uploads a string of text and receives the string of the name of the language from Google Translate.
Jochen Arndt 14-Mar-17 4:37am    
If you have (or create) a translation program you should have dictionaries. Then count the number of known words from the text for each dictionary. While this would took some time it should give you the probabilities.

1 solution

You can use the Google Translate API to do that - i.e. I mean specifically just detect/predict the source language not just the bit that does the translation
Detecting Languages  |  Google Cloud Translation API Documentation  |  Google Cloud Platform[^]

There is a similar API here - beware there is a charging structure in place for more than 5000 requests per day or more than 1Mb per day (which can soon add up if there is a lot of text!) - Language Detection API[^]

Jochen Arndt @User-2223753 has come up with another potential (manual) solution and there are more suggestions here - Language identification - Wikipedia[^]

If you need more suggestions then try using "Natural Language Processing" as a search term.
 
Share this answer
 
Comments
john1990_1 14-Mar-17 11:50am    
I want please a C# code that uploads a string of text and receives the string of the name of the language from Google Translate.
CHill60 14-Mar-17 12:22pm    
We don't write code for you. Both of the links to API's I gave you provide both examples of use and support.
Don't continue to learn by trial and error - invest in a good book or series of tutorials - there are several suggestions here on CodeProject to help you
john1990_1 14-Mar-17 15:30pm    
i tried but get an error:

string getHTML(string url)
{
using (WebClient wc = new WebClient())
{
return wc.DownloadString(url);
}
}
MessageBox.Show(getHTML(@"https://translation.googleapis.com/language/translate/v2/detect?key=YOUR_API_KEY&q=Google%20Translate%20Rocks"));
Graeme_Grant 14-Mar-17 12:25pm    
if you go to this page: Translate API Client Library for .NET  |  API Client Library for .NET  |  Google Developers[^], it has a downloadable Google-build API library + a link to sample C# code... all found from the links provided above... You just need to take the time and look.
Graeme_Grant 14-Mar-17 12:00pm    
5ed! :)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900