Multi-Language In Any Web Page With Google API

Posted By Venu Thomas

Multi-languageĀ In Any Web Page (HTML, PHP, ASP.NET etc) With Google API

live_preview Demo      downloadDownload Code

Mostly Web Programmers Multilanguage in ASP.NET is by using Localization & Resource rules. But this rule cant use with HTML, PHP etc. Now I’m changing to new rules with Google AJAX Language API. It is very useful for programmers. Click here to read about Localization & Resource

Advantage & Disadvantage

Advantage:
1: Reduce programming time
2. Reduce file size, In Localization & Resource rules, we need resource files by each language
3. No need to find meaning of unknown language for creating site
4. Only one language to store in XML or..5. No need C# & VB.NET.

Disadvantage:
1. Need Internet connection for connecting to Google AJAX Language API’s Script

Click here to read about Google Language AJAX API.
I have a sample program as below. I Hope you will understood.

 
    <script type="text/javascript" src="http://www.google.com/jsapi"></script>
 
<script type="text/javascript">
 
google.load("language", "1");
 
 
function fnTrans(strTransText,strTransField, strTransFLang, strTransTLang)
{
 // Translation
 google.language.translate(strTransText, strTransFLang, strTransTLang, function(result) {
          var strcontainer = document.getElementById(strTransField);
          strcontainer.innerHTML = result.translation ;
 
      });
}
 
function initialize(strToTxtBox, strFromTxtBox) {
 
 // Translate English to German
 
 strFLang = 'en' //English
 strTLang = 'de' //German
 
 var strText = document.getElementById(strFromTxtBox).innerHTML; //Get Lable Name
 
 fnTrans(strText,strToTxtBox, strFLang,strTLang)
 
}
 
 function fnhi()
  {
 
  initialize('ToLableName_FN', 'FrmLableName_FN' ); // First Name
 
  initialize('ToLableName_LN', 'FrmLableName_LN' ); // Last Name
 
  }
</script>
 
  </head>
  <body onload="fnhi()">
 
      <label id="FrmLableName_FN" >First Name</label>
      <br />
  <label id="ToLableName_FN"></label>
  <input type="text" name="txtFname" />
</br>
</br>
 
      <label id="FrmLableName_LN" >Last Name</label>
      <br />
  <label id="ToLableName_LN"></label>
  <input type="text" name="txtFname" />

live_preview Demo      downloadDownload Code

Tags: , , , ,

  •  
  • Share with others:

    Thanks for visiting us! If you enjoyed these icons please feel free to share them! Or if you want to know what's going on with WiseCodes.com, follow us!

    3 Responses to “Multi-Language In Any Web Page With Google API”

    1. hi,good apple in your post,I love thatelegantapple,I need to find one for me,jane

    2. Shyla Kedra your flag on June 13th, 2010 at 9:51 AM
    3. interesting blog. It would be great if you can provide more details about it. Thanks you

    4. Nicol Folsom your flag on June 17th, 2010 at 8:46 AM
    5. Very useful post. Bookmarked. Thanks for it!

    6. pharmatex sponge your flag on August 7th, 2010 at 8:19 PM

    Leave a Reply

    Anti-Spam Protection by WP-SpamFree

    Locations of visitors to this page eXTReMe Tracker