Follow us on Twitter X-Cart on Facebook Wiki
Shopping cart software Solutions for online shops and malls
 

Language Translation box using google - simple mod

 
Reply
   X-Cart forums > X-Cart 4 > Dev Questions
 
Thread Tools Search this Thread
  #1  
Old 01-01-2008, 04:17 AM
  ShishaPipeUK's Avatar 
ShishaPipeUK ShishaPipeUK is offline
 

Senior Member
  
Join Date: Jul 2005
Location: London, England.
Posts: 118
 

Smile Language Translation box using google - simple mod

As the web has spread across the world, more and more web pages are available in languages other than English. Google provides a translation link and language tools to enable you to read pages written in unfamiliar languages.
Google translates pages by computer. Machine translation is difficult to do well and tends not to be as clear as human translation. But it can give you the gist of what’s written or suggestions for translating something into another language.

This works fine with Mozilla Firefox, opera9 and explorer

Here is a very simple modification for a language translation box to be placed on your main x-cart ENGLISH (EN) home page.

First of all it looks like this:
http://www.shishapipe.net/images/xcartlangbox.jpg
If you want to see it in action go to http://www.shishapipe.net/shopcart/home.php it's on the left hand side half way down.


All you need is the NEW language.tpl file which is below and also attached xcart_language.zip.

Save this file in the directory skin1/customer/language.tpl

language.tpl
HTML Code:
{capture name=language} <table width="100%" border="0"> <tr> <td><div align="center"><a href="http://64.233.179.104/translate_c?hl=en&ie=UTF-8&oe=UTF-8&langpair=en%7Cfr&u=http://www.YOUR_WEB_ADDRESS/home.php" target="_blank"><img border="0" src="{$ImagesDir}/french.gif" alt="Fran&ccedil;ais /French" width="30" height="20" /> <br /> Fran&ccedil;ais</a></div></td> <td><div align="center"><a href="http://64.233.179.104/translate_c?hl=en&ie=UTF-8&oe=UTF-8&langpair=en%7Cde&u=http://www.YOUR_WEB_ADDRESS/home.php" target="_blank"><img border="0" src="{$ImagesDir}/german.gif" alt="Deutsch/German" width="30" height="20" /> <br /> Deutsch</a></div></td> </tr> <tr> <td><div align="center"><a href="http://64.233.179.104/translate_c?hl=en&ie=UTF-8&oe=UTF-8&langpair=en%7Ces&u=http://www.YOUR_WEB_ADDRESS/home.php" target="_blank"><img border="0" src="{$ImagesDir}/spanish.gif" alt="Espa&ntilde;ol" width="30" height="20" /> <br /> Espa&ntilde;ol</a></div></td> <td><div align="center"><a href="http://64.233.179.104/translate_c?hl=en&ie=UTF-8&oe=UTF-8&langpair=en%7Cru&u=http://www.YOUR_WEB_ADDRESS/home.php" target="_blank"><img border="0" src="{$ImagesDir}/russian.gif" alt="Русский" width="30" height="20" /> <br /> Русский</a></div></td> </tr> <tr> <td><div align="center"><a href="http://64.233.179.104/translate_c?hl=en&ie=UTF-8&oe=UTF-8&langpair=en%7Car&u=http://www.YOUR_WEB_ADDRESS/home.php" target="_blank"><img border="0" src="{$ImagesDir}/arabic.gif" alt="العربية" width="30" height="20" /> <br /> العربية</a></div></td> <td><div align="center"><a href="http://64.233.179.104/translate_c?hl=en&ie=UTF-8&oe=UTF-8&langpair=en%7Cpt&u=http://www.YOUR_WEB_ADDRESS/home.php" target="_blank"><img border="0" src="{$ImagesDir}/portugues.gif" alt="Portugu&ecirc;s" width="30" height="20" /> <br /> Portugu&ecirc;s</a></div></td> </tr> <tr> <td><div align="center"><a href="http://64.233.179.104/translate_c?hl=en&ie=UTF-8&oe=UTF-8&langpair=en%7Cko&u=http://www.YOUR_WEB_ADDRESS/home.php" target="_blank"><img border="0" src="{$ImagesDir}/korean.gif" alt="한국어" width="30" height="20" /> <br /> 한국어</a></div></td> <td><div align="center"><a href="http://64.233.179.104/translate_c?hl=en&ie=UTF-8&oe=UTF-8&langpair=en%7Cit&u=http://www.YOUR_WEB_ADDRESS/home.php" target="_blank"><img border="0" src="{$ImagesDir}/italian.gif" alt="Italiano" width="30" height="20" /> <br /> Italiano</a></div></td> </tr> <tr> <td><div align="center"><a href="http://64.233.179.104/translate_c?hl=en&langpair=en%7Cnl&u=http://www.YOUR_WEB_ADDRESS/home.php" target="_blank"><img border="0" src="{$ImagesDir}/dutch.gif" alt="Nederland" width="30" height="20" /> <br /> Nederland</a></div></td> <td><div align="center"><a href="http://64.233.179.104/translate_c?hl=en&langpair=en%7Czh-CN&u=http://www.YOUR_WEB_ADDRESS/home.php" target="_blank"><img border="0" src="{$ImagesDir}/tw.gif" alt="台灣 / Chinese" width="30" height="20" /> <br /> 台灣</a></div></td> </tr> </table> {/capture} { include file="menu.tpl" dingbats="dingbats_categorie.gif" menu_title=$lng.lbl_languages menu_content=$smarty.capture.language }

Information on items in the above code for you to understand the code better:

What is http://64.233.179.104/translate_c?hl=en ?
This is the IP address for the Google translate URL, this tells Google that we are translating from a English page (en)

What is UTF-8 in the code ?
UTF-8 (8-bit UCS/Unicode Transformation Format) is a variable-length character encoding for Unicode. It is able to represent any character in the Unicode standard, yet the initial encoding of byte codes and character assignments for UTF-8 is backwards compatible with ASCII. For these reasons, it is steadily becoming the preferred encoding for e-mail, web pages, and other places where characters are stored or streamed.

What is langpair=en%7Cfr in the code ?
In the above code we have the language pairs:

langpair=en%7Cfr = English (en) to French (fr)
langpair=en%7Cde = English (en) to Deutsch (de)
langpair=en%7Ces = English (en) to Espanol (es)
langpair=en%7Cru = English (en) to Russian (ru)
langpair=en%7Car = English (en) to Arabic (ar)
langpair=en%7Cpt = English (en) to Portugues (pt)
langpair=en%7Cko = English (en) to Korea (ko)
langpair=en%7Cit = English (en) to Italian (it)

What is http://www.YOUR_WEB_ADDRESS/home.php ?
This is the url of the page you want Google to start to translate.

Next you need the images for the flags (Image size 30 x 20 pixels), Because you can only attach 4 images to a post in this forum I have included a downloadable file which has the language.tpl file included - xcart_language.zip

You can get more flag images from http://www.google.com/language_tools (scroll down and you can find 159 flags)


http://www.shishapipe.net/shopcart/images/french.gif http://www.shishapipe.net/shopcart/images/italian.gif http://www.shishapipe.net/shopcart/images/german.gif

All you need to do now is edit your skin1/customer/home.tpl by placing a link where you want the language.tpl file to be displayed.

Code:
{include file="customer/language.tpl"}

That's it, you DO NOT need to make a language label as there is already one in the x-cart default software.

If anyone has any other web site translation codes better than this, please post them here for us to look at. For example the Alta Vista Babel Fish site, at http://www.altavista.com/help/free/free_searchbox_transl maybe better than Google for translating, I really do not know but always open to any suggestions on either the above code or other sites.
__________________
Apache/2.0.55 (Red Hat) & MYSQL Server: 5.0.24
PERL: 5.008005 / PHP: 4.4.4 - 4.3.1 X-CART

Shop carts at
http://www.nightscene.co.uk/shop/home.php
http://www.theshisha.net/shopcart/home.php
http://www.system-maintenance.com/maint/home.php
http://www.tabac4u.com
Reply With Quote
  #2  
Old 02-21-2008, 02:32 AM
 
GTXPC GTXPC is offline
 

Member
  
Join Date: Feb 2005
Location: USA Ca
Posts: 15
 

Default Re: Language Translation box using google - simple mod

can you post the code that you have in your site, Ican't get it to be in dropdown like yours
__________________
4.0.16
Reply With Quote
  #3  
Old 07-16-2008, 11:29 AM
 
kerri kerri is offline
 

Newbie
  
Join Date: Jul 2008
Posts: 4
 

Default Re: Language Translation box using google - simple mod

Does anyone has a Chinese language pack in dropdown?
__________________
Version 4.1.10
Reply With Quote
  #4  
Old 07-16-2008, 11:40 AM
 
fropirate fropirate is offline
 

Member
  
Join Date: May 2008
Posts: 24
 

Default Re: Language Translation box using google - simple mod

The drop down language thing on his site is the original xcart language module. The thing he's posting about is farther down the page. It's listed in a menu box like bestsellers.
__________________
X-Cart Gold 4.1.10
www.oldworlddistributors.com - Live Store
www.coppercakestands.com - Live Store
--
My Website - www.frodesigns.com
Reply With Quote
Reply
   X-Cart forums > X-Cart 4 > Dev Questions



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -8. The time now is 04:19 PM.

   

 
X-Cart forums © 2001-2020