Smarty Forum Index Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon.

my translator template

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> General
View previous topic :: View next topic  
Author Message
monotreme
Smarty Regular


Joined: 22 Feb 2004
Posts: 97
Location: USA

PostPosted: Fri Mar 28, 2008 1:25 am    Post subject: my translator template Reply with quote

I just made a translator bar using google translation. It's general enough that I wanted to share it . I wanted it not to take up much screen real estate. and I wanted the titles to say Translate to XXX in the language. First the css:

Code:

img.social_img
{
   padding: 0px;
   margin: 0px;
   border: none;
}


Now the smarty template:
Code:

{* xlatbar *}
<div id='xlatbar' style='margin-left: auto; margin-right:auto;'>
<a href='http://translate.google.com/translate?u={$appurl}{$uri|escape:"url"}&langpair=en%7Car&hl=en&ie=UTF8' title="ترجمة الى العربية"><img class='social_img' src="{$imgurl}/flags/sa.png" height="11" width="16" alt="sa flag" /></a>  {* Arabic *}
<a href='http://translate.google.com/translate?u={$appurl}{$uri|escape:"url"}&langpair=en%7Czh-CN&hl=en&ie=UTF8' title="翻译,以中文简体"><img class='social_img' src="{$imgurl}/flags/cn.png" height="11" width="16" alt="cn flag" /></a>  {* Chinese - simplified *}
<a href='http://translate.google.com/translate?u={$appurl}{$uri|escape:"url"}&langpair=en%7Czh-TWde&hl=en&ie=UTF8' title="翻译,以中文繁体"><img class='social_img' src="{$imgurl}/flags/tw.png" height="11" width="16" alt="tw flag" /></a>  {* Chinese - traditional *}
<a href='http://translate.google.com/translate?u={$appurl}{$uri|escape:"url"}&langpair=en%7Cnl&hl=en&ie=UTF8' title="Vertalen naar het Nederlands"><img class='social_img' src="{$imgurl}/flags/nl.png" height="11" width="16" alt="nl flag" /></a>  {* Dutch *}
<a href='http://translate.google.com/translate?u={$appurl}{$uri|escape:"url"}&langpair=en%7Cfr&hl=en&ie=UTF8' title="Traduire en français"><img class='social_img' src="{$imgurl}/flags/fr.png" height="11" width="16" alt="fr flag" /></a>  {* French *}
<a href='http://translate.google.com/translate?u={$appurl}{$uri|escape:"url"}&langpair=en%7Cde&hl=en&ie=UTF8' title="Deutsch zu übersetzen"><img class='social_img' src="{$imgurl}/flags/de.png" height="11" width="16" alt="de flag" /></a>  {* German *}
<a href='http://translate.google.com/translate?u={$appurl}{$uri|escape:"url"}&langpair=en%7Cgf&hl=en&ie=UTF8' title="μεταφρασει σε ελληνικες"><img class='social_img' src="{$imgurl}/flags/gr.png" height="11" width="16" alt="gr flag" /></a>  {* Greek *}
<a href='http://translate.google.com/translate?u={$appurl}{$uri|escape:"url"}&langpair=en%7Cit&hl=en&ie=UTF8' title="Tradurre in italiano"><img class='social_img' src="{$imgurl}/flags/it.png" height="11" width="16" alt="it flag" /></a>  {* Italian *}
<a href='http://translate.google.com/translate?u={$appurl}{$uri|escape:"url"}&langpair=en%7Cjpe&hl=en&ie=UTF8' title="を日本語に訳す"><img class='social_img' src="{$imgurl}/flags/jp.png" height="11" width="16" alt="jp flag" /></a>  {* Japanese *}
<a href='http://translate.google.com/translate?u={$appurl}{$uri|escape:"url"}&langpair=en%7Cko&hl=en&ie=UTF8' title="한국의 번역"><img class='social_img' src="{$imgurl}/flags/kr.png" height="11" width="16" alt="kr flag" /></a>  {* Korean *}
<a href='http://translate.google.com/translate?u={$appurl}{$uri|escape:"url"}&langpair=en%7Cpt&hl=en&ie=UTF8' title="Traduzir para Português"><img class='social_img' src="{$imgurl}/flags/pt.png" height="11" width="16" alt="pt flag" /></a>  {* Portuguese *}
<a href='http://translate.google.com/translate?u={$appurl}{$uri|escape:"url"}&langpair=en%7Cru&hl=en&ie=UTF8' title="перевода на русский"><img class='social_img' src="{$imgurl}/flags/ru.png" height="11" width="16" alt="ru flag" /></a>  {* Russian *}
<a href='http://translate.google.com/translate?u={$appurl}{$uri|escape:"url"}&langpair=en%7Ces&hl=en&ie=UTF8' title="Traducir al español"><img class='social_img' src="{$imgurl}/flags/es.png" height="11" width="16" alt="es flag" /></a>  {* Spanish *}
</div>


and the flags themselves I can't do an attachment here but PM me if you want them they are public domain
The vars you have to set are {$imgurl} the root where you keep your images,
{$appurl} the main url of your domain, and {$uri} which is just $_SERVER['REQUEST_URI']
_________________
Your online 24/7 box office
http://www.tixrus.us
Back to top
View user's profile Send private message Visit poster's website
monotreme
Smarty Regular


Joined: 22 Feb 2004
Posts: 97
Location: USA

PostPosted: Fri Mar 28, 2008 5:14 am    Post subject: correction Reply with quote

just to be truly anal you should escape the {$appurl} variable as well. It works without, but I think it will be more robust if you secape it.
_________________
Your online 24/7 box office
http://www.tixrus.us
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> General All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group
Protected by Anti-Spam ACP