1:32 pm - Monday May 20, 2013

internationalize web pages using Google Translate

Google pro­vides a free lan­guage trans­la­tion api which convert’s your web­site con­tent to any other language.With this pow­er­ful tool in hand we can sim­ply inte­grate Google trans­late in your web­pages to inter­na­tion­al­ize our website.Internationalization improves your web­site by lur­ing vis­i­tors to your site from all over the world and makes them clearly under­stand your web­site content.Follow few steps to inte­grate google trans­late in your webpages.There are num­ber of items which should be taken care while build­ing up a global web­site. This tuto­r­ial would not give you com­plete detail on this but it would give you a good exam­ple on how you can offer your web page in dif­fer­ent lan­guages to inter­net com­mu­nity by dif­fer­en­ti­at­ing their loca­tion ie. locale.To Inter­na­tion­al­ize web pages you need to

1.Add script from google trans­late in the head sec­tion of your web page.

<script>
            function googleTranslateElementInit() {
                new google.translate.TranslateElement({
                    pageLanguage: 'en',
                    layout: google.translate.TranslateElement.InlineLayout.SIMPLE
                }, 'google_translate_element');
            }
        </script><script src="//translate.google.com/translate_a/element.js?cb=googleTranslateElementInit"></script>

2.Add the html in your page any­where in the body sec­tion of webpage.

<div id="google_translate_element"></div>

Now you can local­ize your Web sites and trans­lat­ing them into the local lan­guages or just by mak­ing them more acces­si­ble to other lan­guage speak­ers.
It’s all done you are now ready to go and fire up your favorite browser and trans­late your web­site con­tent using google trans­late tool.

You May Also Like:

Filed in: Javascript

2 Responses to “internationalize web pages using Google Translate”

  1. Rasheed
    January 23, 2013 at 12:53 pm #

    Hi Murali,
    Do u think , it is the best approach for pro­vid­ing the inter­nal­iza­tion sup­port in web­sites.
    I think using prop­er­ties file (with local sup­port of dif­fer­ent lan­guages) is the bet­ter approach. Please give your comments.

    • January 23, 2013 at 2:11 pm #

      yes rasheed, Google pro­vides it’s own cus­tomiza­tion of labels in dif­fer­ent lan­guages, but using prop­er­ties file would be bet­ter approach because you can cus­tomize the words more pre­cisely for your web­site. If you are sat­is­fied with google’s trasla­tion for your web­site or you think google’s trans­la­tion is pre­cise you can choose googles translator.

Leave a Reply