Installing Google translator widget with flags
Do you want to reach wider international audience? What better way to do it than by allowing your readers to read your articles in his or her own language!
Installing a translator on your webpage or blog will do just that. Google translator can translate your web page into 56 languages (as of 24 August 2009).
In this tutorial I will show you how to add a Google translator widget complete with the corresponding nation’s flag icons.
Without further ado,
- Go to Layout.
- Click a Add A Gadget link.
- In Add A Gadget window, select HTML/Javascript.
- Enter the title of your widget e.g. Translate This Page -this is optional.
- Copy the code below and paste it inside the window.
- Click Save.
<!-- Translate flag BEGIN --> <!-- by www.bloggersentral.com --> <a class="translate-flag" onclick="href='http://translate.google.com/translate?u='+encodeURIComponent(location.href)+'&langpair=SourceLangCode|TargetLangCode&hl=InterfaceLangCode'" title="Translate to TargetLangName" target="_blank"><img border="0" style="cursor: pointer;" src="FlagIconURL" /></a> <!-- Translate flag END -->
Where:
SourceLangCode
is the code web page original language,TargetLangCode
is the code for language you want the page translated into, andInterfaceLangCode
is code for Google translator bar language.TargetLangName
is the name of targeted language.- Replace all those variables with their respective Google language codes and language name. Refer to the table below.
Language name Code Language name Code Language name Code Albanian sq Hungarian hu Turkish tr Arabic ar Indonesian id Ukrainian uk Bulgarian bg Italian it Vietnamese vi Catalan ca Japanese ja Afrikaans af Chinese (Simplified) zh-CN Korean ko Belarusian be Chinese (Traditional) zh-TW Latvian lv Icelandic is Croatian hr Lithuanian lt Irish ga Czech cs Maltese mt Macedonian mk Danish da Norwegian no Malay ms Dutch nl Persian fa Swahili sw English en Polish pl Welsh cy Estonian et Portuguese pt Yiddish yi Filipino tl Romanian ro Afrikaans af Finnish fi Russian ru Belarusian be French fr Serbian sr Icelandic is Galician gl Slovak sk Zulu zu German de Slovenian sl Greek el Spanish es Hebrew iw Swedish sv Hindi hi Thai th FlagIconURL
is the link to the nation flag representing the target language. You can download free flag icons from Custom Icon Design, FamFamFam or MarkFennel.com. Then upload the ones you need to an image host such as Photobucket, Flickr or Picasa. Once uploaded, get the link to each image an use it to replaceFlagIconURL
.
I’ve put a class name to the code, so you can easily style the flag if you want. Add the codes below before or after the translator code.
<style> .translate-flag img { /* add styling codes here */ } </style>
Here is a working sample of actual translator flags and their codes. The first one translates from English to Indonesian, with English interface. The second one translates from English to Spanish with Spanish interface.
<!-- Translate flag BEGIN --> <!-- by BloggerSentral.blogspot.com --> <a class="translate-flag" onclick="href='http://translate.google.com/translate?u='+encodeURIComponent(location.href)+'&langpair=en|id&hl=en'" title="Translate to Indonesian" target="_blank"><img border="0" style="cursor: pointer;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgNxd6SxYNgs-bXJdr5ROpYJyDLXyjwghQXUfOtUgD80xG4N1A0-zWSVyghBe77mYdZ1bwuPfdB_FzaI70D8FQt2VKflB90Hx152NAWi5vmm17otQZD1dDHl_HPxXVxYwFU8MuvlL9lBHjX/" /></a> <a class="translate-flag" onclick="href='http://translate.google.com/translate?u='+encodeURIComponent(location.href)+'&langpair=en|es&hl=es'" title="Translate to Spanish" target="_blank"><img border="0" style="cursor: pointer;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjroxApUODRtoGU8dQhVeyWyxLenY1-BiJQtcFaWNqX6wNo0ZWe_wDll591WtOH9kqLEJ78_AVy9iEVgyJ-HO1SN4ZQVD8cZpTnPieFMqKaKMw9MEAkEcUSTGyirXi9eQ32q5OFCYuop_1R/" /></a> <!-- Translate flag END -->
Enjoy!
Before you leave:- Do you find this article useful? Share it via Retweet, Share and Stumble buttons below.
- Any suggestion, question or comment? Please post it in the comments below.
47 comments to "Installing Google translator widget with flags"
Thank you for sharing this informative information.
Sending love land light, beauty and Joy...)
Very useful. Thank you very mutch. I use this script in my site, and it's looking great.
artparadox,
Glad you find it useful. Stick around for more tips and hacks.
As always an excellent posting.The
way you write is awesome.Thanks. Adding more information will be more useful.
Bathmate
Seem this is different install Google traslate.
Thanks.
Thanx this tips is very useful..
Btw, here is the example of my site installed with translator @ fit2page.blogspot.com
Bathmate, techgravy, Ryan, CikguNorza,
Thanks for stopping by guys :)
Thanks a lot, i try n it works in my halamansamping.blogspot.com :)
@Halaman Samping-nya Inung
You're welcome. It looks good.
Whoaa... its so useful, particularly ur link to http://www.markfennell.com/flags/. so i can download many flags. Its work in my blog http://halamansamping.blogspot.com. I had grab it blogger-sentral badge, thanks a lot
@Halaman Samping-nya Inung
Saw the badge, thanks a lot.
excellent...
Thank you very much, this is what I was searching for, as I plan to start a photoblog. Though it doesn't work at my page... I've downloaded the flags, copied them into a Picasa album, then the link into the html text... The flags don't appear on the site. I keep trying. :-)
http://engelwerk.blogspot.com/
It work nicely.
@Blog Tactic
I am glad it did.
this is different install Google traslate.
good site about translation.
@M.Akramsaim12812
Thanks
that was really good
nice tips....
sudah saya follow
di tunggu kunjungan baliknya and follow baliknya.....
sukses selalu
thenk you
thanks a lot... this is very usefull....
www.teenagerx.co.cc
This post very informative and helpful...
guess I'm gonna put that on my blog!
Thanks!
Hi Greenlava,
The process seems very simple, but not quite so to a novice! When copy/pasting the working code above: “…working sample of actual translator flags and their codes…,” into the HTML page of my website, together with the flags, it shows up in the normal page view only as HTML code.
I have copied national flags from a free website and saved them to my hard drive with their relative language codes, used the basis of your working sample above linking to the flags on my hard drive, but the HTML code still does not embed as HTML code linking to the flags in the normal page view – it only shows as HTML code.
In another test, I copied the codes from your ‘Page Source’ page of the 23 flags – top right, and pasted the code into the HTML page of my website, but again the code comes out as HTML code in the normal page view page.
When I am given other HTML codes to embed into the HTML page of my website the codes always work in page view and uploaded to my server.
Can you be so kind and to explain what is going on here?
Can I use this for a regular website?
@Matt
Yes you can.
thank you for the information.. nice post.. :)
appreciated!
absolutely fantastic. you make my blog up.
Nice Info.......!!!
Thank for this imfo..very nice post!!
thanks for the very informative post! :)
Yay! You can now view grogb.blogspot.com in german :) Thank you so much!
thanks.......for the
tips.............
I looked for this over and over but don't see step 3 on my gadget adding menu. The only thing I can do is select from or search from a gadget list. Am I looking in the wrong place???
Thanks!
1.Go to Dashboard > Design > Page Elements.
2.Click Add A Gadget.
3.In Add A Gadget window, select HTML/Javascript.
@Anonymous
You're in the right place. Just scroll down the list until you see the HTML/Javascript gadget.
Thanks for sharing I added it works good.
I failed to add widget for translation of my contents into french.
@Hosne
Use this code:
[a class="translate-flag" onclick="href='http://translate.google.com/translate?u='+encodeURIComponent(location.href)+'&langpair=en|fr&hl=fr'" title="Translate to French"][img border="0" style="cursor: pointer;" src="FlagIconURL" /][/a]
don't forget to replace FlagIconURL with the link to the flag.
Thanks for this information...I use this translater to accomplish many of my tasks.
the translation for the simple words are accurate
but for long sentences and paragraphs it wouldn't make sense :(
anyways... thank you so much I will use this in the future :)
I found an excellent tool that allows you to translate with Google and Microsoft at the same time.This comment did in Spanish using: http://www.traductor--google.com
wow! this article is more than useful. thanks.
will this widget affect blog load time? so that i will add this to my blog
This script takes me to the google translator page. I want the script which translate the page in my website itself.
Google now has updated to 50 languages. If i use ur method, does it still work?
Thanks for sharing this widget with us . I've been looking for a good translation widget for a while.It really helpful.keep it up
@Shank
Yes it will still work.
Post a Comment
We love to hear from you! Leave us a comment.
To ensure proper display, HTML/XML/Javascript need to be escaped first using this escape tool.