UBB.Dev
Posted By: 1QuickSI UBB Translations by Google - 12/22/2004 4:33 PM
I have been trying to get this working but only seem to be able to get the root of the domain and not UBB itself. Any ideas on how to incorporate this? I have flags so would like to release this as a modification.

Code
<table border="0" align="center" cellpadding="3" cellspacing="0">
<tr>
<td><div align="center"><a href="http://www.YourDomain.com/"><img src="/images/languages/english.gif" ALT="English" border="0"></a></div></td>
<td><div align="center"><a href="http://translate.google.com/translate?u=http://www.YourDomain.com/&langpair=en&hl=fr"><img src="/images/languages/french.gif" ALT="French" border="0"></a></div></td>
<td><div align="center"><a href="http://translate.google.com/translate?u=http://www.YourDomain.com/&langpair=en&hl=es"><img src="/images/languages/spanish.gif" ALT="Spanish" border="0"></a></div></td>
</tr>
<tr>
<td><div align="center"><a href="http://translate.google.com/translate?u=http://www.YourDomain.com/&langpair=en&hl=de"><img src="/images/languages/german.gif" ALT="German" border="0"></a></div></td>
<td><div align="center"><a href="http://translate.google.com/translate?u=http://www.YourDomain.com/&langpair=en&hl=it"><img src="/images/languages/italian.gif" ALT="Italian" border="0"></a></div></td>
<td><div align="center"><a href="http://translate.google.com/translate?u=http://www.YourDomain.com/&langpair=en|pt"><img src="/images/languages/portuguese.gif" ALT="Portuguese" border="0"></a></div></td>
</tr>
</table>
Posted By: Ian Spence Re: UBB Translations by Google - 12/22/2004 8:48 PM
Code
<script type="text/javascript">
<!--
//<![CDATA[

// Google Translation Addon for UBB.classic, and technically, any other site.

var language_base = "en";
var images_base = "/images/languages/";
var languages = new Array("english", "french", "spanish", "german", "italian", "portuguese");
var images_alt = new Array("English", "French", "Spanish", "German", "Italian", "Portuguese");
var languages_code = new Array("en", "fr", "es", "de", "it", "pt");
var image_extension = ".gif";

var here = document.location.href ? document.location.href : document.location;
var url = here.split("#");
here = url[0];

function makeLink(lang) {
// First, make the anchor
var a = document.createElement("A");
a.href = "http://translate.google.com/translate?u=";
a.href += here;
a.href += "&langpaig=" + language_base;
a.href += "&hl=" + languages_code[lang];

// No need to translate english to english
if(languages_code[lang] == language_base) {
a.href = here;
}

// Now, make the image.
var img = document.createElement("IMG");
img.src = images_base + languages[lang] + image_extension;
img.alt = images_alt[lang];

a.appendChild(img);
document.getElementById("google-" + languages[lang]).appendChild(a);
}

//]]>
//-->
</script>

<table id="google-translate">
<tr>
<td><span id="google-english"></span></td>
<td><span id="google-french"></span></td>
<td><span id="google-spanish"></span></td>
</tr>
<tr>
<td><span id="google-german"></span></td>
<td><span id="google-italian"></span></td>
<td><span id="google-portuguese"></span></td>
</tr>
</table>
<script type="text/javascript">
<!--
//<![CDATA[

for(x=0;x<languages.length;x++) {
makeLink(x);
}

//]]>
//-->
</script>
Will do it without any modifications to the actual code.
Requires the user to have javascript enable though
Posted By: 1QuickSI Re: UBB Translations by Google - 12/29/2004 10:14 PM
Neat... How would I get this say to appear just above the login/profile, search, forum home, etc box? I would want text "Translations by Google" and the flags just under that.

I am pretty sure it is in public_common.pl Just no idea how to make it appear.
Posted By: Ian Spence Re: UBB Translations by Google - 12/30/2004 12:08 AM
Code
<script type="text/javascript">
<!--
//<![CDATA[

// Google Translation Addon for UBB.classic, and technically, any other site.

var language_base = "en";
var images_base = "/hostboard/images/languages/";
var languages = new Array("english", "french", "spanish", "german", "italian", "portuguese");
var images_alt = new Array("English", "French", "Spanish", "German", "Italian", "Portuguese");
var languages_code = new Array("en", "fr", "es", "de", "it", "pt");
var image_extension = ".gif";

var here = document.location.href ? document.location.href : document.location;
var dyn_fix = here.substr(0, here.length - 4);
if((dyn_fix + ".php" == here) &#0124;&#0124; (dyn_fix + ".cgi" == here)) {
here += "/";
}
var url = here.split("#");
here = url[0];
here = here.replace(/\?\//, "/");

function makeLink(lang) {
// First, make the anchor
var a = document.createElement("A");
a.href = "http://translate.google.com/translate?u=";
a.href += here;
a.href += "&langpaig=" + language_base;
a.href += "&hl=" + languages_code[lang];

// No need to translate english to english
if(languages_code[lang] == language_base) {
a.href = here;
}

// Now, make the image.
var img = document.createElement("IMG");
img.src = images_base + languages[lang] + image_extension;
img.alt = images_alt[lang];

a.appendChild(img);
document.getElementById("google-" + languages[lang]).appendChild(a);
}

//]]>
//-->
</script>

<table id="google-translate">
<tr>
<td><span id="google-english"></span></td>
<td><span id="google-french"></span></td>
<td><span id="google-spanish"></span></td>
</tr>
<tr>
<td><span id="google-german"></span></td>
<td><span id="google-italian"></span></td>
<td><span id="google-portuguese"></span></td>
</tr>
</table>
<script type="text/javascript">
<!--
//<![CDATA[

for(x=0;x<languages.length;x++) {
makeLink(x);
}

//]]>
//-->
</script>
Updated code to prevent google from not parsing dynamic pages
© UBB.Developers