Tuesday, September 02, 2008

Add Inline Language Translation to your Website with Google AJAX API

Source: http://www.labnol.org/internet/website-translation-with-google-ajax-language-ap/4367/

translation Google Translate, Windows Live Translator and Yahoo! Babelfish have made it very easy for web publishers to add language translation capability into their web pages. Include a line of Javascript code anywhere in your blog template and visitors from other countries will be able to translate and read your content in their own native language. Simple.

While these solutions work, the only problem is that when people translate your web pages, everything gets reloaded under a different URL and this is not the best user experience. You may therefore want to try this AJAX based language translation where the content is translated inline in real-time while the visitor remains on your site.

Inline Translation powered by Google AJAX Language API

Watch this screencast video to see how inline translation works or go here for a live demo.

There are many advantages offered by Google AJAX Language Translation API vis-a-vis the regular online translation service of Google. You are in complete control of page elements that are to be translated, all existing links and sharing features on your web page stay intact and best of all, visitors get a better experience.

If you liked what you just saw, it is something very easy to implement and internally uses Google API that you may use on any site without any restrictions.

How Inline Language Translation Works ?

The basic idea is that when a visitors clicks a language flag or selects a new language from the drop down, we invoke the Google Translate API and replace (actually hide) the existing text with the translated text returned by the Google API. The cycle is repeated when another languages is selected.

Your visitors can also switch to the original language of the web page anytime.

Add Google AJAX Language API in your Website

If you are ready to take the plunge, here’s what you need to do to get this working on your site.

Step 1: Edit your blog template and place everything that you want to translate inside a <div> tag with some unique id. - let’s say <div id="article">….</div>

translation-div

Step 2: Now place this code - <div id="translation"></div> - near the article div you configured in Step 1. The second div will actually house your translated text so you may add it just above or below the article div.

Step 3: And here’s the actual translation code. If this looks geeky, don’t worry too much - just copy-paste it inside the <head> tag of your blog template as it is.

<script type="text/javascript"         src="http://www.google.com/jsapi"></script> <script type="text/javascript">   // Initialize version 1.0 of Google AJAX API  google.load("language", "1");   function translate(lang) {    var source = document.getElementById("article").innerHTML;    var len = content.length;     // Google Language API accepts 500 characters per request     var words = 500;     // This is for English pages, you can change the    // sourcelang variable for other languages    var sourcelang = "en";    document.getElementById("translation").innerHTML = "";     for(i=0; i<=(len/words); i++) {      google.language.translate (source.substr(i*words, words),                  "en", lang, function (result) {      if (!result.error) {      document.getElementById("translation").innerHTML            = document.getElementById("translation").innerHTML            + result.translation;     } }); }      // Hide the text written in the original language   document.getElementById("article").style.display = 'none';   return false;  }   // Switch to the original language   function original() {   document.getElementById("translation").style.display='none';   document.getElementById("article").style.display = 'block';   return false;  } </script>

Step 4: The last step is to include the translation flags or translation drop-down menu in your template.

I prefer having language names (see sidebar) instead of country flags because a flag may not always be the best representation of a language.

<a href="#" onclick="original();">Switch to English</a> <select onchange="translate(this.options[this.selectedIndex].value);"> <option value="de">deutsch</option> <option value="pt">português</option> <option value="fr">français</option> <option value="ja">日本語</option> <option value="ar">عَرَبيْ</option> <option value="it">italiano</option> <option value="ru">pусский</option> <option value="po">polski</option> <option value="zh-CN">中文</option> <option value="es">español</option> <option value="ko">한국어</option> <option value="nl">nederlands</option> <option value="hi">हिन्दी </option> <option value="el">Ελληνική</option> <option value="ro">română</option> </select>

Add Inline Language Translation to your Website with Google AJAX API - Digital Inspiration

Read More...

Intel talks up shape-shifting "programmable matter," bugs us out

Source: http://feeds.engadget.com/~r/weblogsinc/engadget/~3/381366301/

Filed under:


We've managed to somewhat wrap our brains around shape-shifting robots and printable circuits, but we're still working on fully understanding the latest Intel spill. As IDF came to a close, Justin Rattner, Intel's chief technology officer, presented a keynote speech in which he explained just how close the outfit was to realizing "programmable matter." Granted, he did confess that end products were still years away, but researchers have been looking at ways to "make an object of any imaginable shape," where users could simply hit a print button and watch the matter "take that shape." He also explained that the idea of programmable matter "revolves around tiny glass spheres with processing power and photovoltaic for generating electricity to run the tiny circuitry." For those now sitting with a blank stare on their face (read: that's pretty much all of you, no?), hit up the read link for even more mind-boggling "explanations."

[Via MAKE]
Read | Permalink | Email this | Comments

Read More...

Mythbusters RFID hacking episode canned by credit card company lawyers

Source: http://feeds.engadget.com/~r/weblogsinc/engadget/~3/381471510/

Filed under:

Although it's no secret that RFID is easily hacked (see: train passes, passports, credit cards, one billion other cards, etc.) it's still not necessarily common knowledge, and it sounds like the major credit card companies want to keep it that way -- according to Adam Savage, Mythbusters was all set to do a show exposing the weak security behind most RFID implementations but was shut down by lawyers from "American Express, Visa, Discover, and everybody else... [who] absolutely made it really clear to Discovery that they were not going to air this episode." Since Discovery is an ad-supported channel, it's not surprising that it backed down, but we'd say that the credit card industry would be far better served spending money on actually improving security rather than lawyering up and trying to keep consumers in the dark. Video after the break.

[Via Wired]

Continue reading Mythbusters RFID hacking episode canned by credit card company lawyers

Read | Permalink | Email this | Comments

Read More...

NEC debuts "premium" 22-inch EA221WM LCD monitor

Source: http://feeds.engadget.com/~r/weblogsinc/engadget/~3/381541860/

Filed under:


Impressed by the NEC EA261WM's frog-displaying abilities but think it's about four inches too much for you? Then good news! NEC has now introduced the MultiSync EA221WM, which boasts many of the same "premium" features in a slightly more desk-friendly 22-inch size. That includes a 1,000:1 contrast ratio, a 5 ms response time, a four port USB 2.0 hub, and NEC's trademark ECO Mode and carbon footprint meter, to name a few, although you will have to make do with a drop to 250 cd/m&sup2; brightness, and a 1680 x 1050 resolution instead of the full 1,920 x 1,200 on the 26-inch model. On the upside, the EA221WM's $390 price tag is a good deal more affordable than that of its larger counterpart, and you'll be able to get your hands on it sometime this month.
Read | Permalink | Email this | Comments

Read More...

ATP PhotoFinder mini geotagger doesn't require software

Source: http://feeds.engadget.com/~r/weblogsinc/engadget/~3/381595730/

Filed under: ,


Most of the geotaggers we've seen have written location data to your photos using some fancy software on your machine after you've pulled images off your camera, but ATP's PhotoFinder mini moves the tagging step backwards in the process, writing geodata directly to images on your memory card. Like similar devices, the PhotoFinder mini records timelogged GPS data from a SiRF Star III chip while you shoot -- but when you're done, you insert your card into a base station, which tags your images using their EXIF timestamps. Sounds like a much simpler system than relying on third-party software to integrate with your photo-management apps -- we just wish the dock was also a card reader, which would make this a one-step process. No pricing info yet, but if this thing is reasonable, it'll certainly be tempting.

[Via Photography Blog, thanks Mark]
Read | Permalink | Email this | Comments

Read More...