 |
|
 |
Hi Ravi, The software works fine for me. However, it will be wonderful if it supports Japanese too.
How can I change the setting? I do not know how to change the code. Please help.
Thank you.
Alvin
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
Good project.
This is what I did for Unicode (Thai) support. Get source for WebResourceProvider (http://www.codeproject.com/KB/IP/WebResourceProviderDotNet.aspx)
This example is adding Thai.
// changes in class GoogleTranslator
public enum Mode { ... // add EnglishToThai, ThaiToEnglish }
protected override string getPostData() { ... // add case Mode.EnglishToThai: strPostData += "en|th"; break; case Mode.ThaiToEnglish: strPostData += "th|en"; break;
//changes in class WebResourceProvider void getContent (string url) { ... // change // ASCIIEncoding asciiEncoding = new ASCIIEncoding(); // byte[] postData = asciiEncoding.GetBytes(strPostData); // to UTF8Encoding utf8Encoding = new UTF8Encoding(); byte[] postData = utf8Encoding.GetBytes(strPostData);
// change // StreamReader streamReader = new StreamReader (stream);
// to StreamReader defaults to UTF-8 encoding (change or don't change, your call) StreamReader streamReader = new StreamReader(stream, System.Text.Encoding.UTF8);
//changes in class GoogleTranslatorForm
// Add a radio button to the form for your translation. In this case I called it 'radioThai'. // Change the font in editTranslation to Tahoma (has Unicode Thai). // You will need to change this font to support your language. If not you'll end up with squares // if the font does not support your language.
private void OnTranslate(object sender, System.EventArgs e) { ... // add else { if (radioThai.Checked) { mode = GoogleTranslator.Mode.EnglishToThai; reverseMode = GoogleTranslator.Mode.ThaiToEnglish; } }
|
| Sign In·View Thread·PermaLink | 5.00/5 (1 vote) |
|
|
|
 |
|
|
 |
|
 |
Hi Ravi
As you will have read in your other projects, I am hoping to achieve programmatic Japanese to English translation. I've given up trying to modify the MFC version of WebResourceProvider and will try to work with the .NET version instead as it apparently supports Unicode.
I changed the translation mode to en|ja, and successfully saw 'hello' translated to 'こんにちは' but the reverse translation (using ja|en) is displayed as '?????'. So I think there is something wrong with the local string handling.
Please will you suggest where I should look to fix this?
David
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
I fixed this by changing:
ASCIIEncoding asciiEncoding = new ASCIIEncoding(); byte[] postData = asciiEncoding.GetBytes (strPostData);
to UTF8Encoding utf8Encoding = new UTF8Encoding(); byte[] postData = utf8Encoding.GetBytes(strPostData);
in WebResourceProvider.cs.
|
| Sign In·View Thread·PermaLink | 5.00/5 (1 vote) |
|
|
|
 |
|
|
 |
|
 |
This is great, except I don't know C#, I am using VB.NET, Is there a version for VB or can anyone convert it?
Thanks
El Chalateco
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
Here's[^] a VB .NET version of WebResourceProvider. Perhaps you could use it to write a VB .NET version of GoogleTranslator by copying the parsing logic?
/ravi
|
| Sign In·View Thread·PermaLink | 2.00/5 (1 vote) |
|
|
|
 |
|
|
 |
|
 |
If I translate the sentence below from English to Spanish and back, part of the English sentence stays Spanish. Noticed this in my own code and in this project as well.
"This is a major weather alert. There is a tornado warning in effect until 9:00 pm today"
I also found that this sentence translates perfectly using the Google Translate site verses sending the web requests in Spanish and English. Any Idea what we might be missing?
|
| Sign In·View Thread·PermaLink | 5.00/5 (1 vote) |
|
|
|
 |
|
 |
jwaldner wrote: sentence translates perfectly using the Google Translate site verses sending the web requests
Interesting... Will have to look into what's missing.
/ravi
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
in the example below adding and removing the line that sets the webClient encoding causes and fixes the problem for me...not sure why
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();
// this line makes the translation fail sometimes... webClient.Encoding = Encoding.UTF8; string result = webClient.DownloadString(url);
result = result.Substring(result.IndexOf("id=result_box") + 24, result.IndexOf("id=result_box") + 500);
result = result.Substring(0, result.IndexOf("</div"));
return result; }
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
 |
|
|
 |
|
|
 |
|
 |
Dear Ravi,
First of congratulations for _thinking_ and then implementing a _poor man's_ translation tool that would enable developers to come out with their products supporting multiple languages easily. The response from the community itself is a proof of the _value_ this tool has to them.
I am posting my comment here, but I am actually working on C++ (MFC) so I would be more interested in your MFC component (WebResourceProvider) supporting Unicode. Ok - very quickly - I saw that Google Translation is supporting _11_ different languages translations and without any doubt the languages which don't need Unicode compliance quickly got translated using your tool (that I extended to support other languages).
The languages like Chinese (simplified and traditional), Japanese, Korean, Russian, Arabic obviously failed since they need Unicode to be able to represent their characters. Now I added (partially) the Unicode support to the MFC app (WebResourceProvider_Demo and Lib) and finally the code compiled with 0 errors, but as we know that's not enough - the translation then did _NOT_ work for any languages. I quickly saw that we are using _string length_ based calculations and surely in Unicode environment, they would start behaving strangely. I guess you need to look into it, so that then it becomes a very strong tool.
Recently I saw some posts here and you replying them that Unicode support is soon coming out. Could you please ensure that you add it in both of your tools MFC & C#? If I could be of any help by all means let me know.
Best regards, Yogesh Dhakad (Pune - India)
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
Thanks for your comments. The MFC version of WRP is indeed sorely lacking Unicode support! I hope to be able to get to this soon. Will keep you posted.
/ravi
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
 |
|
 |
Hi Yogesh, I'm sorry but I haven't yet found the time to implement Unicode support for the MFC version. I'm completely swamped right now. 
/ravi
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
Dear Mr. Ravi i really like your work...i have a similar project to do could you please help me???I need to translate from arabic to english and viceversa what should i modify in your code....
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
 |
|
 |
There was once a guy, and he was walking down the street and he saw a picture of his friend and it said if u commit a sin u will bcome like this
Salman
|
| Sign In·View Thread·PermaLink | 1.15/5 (9 votes) |
|
|
|
 |
|
 |
What the ***k on earth is that you are b*****g about?
Nobody can give you wiser advice than yourself. - Cicero ப்ரம்மா
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
 |
|
 |
The binaries in the _demo .zip have now been upgraded. Please retry and let me know if you're still having problems.
Thanks,
/ravi
|
| Sign In·View Thread·PermaLink | 2.00/5 (1 vote) |
|
|
|
 |