Reputation:
I want to translate the words using asp.net mvc3 , for example Good is a word. i want to translate the word into my specified language? how to do? advance in thank you...
Upvotes: 3
Views: 2661
Reputation: 35572
MVC Can't do traslation. you should be using some kind of service to do that for you
like google traslation APIs for DotNet as
https://code.google.com/p/google-language-api-for-dotnet/
You can creat a custom function as below to acheive that
public string TranslateText(string input, string languagePair)
{
string url = String.Format("http://www.google.com/translate_t?hl=en&ie=UTF8&text={0}&langpair={1}", input, languagePair);
WebClient webClient = new WebClient();
webClient.Encoding = System.Text.Encoding.UTF8;
string result = webClient.DownloadString(url);
result = result.Substring(result.IndexOf("<span title=\"") + "<span title=\"".Length);
result = result.Substring(result.IndexOf(">") + 1);
result = result.Substring(0, result.IndexOf("</span>"));
return result.Trim();
}
OR see this Question here on SO
Upvotes: 4
Reputation: 1038720
You could use an online language translation service such as the Google Translate API
or Bing Translate
. On the other hand if the words you want to translate are known beforehand you could localize your application using resource files. Checkout the following blog post
from Scott Hanselman for more details.
Upvotes: 2