Automatically redirect to Google Translator when certain domain TLD used

Status
Not open for further replies.

Mr. tech

In Runtime
Messages
384
I have set-up Google Translation on a clients website. He currently owns the .net for his domain and also wants to buy other country TLDs such as .de, .cn etc etc He wants it so that when you load the website using another countries TLD, it will redirect and translate the page.

I've got a PHP function that works except it redirects over and over because even though Google loads the website in a framed page, it doesn't give any $_GET or $_POST variables so I can determine whether it has already been redirected or not. Am I making sense? My code below?

PHP:
function curPageURL() {
    $pageURL = 'http';
    if ($_SERVER["HTTPS"] == "on")
        $pageURL .= "s";
    $pageURL .= "://";
    if ($_SERVER["SERVER_PORT"] != "80")
        $pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"];
    else
        $pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];
    return $pageURL;
}
if (preg_match('|\.de|', $_SERVER["SERVER_NAME"], $match)) {
    header('location: http://translate.google.com/translate?u=' . urlencode(curPageURL()) . '&hl=en&langpair=auto|de&tbb=1&ie=UTF-8');
}
Or is there a PHP function that allows you to detect the content language so I can check to see if it is no longer english and has been translated? Any input would be fantastic!

I hope this message makes sense...
 
Status
Not open for further replies.
Back
Top Bottom