RickStrahl / Westwind.Globalization

Database driven resource localization for .NET applications
543 stars 135 forks source link

Modify the TranslationServices class #134

Closed ablove00 closed 5 years ago

ablove00 commented 6 years ago

Hello and thanks for the work you have done I am sending this message from Iran, whose language is Persian I was testing the program. Persian to Farsi translation. Persian language translation has a fault in Persian: Text to translate سلام جهان Google Translation In the words of "Tvsaz ... Tazzat Tazaz"

When the translation, it displays strange characters. Which was resolved by editing the TranslationServices class. Line Code 195 Class TranslationServices

                WebClient web = new WebClient();
                web.Headers.Add(HttpRequestHeader.AcceptCharset, "UTF-8");

                // Make sure we have response encoding to UTF-8
                web.Encoding = Encoding.UTF8;
                jsonString = web.DownloadString(url);

To:

                using (WebClient web = new WebClient())
                {
                    web.Headers.Add(HttpRequestHeader.AcceptCharset, "UTF-8");
                    web.Headers.Add("user-agent", "Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 " +
                                                 "(KHTML, like Gecko) Chrome/41.0.2228.0 Safari/537.36");
                    // Make sure we have response encoding to UTF-8
                    web.Encoding = Encoding.UTF8;
                    jsonString = web.DownloadString(url);
                }

Result: Text to translate سلام جهان Google Translation سلام جهان

The codes for lines 121, 318 and 361 should also be corrected. please inform me. Thank you

RickStrahl commented 5 years ago

Sorry for the long delay. This was added recently.