Translate Your Website to Another Language using Google Language APIThis article will show you how to translate your website from English to another language or vice versa using Google AJAX Language API. Introduction. A few days ago, I updated my Internet Explorer 7 browser to the latest Internet Explorer 8. Naturally thereafter, I was checking out the . Right away I thought that was very cool, and started looking into other translation accelators offered by IE8. I played around with the web translators for a while and found out that the translation works to a certain extent. All web translators pretty much translate word- per- word rather than by context, which is understandable. Anyway, I still thought it would be cool to be able to translate a website or parts of a website without saving all the translations in a database. The Google Maps API allow for the embedding of Google Maps onto web pages of outside developers, using a simple JavaScript interface or a Flash interface. It is designed to work on both mobile devices as well as traditional. GWT is used by many products at Google, including Google AdWords and Google Wallet. It's open source, completely free, and used by thousands of. Google APIs is a set of application programming interfaces developed by Google which allow communication with Google Services and their integration to other services. Examples of these include Search, Gmail, Translate or. Get people into your apps quickly and securely, using a registration system they already use and trust–their Google account. Google Maps JavaScript API V3 - Geocoder. So with that, I started surfing the internet looking for a free API, and lo and behold, I found the Google AJAX Language API, click here to check it out. Look at a snapshot below to see how an English phrase can be translated to various languages. Requirements We will translate a few phrases from English to other languages using Google AJAX Language API's Rest Interface described here. The Fun Begins! To start of, you need to familiarize yourself with the languages that Google supports which is shown in the Languages Enum. Yes I know, it's a lot. According to terms of use, that you will not . Create An Enum Class First, we will create our own enum class for the languages based from Google's Languages Enum, as mentioned and shown above. This is really straight forward. See the code below: 1using System. Language. 4 . In this example, the method is inside my test ASP. NET Page, that's why it's private, I recommend moving it to a public class, and make it static so other pages will have access to this method. Translate(string string. To. Translate. string from. Language, string to. Language). 3. 1 ? The most important part of this code can be seen in lines 4. Lines 4. 5- 4. 7 build a URL that sends a request and gets the response shown in lines 5. Because we're accessing the API via Google's Rest Interface, the response is returned through a Stream object. This is a lot easier to code as compared to web services. The returned string encoded from the stream is cleaned- up (lines 7. We simply call the Translate method that we built above to get translated strings. Of course, we didn't have to make the Language Enum class, but, because of it, our code is a little bit more elegant. As always, the code and the article are provided . Note: The original article can be seen here. Happy coding! History. April 2. 00. 9: Initial post Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. Archives
January 2017
Categories |