X-Cart: shopping cart software

X-Cart forums (https://forum.x-cart.com/index.php)
-   Dev Questions (https://forum.x-cart.com/forumdisplay.php?f=20)
-   -   Language Translation box using google - simple mod (https://forum.x-cart.com/showthread.php?t=36452)

ShishaPipeUK 01-01-2008 04:17 AM

Language Translation box using google - simple mod
 
1 Attachment(s)
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 Attachment 705.

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 - Attachment 705

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.

GTXPC 02-21-2008 02:32 AM

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

kerri 07-16-2008 11:29 AM

Re: Language Translation box using google - simple mod
 
Does anyone has a Chinese language pack in dropdown?

fropirate 07-16-2008 11:40 AM

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.


All times are GMT -8. The time now is 08:52 PM.

Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.