GoFuckYourself.com - Adult Webmaster Forum

GoFuckYourself.com - Adult Webmaster Forum (https://gfy.com/index.php)
-   Fucking Around & Business Discussion (https://gfy.com/forumdisplay.php?f=26)
-   -   Automatic translation of pages that recognise IP locations (https://gfy.com/showthread.php?t=921782)

Clean_Franck 08-14-2009 10:01 AM

Automatic translation of pages that recognise IP locations
 
I am throwing this out there, but is there such a service that translates your web pages automatically for you when a surfer logs on from a different country?

For example the type of thing google has, it recognizes where the user is from throws them to the french site http://www.google.fr and the google page is in French.

Can this type of thing be done or does everything have to be translated manually?

mpahlca 08-14-2009 10:11 AM

not sure of a service, but you could do it in php with smarty and lang files using that it would auto transalte on whatever variable you so desired.

acctman 08-14-2009 10:25 AM

but what if an english reading person is traveling overseas or military person is viewing the page outside of the of the country he's from.

i guess it would work for majority of the viewers.

borked 08-14-2009 10:40 AM

IMO you should never present language-localised pages based on IP address, but based on the browser language settings. I'm in France, but I prefer to read English, so I set my browsers to default to En-en.

Web pages should respect my choice and not diss up French pages based on my IP address location.

Pete-KT 08-14-2009 10:52 AM

you should never translate by ip, you should translate based on the surfers language setting in there browser

Clean_Franck 08-15-2009 07:51 PM

Thanks for the advice regarding browser settings. To clarify however, this can be done automatically and I don't need to go through my pages with a translator having to do each and everyone of them popping them on a new page?

Are there any pages on how to set this up? I would not really know what to look for.

Clean_Franck 08-16-2009 06:10 AM

If someone could quickly help out old franck :)

SmokeyTheBear 08-16-2009 10:23 AM

What i would do is log your visitors languages and get an idea of the top languages , then work on getting some "real" translations for the major ones

make a file called languagelog.txt upload to root , chmod then drop this pgp into your index, this will log the different languages.
Code:

<?php
$lang = substr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2);
$fh2 = fopen("languagelog.txt", 'a+');
fwrite($fh2, "$lang\n");
fclose($fh2);
?>

it all depends on the type of site you have in how you would implement translation integration.

Could be as simple as a welcome message
if ($lang == "en"){ $welcomemessage = "Welcome to my site";}
if ($lang == "fr"){ $welcomemessage = "Bonjour tete a la merde";}

SmokeyTheBear 08-16-2009 10:36 AM

another idea is just to redirect certain languages to an online translator like babelfish that translates the page you're on
Code:


<?php
$mypage = "www.gfy.com/index.php";
$lang = substr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2);
if ($lang == "de"){
$url = "http://babelfish.yahoo.com/translate_url?doit=done&tt=url&intl=1&fr=bf-home&trurl=http%3A%2F%2F$mypage&lp=en_$lang&btnTrUrl=Translate";
header("Location: $url");
exit;
}

?>


SmokeyTheBear 08-16-2009 10:39 AM

what i would do is simply translate the words "translate this page" then put a link near the top that leads to an online translation service like babelfish.

SmokeyTheBear 08-16-2009 10:48 AM

something like this
Code:

<?php
$mypage = "www.gfy.com/index.php";
$lang = substr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2);
$url = "http://babelfish.yahoo.com/translate_url?doit=done&tt=url&intl=1&fr=bf-home&trurl=http%3A%2F%2F$mypage&lp=en_$lang&btnTrUrl=Translate";
if ($lang == "fr"){
$message = "Translate this page <- this should be in french";
}
if ($lang == "de"){
$message = "Translate this page <- this should be in german";
}
$translatelink = "<a href=\"$url\">$message</a>";
echo $translatelink;

?>


fris 08-16-2009 12:02 PM

I have this method setup in wordpress

Clean_Franck 08-16-2009 12:07 PM

Thankyou Smokey for your help.
I like the idea of real translations for visitors from the major countries who visit me site.

For the other countries though, what method would be best for my translated pages to appear based on their browser settings automatically and a page of mine created for that langauge.

E.g. the page is mysite.com/porn.html
And someone from Poland logs on with polish settings in his browser. I would then want a page created for him in polish that is under the url mysite.com/porn.html&pl

I am not sure whether that is the second or third method you posted and whether the online services allow this.

GT-Omar 08-16-2009 12:13 PM

Smokey hits nail on head!

Hey Smokey. When ever you have a chance can you hit me up. Would like to discuss a few things with with regards to this. See sig.

Clean Frank. If you're looking to translate into different languages let me know. We would be more than happy to help.

Clean_Franck 08-16-2009 02:11 PM

Hey for the moment I would like to just get automatic setup. Once I have some spare cash then I can go down the proper route. But just need to know how to go about it.

SmokeyTheBear 08-17-2009 12:01 AM

Quote:

Originally Posted by Clean_Franck (Post 16192223)
Hey for the moment I would like to just get automatic setup. Once I have some spare cash then I can go down the proper route. But just need to know how to go about it.

ok heres what this does

It grabs an glob of text like a welcome message from a txt file

en.txt for english
fr.txt for french
etc etc
if you dont have a txt file for that language it displays a link to translate the page in place of where the message would be ( KEEP IN MIND THE WORDS "TRANSLATE THIS PAGE" ARE IN ENGLISH )

Code:

<?php
$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"];
 }
$pageURL = urlencode($pageURL);
$lang = substr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2);
$lang = strtolower($lang);
$file="$lang.txt";

if (file_exists($file)) {
$message = file_get_contents("$file");
} else {
$message = "<a href=\"http://babelfish.yahoo.com/translate_url?doit=done&tt=url&intl=1&fr=bf-home&trurl=$pageURL&lp=en_$lang&btnTrUrl=Translate\">TRANSLATE THIS PAGE</a>";

}

echo $message;

?>


using this method you could add a txt file message for each language as you add them without altering those code.

the drawback is they must be able to read the words "translate this page" in english to understand they can translate the page.
------------------------------------------------
below is some diff code , this will automatically redirect the user to the babelfish translator if you dont have a message .txt for that language

Code:

<?php
$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"];
 }
$pageURL = urlencode($pageURL);
$lang = substr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2);
$lang = strtolower($lang);
$file="$lang.txt";

if (file_exists($file)) {
$message = file_get_contents("$file");
} else {
$message = "<script>top.location.href = \"http://babelfish.yahoo.com/translate_url?doit=done&tt=url&intl=1&fr=bf-home&trurl=$pageURL&lp=en_$lang&btnTrUrl=Translate\";</script>";

}

echo $message;

?>

p.s. i havent tested either of these out, if you have a problem just let me know.


so for example on gfy where it says "where the industry meets" if you put this code right where it says that then made a txt file called en.txt for english and put "where the industry meets" then made a few more with proper translation for popular languages , if someone visited this page they would see the messagein their language, unless gfy didnt have their particular language translated then it would send them to the babelfish translator

below is an example of the babelfish page translator.. translating gfy.com to french

http://babelfish.yahoo.com/translate...rUrl=Translate

Clean_Franck 08-17-2009 10:23 AM

Thanks very much Smokey, Will get on this right now


All times are GMT -7. The time now is 06:23 PM.

Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2025, vBulletin Solutions, Inc.
©2000-, AI Media Network Inc