Results 1 to 6 of 6

Thread: Multilanguage translation on the fly

  1. #1
    Join Date
    Aug 2004
    Posts
    21

    Default Multilanguage translation on the fly

    OK here goes...

    first, what does this do? it checks the location of the viewers browser for identification based on their IP address. if the user is from outside of an english speaking country then the page sends a command to babelfish online translation corresponding to the location of the IP. it will translate the entire site as long as the links are within the same domain... all on the fly!
    this script uses jscript code modified from geobytes. unilimited numbers of languages and redirects can be added provided they are available from the translation site.

    an example of this implemented is at mtnprops. if your from an english speaking country then chances are you are not going to be redirected to a translated page.... for this reason, manual translation links are located in the upper right portion of the screen. they perform the same concept without automatic redirection. should you also be interested in the code for that, i will try to package something together for all.

    and onto the goods...

    open the index.php in your root file and insert the following code after the first <?php include ?> (you may or may not have other includes so it will not look exactly as it does here. the code will also be before the first <body> tag.

    ...and don't forget to replace the "YOUR.URL.HERE" everywhere within the code so you don't get redirected to http://YOUR.URL.HERE.COM

    <head>
    <script language="Javascript" src="http://gd.geobytes.com/Gd?after=-1"></script>
    <script language="javascript">
    var sSpanishLocations="ES,MX,GT,SV,HN,NI,CR,EC,PE,CU,D O,PR,PA,VE,CO,BO,AR,CL,PY,UY";
    var sGermanLocations="DE,AT,CH";
    var sFrenchLocations="FR,BE";
    var sItalianLocations="IT";
    var sPortugueseLocations="PO,BR";
    var sDutchLocations="NL";
    var sRussianLocations="RU,SK,,BY,SI,UZ";
    // additional language redirection bases can be added here
    // use country codes to define which language the user will be redirected to
    // if you wanted to add chinese language you would ad the following
    // var sChineseLocations="CH";
    if(typeof(sGeobytesLocationCode)!="undefined")
    {
    var sCountryCode=sGeobytesLocationCode.substring(0,2);
    if(sCountryCode!="US"&&sCountryCode!="UK")
    {
    if(sSpanishLocations.indexOf(sCountryCode)>=0)
    {
    // Spanish Visitors would go here
    document.write("<META HTTP-EQUIV='Refresh' CONTENT='0; URLhttp://world.altavista.com/babelfish/trurl_pagecontent?url=http%3A%2F%2FYOUR.URL.HERE%2 Findex.php&lp=en_es'>");
    }else if(sGermanLocations.indexOf(sCountryCode)>=0)
    {
    // German Visitors would go here
    document.write("<META HTTP-EQUIV='Refresh' CONTENT='0; URL=http://world.altavista.com/babelfish/trurl_pagecontent?url=http%3A%2F%2FYOUR.URL.HERE%2 Findex.php&lp=en_de'>");
    }else if(sFrenchLocations.indexOf(sCountryCode)>=0)
    {
    // French Visitors would go here
    document.write("<META HTTP-EQUIV='Refresh' CONTENT='0; URL=http://world.altavista.com/babelfish/trurl_pagecontent?url=http%3A%2F%2YOUR.URL.HERE%2F index.php&lp=en_fr'>");
    }else if(sItalianLocations.indexOf(sCountryCode)>=0)
    {
    // italian Visitors would go here
    document.write("<META HTTP-EQUIV='Refresh' CONTENT='0; URL=http://world.altavista.com/babelfish/trurl_pagecontent?url=http%3A%2F%2FYOUR.URL.HERE%2 Findex.php&lp=en_it'>");
    }else if(sPortugueseLocations.indexOf(sCountryCode)>=0)
    {
    // portuguese Visitors would go here
    document.write("<META HTTP-EQUIV='Refresh' CONTENT='0; URL=http://world.altavista.com/babelfish/trurl_pagecontent?url=http%3A%2F%2FYOUR.URL.HERE%2 Findex.php&lp=en_pt'>");
    }else if(sDutchLocations.indexOf(sCountryCode)>=0)
    {
    // dutch Visitors would go here
    document.write("<META HTTP-EQUIV='Refresh' CONTENT='0; URL=http://world.altavista.com/babelfish/trurl_pagecontent?url=http%3A%2F%2FYOUR.URL.HERE%2 Findex.php&lp=en_nl'>");
    }else if(sRussianLocations.indexOf(sCountryCode)>=0)
    {
    // russian Visitors would go here
    document.write("<META HTTP-EQUIV='Refresh' CONTENT='0; URL=http://world.altavista.com/babelfish/trurl_pagecontent?url=http%3A%2F%2FYOUR.URL.HERE%2 Findex.php&lp=en_ru'>");
    // appended Additional language redirection are added here
    // as in the example below
    // remember to verify the actual URL used by the translation engine
    // altavista uses en_ru at the end of the query while google puts it
    // in the center of the query
    // }else if(sChineseLocations.indexOf(sCountryCode)>=0)
    // {
    // // russian Visitors would go here
    // document.write("<META HTTP-EQUIV='Refresh' CONTENT='0; //URL=http://world.altavista.com/babelfish/trurl_pagecontent?url=http%3A%//2F%2FYOUR.URL.HERE%2Findex.php&lp=en_ch'>");
    }else
    {
    // World Visitors would go here
    document.write("<META HTTP-EQUIV='Refresh' CONTENT='0; URL=http://YOUR.URL.HERE/index.php'>");
    }
    }
    }
    </script>
    </head>

    and then the body tag will follow this... if you already have head meta's or whatever... just add this after them without the <head> statements included here.

    there is no need to create separate translated pages unless you have already created them. this includes mods to the common.php and the language files.


    As far as all the testing goes, i could only find one minor fault. If the translation has begun prior to logging into an account, then the sessions will not work (obviously!... because your page is being redirected from the translation site).... and even after you hjave logged in, you'll continually be swept in a viscious circle of logging in.. it just does't work on the admin area.... its possible that if it gets a little more annoying in the future that we'll try to find a workaround for this.

    hope this helps!
    Last edited by flipside72; 11-29-2004 at 01:31 AM. Reason: additions to language translation

  2. #2
    Join Date
    Apr 2004
    Location
    OH
    Posts
    32

    Default Good info

    Just tried it. It works great. This can also be used for other web programs.

    Thanks for contributing the code.

  3. #3
    Join Date
    Dec 2004
    Location
    German, since 2000 in Spain
    Age
    50
    Posts
    826

    Default big laugh!!! :-)))

    Quote Originally Posted by rogs
    Just tried it. It works great. This can also be used for other web programs.

    Thanks for contributing the code.
    I sometimes find sites that translate their content with this sort of programs.

    My opinion: Better not offer a different language on your page, if you can't affort to pay a prof. translater than having a page everybody makes a laugh on. This translating progs really are so bad, always the sense gets lost and you end up with funny germanspanrushenenglish.

    So if you want to have a Joke page, use this to translate your content!!!!

  4. #4
    Join Date
    Sep 2003
    Location
    London UK
    Posts
    1,654

    Default

    Hi

    good mod

    but like CanariasData said some of the words are not correct.

    I removed all mine when I found out a few words
    came up very rude he he

    Al

  5. #5
    Join Date
    Nov 2004
    Posts
    9

    Default

    Thank You werry Much

  6. #6
    Join Date
    Mar 2005
    Posts
    1

    Default

    Hi,

    Great MOD, but why are you buttons translated and mine are not??

    I work with V1.15b....

    Regards

    Erik

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •