1
Jharis
help with this script
  • 2006/1/20 7:45

  • Jharis

  • Just can't stay away

  • Posts: 488

  • Since: 2005/2/13


Guys,

Here's a nice php script for google translation. When following the authors suggestions I upload a folder such as.

translate -- to a directory on my site
-- a seperate folder for each language contains a php script for that particular language

I am using multimenu to diplay the language icons and using a relative url that points to the language folder containing the script.

Works great, but only translates the first page. When I click on links deeper into my site I'm back into english.

When I click on an icon to translate while in a subpage I get dumped back to the main page.

What am I missing? Is there a better way to do this. Help would be appreciated.

Here's my site

Here's a copy of the script.

<?php
$translator_base_url = 'http://translate.google.com/translate_c?hl=en&prev=/language_tools&ie=UTF-8&oe=UTF-8&langpair=en%7C';


@set_time_limit(180);
$language = "es";
$MySiteURL = "http://www.sbe38.org";
$url = $MySiteURL.$_SERVER["QUERY_STRING"];
if(function_exists('curl_init')) {
$ch = curl_init();
$resource = $translator_base_url . $language . '&u=' . $url;
curl_setopt($ch, CURLOPT_URL, $resource);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)"); // Increase IE Stats! Google dislikes non-browser user agents :(
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1); // return into a variable
$GetPage = curl_exec($ch);
curl_close($ch);
$GetPage = str_replace("&", "&", $GetPage);
$GetPage = str_replace("&prev=/language_tools", "", $GetPage);
$GetPage = str_replace("http://216.239.39.104/translate_c?hl=en&ie=UTF-8&oe=UTF-8&langpair=en%7C".$language."&u=".$MySiteURL, $MySiteURL."/translate/".$language."/?", $GetPage);
$GetPage = str_replace("http://216.239.37.104/translate_c?hl=en&ie=UTF-8&oe=UTF-8&langpair=en%7C".$language."&u=".$MySiteURL, $MySiteURL."/translate/".$language."/?", $GetPage);
$GetPage = str_replace("charset=iso-8859-1", "charset=utf-8", $GetPage);
$GetPage = str_replace("%23", "#", $GetPage);
$GetPage = str_replace("%3F", "?", $GetPage);
$GetPage = str_replace("/translate/".$language."/?/translate", "/translate", $GetPage);
echo $GetPage;
} else {
echo "Temporary failure. Please try again later. Sorry for the inconvenience.";
}
?>


don (el paso)
motto - green chili for everything!

2
JMorris
Re: help with this script
  • 2006/1/20 11:57

  • JMorris

  • XOOPS is my life!

  • Posts: 2722

  • Since: 2004/4/11


Have you tried including mainfile.php and then using XOOPS variables to assign the $MySiteURL variable.

I would think that $url = $MySiteURL.$_SERVER["QUERY_STRING"]; would pick up the query string, but apparently not.

At any rate, I would definately be interested in seeing the finished code when you get it working.

Best Regards,

James
Insanity can be defined as "doing the same thing over and over and expecting different results."

Stupidity is not a crime. Therefore, you are free to go.

3
mawi27
Re: help with this script
  • 2006/1/20 13:00

  • mawi27

  • Friend of XOOPS

  • Posts: 103

  • Since: 2006/1/1 1


Hi jharis,

Pls excuse me, but I visited your page and could not stop to laugh. No offense ment!

The reason is the "german" output of the script. not your site

For example: "Published by Don Bohrer "
is translated to: "Vorbei veröffentlicht ziehen Sie Bohrer"
I will try to translate this back to english: "gone published pull the drill"
The german special character 'ö' is shown as 'ö' as every special character on the page is a bit weird.

And believe me, i found not one correct sentence.

I think this script (esp. german) is not yet good enough to spend some time on it.
If you find another way, pls feel free to contact me for a look on the german content.

Marco
--
Match Dart!
Darts Ranking, News, Videos, Forum and more

4
Jharis
Re: help with this script
  • 2006/1/20 17:01

  • Jharis

  • Just can't stay away

  • Posts: 488

  • Since: 2005/2/13


Morning guys,

James,
I will keep working on it, but might need some tips along the way. What I really need is the "php book for dummies" :)

Marco,
lol, I was hopeful. I will see if there is a better way to do things. Guess google doesn't get everythig right.


don (el paso)
motto - green chili for everything!

5
mawi27
Re: help with this script
  • 2006/1/20 17:09

  • mawi27

  • Friend of XOOPS

  • Posts: 103

  • Since: 2006/1/1 1


Hi Don,

the problem is, that the link buttons on the site do not make use of the translation script.
So you probably have to create a set of themes / menus etc. for each language you want to support.

There is a kind of multilanguage hack, maybe this one can help you.

Good luck,
Marco
--
Match Dart!
Darts Ranking, News, Videos, Forum and more

Login

Who's Online

137 user(s) are online (79 user(s) are browsing Support Forums)


Members: 0


Guests: 137


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: May 31
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits