php forum
php mysql forum
php mysql smarty
 
Topic Options
#57915 - 12/22/04 08:33 AM UBB Translations by Google
1QuickSI Offline
Coder

Registered: 06/10/01
Posts: 705
Loc: CT
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>
_________________________
...Steven
Hostboard.com
Running UBB v6.1.0.4
Doing what NO other UBB in the world is doing.
The first & only production UBB powered by MySQL.

Top
#57916 - 12/22/04 12:48 PM Re: UBB Translations by Google
Ian Spence Offline
Master Hacker

Registered: 01/25/03
Posts: 3765
Loc: Saint Johns, PA
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
_________________________
Code monkey like Fritos

Top
#57917 - 12/29/04 02:14 PM Re: UBB Translations by Google
1QuickSI Offline
Coder

Registered: 06/10/01
Posts: 705
Loc: CT
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.
_________________________
...Steven
Hostboard.com
Running UBB v6.1.0.4
Doing what NO other UBB in the world is doing.
The first & only production UBB powered by MySQL.

Top
#57918 - 12/29/04 04:08 PM Re: UBB Translations by Google
Ian Spence Offline
Master Hacker

Registered: 01/25/03
Posts: 3765
Loc: Saint Johns, PA
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
_________________________
Code monkey like Fritos

Top


Moderator:  Gizmo 
Who's Online
0 registered (), 31 Guests and 16 Spiders online.
Key: Admin, Global Mod, Mod
Shout Box

Latest Posts
Forum 'Trader Ratings'.
by blaaskaak
11/20/08 08:27 AM
Problems reading a lot of old posts here
by Ruben Rocha
11/18/08 04:33 PM
PhotoPost BB Code Popup
by Iann128
11/15/08 01:24 PM
Customization needed
by Gizmo
11/12/08 12:28 PM
Team UBBDev Rides Again!
by AllenAyres
11/11/08 02:16 PM
Active Topics.
by AllenAyres
11/11/08 02:13 PM
Looking for a simple upload script
by AllenAyres
11/11/08 02:12 PM
New Mods
Forum 'Trader Ratings'.
by McLemore
11/19/08 02:14 PM
[7.4] Keep log of custom title changes
by blaaskaak
10/27/08 07:51 AM
User Authentication Class
by
01/19/07 02:59 PM
Multiple Identity Detector
by
12/30/06 06:39 PM
PhotoPost BB Code Popup
by
11/06/06 05:43 PM
Newest Members
Begbie, cenk, MATTO, DougMMcts, tim Anderson
13361 Registered Users
Top Posters
AllenAyres 25448
JoshPet 11330
Rick 8372
LK 7396
Lord Dexter 6503
Greg Hard 5533
Charles Capps 5438

 

 

 
fusionbb message board php hacks