Previous Thread
Next Thread
Print Thread
Rate Thread
#57915 12/22/2004 9:33 AM
Joined: Jun 2001
Posts: 729
Coder
Coder
Offline
Joined: Jun 2001
Posts: 729
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>

Sponsored Links
Joined: Jan 2003
Posts: 3,456
Likes: 2
Master Hacker
Master Hacker
Offline
Joined: Jan 2003
Posts: 3,456
Likes: 2
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

Joined: Jun 2001
Posts: 729
Coder
Coder
Offline
Joined: Jun 2001
Posts: 729
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.

Joined: Jan 2003
Posts: 3,456
Likes: 2
Master Hacker
Master Hacker
Offline
Joined: Jan 2003
Posts: 3,456
Likes: 2
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


Link Copied to Clipboard
Donate Today!
Donate via PayPal

Donate to UBBDev today to help aid in Operational, Server and Script Maintenance, and Development costs.

Please also see our parent organization VNC Web Services if you're in the need of a new UBB.threads Install or Upgrade, Site/Server Migrations, or Security and Coding Services.
Recommended Hosts
We have personally worked with and recommend the following Web Hosts:
Stable Host
bluehost
InterServer
Visit us on Facebook
Member Spotlight
AllenAyres
AllenAyres
Texas
Posts: 21,079
Joined: March 2000
Forum Statistics
Forums63
Topics37,573
Posts293,925
Members13,849
Most Online5,166
Sep 15th, 2019
Today's Statistics
Currently Online
Topics Created
Posts Made
Users Online
Birthdays
Top Posters
AllenAyres 21,079
JoshPet 10,369
LK 7,394
Lord Dexter 6,708
Gizmo 5,833
Greg Hard 4,625
Top Posters(30 Days)
Top Likes Received
isaac 82
Gizmo 20
Brett 7
WebGuy 2
Morgan 2
Top Likes Received (30 Days)
None yet
The UBB.Developers Network (UBB.Dev/Threads.Dev) is ©2000-2024 VNC Web Services

 
Powered by UBB.threads™ PHP Forum Software 8.0.0
(Preview build 20221218)