Google for Two Translate Share Revisit Tutorial

Google for Two Translate Share Revisit Tutorial

Google for Two Translate Share Revisit Tutorial

It was some time ago, now, we left you, regarding our “Google for Two Translate Share Tutorial” project with …

Stop Press 26/5/2015:

Translation arrangements needed amendment, and in order to facilitate this we called on, and thank, the tremendous MyMemory API resource, coupled with more PHP changes as per google_four_translate.php link.

… springing, again, to mind, a bit, because our recent Italian French Spanish Verb Conjugation Text to Speech Tutorial also made use of the wonderful MyMemory API and the stupendous Google Translate services … thanks.

We’ve revisited for a number of reasons …

  • there was a lot of that old CSS “sinful” align=’center’ usage we talked about at W3C XHTML Nu Checker Validation Primer Tutorial going on which we diligently changed to style=” width:100%;text-align:center; “ for all but the HTML td table cells using this syntax, where it was better to say style=” width:33%;text-align:center; “ a bit counterintuitively, we thought, but that way, perhaps because we didn’t specify anything about their parent HTML tr table rows, perhaps
  • the Google Translate usage was channelling that old Text to Speech “translate_tts” approach, which is better, now, left out of the equation in favour of the traditional Google Translate popup window translation and text to speech capabilities that rely on the user clicking a Google button to hear the Text to Speech translation
  • we found fewer bad MyMemory API translations if we looked through the translation ideas offered, rather than just settling, always, for the first one
  • we’d forgotten that with non-English words you can have UTF-8 characters involved, and as MyMemory API returns this as … English “yes” to Italian …

    s\u00ed

    … so we set to work, with the whole of the wonderful web helping world to arrive here to PHP ideas to help, finally resulting in the PHP function …

    function unicode2html($str) { // thanks to //stackoverflow.com/questions/2934563/how-to-decode-unicode-escape-sequences-like-u00ed-to-proper-utf-8-encoded-cha
    $i=65535;
    while($i>0){
    $hex=dechex($i);
    if (strlen($hex) == 3) {
    $str=str_replace("\u0$hex","&#$i;",$str);
    } else if (strlen($hex) == 2) {
    $str=str_replace("\u00$hex","&#$i;",$str);
    } else if (strlen($hex) == 1) {
    $str=str_replace("\u000$hex","&#$i;",$str);
    } else {
    $str=str_replace("\u$hex","&#$i;",$str);
    }
    $i--;
    }
    return $str;
    }

    … to arrive at (assuming you’ve included <meta charset=”utf-8″> within <head> and </head>) …

    sì

The HTML and Javascript and CSS supervisory code you could call google_four_translate.html changed this way.

The PHP supervised code you could call google_four_translate.php changed this way.

Aren’t code revisits such fun?!


Previous relevant Yahoo YQL Web JSON Google for Two Translate Share Tutorial is shown below.

Yahoo YQL Web JSON Google for Two Translate Share Tutorial

Yahoo YQL Web JSON Google for Two Translate Share Tutorial

Today we continue on with Yahoo Web Services called YQL, building on previous tutorial here at Yahoo YQL Web JSON Google for Two Translate Speech Tutorial as shown below. The name is the way it is because it simplified the API aspects of its functionality for the developer to concentrate on SQL, and I’m really supportive of this concept. You don’t have to output in JSON, as other data forms like XML are acceptable. Let’s see what Wikipedia says about YQL below.

Yahoo! Query Language (YQL) is an SQL-like query language created by Yahoo! as part of their Developer Network. YQL is designed to retrieve and manipulate data from APIs through a single Web interface, thus allowing mashups that enable developers to create their own applications.[1]

Initially launched in October 2008 with access to Yahoo APIs,[2] February 2009 saw the addition of open data tables from third parties such as Google Reader, the Guardian, and The New York Times.[3] Some of these APIs still require an API key to access them. On April 29th of 2009, Yahoo introduced the capability to execute the tables of data built through YQL using JavaScript run on the company’s servers for free.[3]

So this tutorial uses a YQL web service into the data emanating from its links to the Google Translate google.translate database with Yahoo YQL website … thanks. You join up with a person talking in another language, share the computer, or tablet, and type your single sentences, one at a time, into your relevant HTML textarea element, get it translated into the other language, which you’ve first selected from a dropdown, and then the other user has their go … if you want you can be totally silent (but probably laughing a lot). We extended the functionality yesterday to allow the users to hear an audio interpretation of their words in a window.open popup window calling on the amazing Google Translate Text-to-Speech functionality. Today we further extend functionality by allowing the users to save their conversation session to share with others, optionally, by sending these friends or interested parties an email that will recreate the conversation scenario with a link they activate off the email.

The two big PHP functions of use for this are:

Good links for information regarding this tutorial (thanks) are:

Another tool you should have in your armoury for jobs like this is the online JSON validator here. A generic JSON approach to issues could be:

  1. Type the URL you were given into a web browser address bar and have a look at it
  2. Type the URL you were given into //jsonlint.com/ and have it validated
  3. Understand in your own mind what would be different about 1. to make it suitable
  4. Incorporate findings of 3. into massaging of data between file_get_contents and json_decode

Here is a link to some downloadable HTML programming source code which you may want to rename to google_four_translate.html which calls some downloadable PHP programming source code which you may want to rename to google_four_translate.php (and then there is a live run). For the modifications of today, the HTML changes are presented with google_four_translate.html link and the PHP changes are presented with google_four_translate.php link.

Stop Press 26/5/2015:

Translation arrangements needed amendment, and in order to facilitate this we called on, and thank, the tremendous MyMemory API resource, coupled with more PHP changes as per google_four_translate.php link.


Previous relevant Yahoo YQL Web JSON Google for Two Translate Speech Tutorial is shown below.

Yahoo YQL Web JSON Google for Two Translate Speech Tutorial

Yahoo YQL Web JSON Google for Two Translate Speech Tutorial

Today we continue with Yahoo Web Services called YQL, building on previous tutorial here at Yahoo YQL Web Service JSON Google for Two Translate Tutorial as shown below. The name is the way it is because it simplified the API aspects of its functionality for the developer to concentrate on SQL, and I’m really supportive of this concept. You don’t have to output in JSON, as other data forms like XML are acceptable. Let’s see what Wikipedia says about YQL below.

Yahoo! Query Language (YQL) is an SQL-like query language created by Yahoo! as part of their Developer Network. YQL is designed to retrieve and manipulate data from APIs through a single Web interface, thus allowing mashups that enable developers to create their own applications.[1]

Initially launched in October 2008 with access to Yahoo APIs,[2] February 2009 saw the addition of open data tables from third parties such as Google Reader, the Guardian, and The New York Times.[3] Some of these APIs still require an API key to access them. On April 29th of 2009, Yahoo introduced the capability to execute the tables of data built through YQL using JavaScript run on the company’s servers for free.[3]

So this tutorial uses a YQL web service into the data emanating from its links to the Google Translate google.translate database with Yahoo YQL website … thanks. You join up with a person talking in another language, share the computer, or tablet, and type your single sentences, one at a time, into your relevant HTML textarea element, get it translated into the other language, which you’ve first selected from a dropdown, and then the other user has their go … if you want you can be totally silent (but probably laughing a lot). We’ve extended the functionality today to allow the users to hear an audio interpretation of their words in a window.open popup window calling on the amazing Google Translate Text-to-Speech functionality.

The two big PHP functions of use for this are:

Good links for information regarding this tutorial (thanks) are:

Another tool you should have in your armoury for jobs like this is the online JSON validator here. A generic JSON approach to issues could be:

  1. Type the URL you were given into a web browser address bar and have a look at it
  2. Type the URL you were given into //jsonlint.com/ and have it validated
  3. Understand in your own mind what would be different about 1. to make it suitable
  4. Incorporate findings of 3. into massaging of data between file_get_contents and json_decode

Here is a link to some downloadable HTML programming source code which you may want to rename to google_four_translate.html which calls some downloadable PHP programming source code which you may want to rename to google_four_translate.php (and then there is a live run). For the modifications of today, only the HTML needed to change, believe it or not, and these changes are presented with google_four_translate.html link.


Previous relevant Yahoo YQL Web Service JSON Google for Two Translate Tutorial is shown below.

Yahoo YQL Web Service JSON Google for Two Translate Tutorial

Yahoo YQL Web Service JSON Google for Two Translate Tutorial

Here is a tutorial that might be re-introducing you to the Yahoo Web Services called YQL, building on previous ones here at this blog. The name is the way it is because it simplified the API aspects of its functionality for the developer to concentrate on SQL, and I’m really supportive of this concept. You don’t have to output in JSON, as other data forms like XML are acceptable. Let’s see what Wikipedia says about YQL below.

Yahoo! Query Language (YQL) is an SQL-like query language created by Yahoo! as part of their Developer Network. YQL is designed to retrieve and manipulate data from APIs through a single Web interface, thus allowing mashups that enable developers to create their own applications.[1]

Initially launched in October 2008 with access to Yahoo APIs,[2] February 2009 saw the addition of open data tables from third parties such as Google Reader, the Guardian, and The New York Times.[3] Some of these APIs still require an API key to access them. On April 29th of 2009, Yahoo introduced the capability to execute the tables of data built through YQL using JavaScript run on the company’s servers for free.[3]

So this tutorial uses a YQL web service into the data emanating from its links to the Google Translate google.translate database with Yahoo YQL website … thanks. You join up with a person talking in another language, share the computer, or tablet, and type your single sentences, one at a time, into your relevant HTML textarea element, get it translated into the other language, which you’ve first selected from a dropdown, and then the other user has their go … if you want you can be totally silent (but probably laughing a lot).

The two big PHP functions of use for this are:

Good links for information regarding this tutorial (thanks) are:

Another tool you should have in your armoury for jobs like this is the online JSON validator here. A generic JSON approach to issues could be:

  1. Type the URL you were given into a web browser address bar and have a look at it
  2. Type the URL you were given into //jsonlint.com/ and have it validated
  3. Understand in your own mind what would be different about 1. to make it suitable
  4. Incorporate findings of 3. into massaging of data between file_get_contents and json_decode

Here is a link to some downloadable HTML programming source code which you may want to rename to google_four_translate.html which calls some downloadable PHP programming source code which you may want to rename to google_four_translate.php (and then there is a live run).

If this was interesting you may be interested in this too.


If this was interesting you may be interested in this too.


If this was interesting you may be interested in this too.


If this was interesting you may be interested in this too.

This entry was posted in eLearning, Event-Driven Programming, Not Categorised, Tutorials and tagged , , , , , , , , , , , , , , , , , , , . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>