View Full Version : Script to change language (no auto redirect)?

10-16-2006, 09:05 AM
Could someone please point me in the direction of a good script that will change the langauge of the website? The only results I get on Google are for detecting the browser language and auto redirecting. I would like for the user to select their own language then have that language remembered during the visit and for the next time they come back. I am not sure about the best way to go about doing this. Any help and/or suggestions would be great.

10-16-2006, 09:24 AM
That's crazy.

Javascript can change certain things on a page, but changing the language is changing the entire page.

You could, I suppose, use javascript to rewrite the whole page, but that's tedious and would be a memory issue as well as create a rather large script.

Definitely use a redirect here and have seperate pages for different languages as well as using cookies to store the language choice.

How do you plan to have the user select his/her language?

Additionally, if you mean to imply that you want javascript to translate the page, then that's not gonna happen, unless you want to program (yes, possible) the translation yourself, which would be insanely complex.
It didn't sound like you needed this, but did want to note it just in case.

10-16-2006, 09:38 AM
I know that I can not use java to change the language itself. I was think that I would have to have a seperate pages with the language. As for the redirect: I meant no auto browser language detect then redirect sript. I have in mind to use a drop down menu as the means of choice.

Also, Is there a way to use this with a template? Instead of 20 similar pages with the only difference being language. I would rather have a template with the Header, Navbar and footer. The content would be changed with the script.

Thank you very much for your help and time!

10-16-2006, 09:46 AM
You haevn't mentioned the server-side language you are using/going to use in your post.

As djr33 mentioned in his post using JavaScript alone i don't think it is possible for you to develop a multi-lingual website.

Are you using any Content Management Systems? Most of the popular CMS supports the method to create multilingual website for example Joomla, PHPNuke, etc

10-16-2006, 09:48 AM
Ah, hmmm.... ok.
I get it more now.

Yes, look into server side for this. It would be a great way to use templates.

You could use CMS or write the php (etc.) yourself... would work very well.

Redirect is easy... just use php to interpret the form, or perhaps javascript... use a jump menu.... dropdown, click, go... easy as that.

10-16-2006, 09:55 AM
Or you could use cookies to remember the settings....

10-16-2006, 10:02 AM
To be honest I am not familiar with any of the server side languages or content management systems. I will add these items to my list of things to learn.

I will have a look into my control panel to see what CMS is available for use. However I am not able to do this from my work computer. So in five or so hours I will begin lesson one with CMS.

Thank you both for the help.

10-16-2006, 10:08 AM
These days, you don't need to learn alot about CMS.

Do you have a web server that supports PHP and MySQL?

Just unzip the CMS into the folder.

Do you have web hosting?

Just upload all the files via FTP.

The rest is easy, just find out your logon details for MySQL.

10-16-2006, 10:27 AM
These days you may not need to know much about CMS but it I think it would help to know CMS as well as the server side languages. I am way behind the power curve and need to catch up.

As for my host (ImHosted): supports PHP and MySQL.

I will ask about the MySQL login details. The only login info I see on my account information is the use of FTP, FrontPage, Mail, Control Panel, WebMail and Telnet.

I downloaded the new beta version of JOOMLA and will begin playing with this.

10-16-2006, 02:10 PM
I know that I can not use java to change the language itself.

Java and JavaScript are very different languages.

I have in mind to use a drop down menu as the means of choice.

So long as you don't rely on client-side scripting to implement it, fine. However, you must keep in mind that for the menu to be useful, its purpose must be obvious.

A common means - displaying a series of links at the top of the document naming the language (English, Deutsch, Svenska, etc.) - is perhaps more obvious because the visitor doesn't need to recognise others as the names of languages (for example, whatever would appear first in your menu), only their own.

For a discussion of issues surrounding multilingual sites, read Jukka Korpela's Techniques for multilingual Web sites (http://www.cs.tut.fi/~jkorpela/multi/index.html). Note that if your browser is configured to prefer one of the alternative representations (German, Finnish, or Swedish), that document will be shown in preference. This isn't based on the interface language of the browser, but rather the actual reading preferences of the user.


10-16-2006, 04:32 PM
Be aware that some languages (日本語, 中文, русский язык...) may require the page to be Unicode-encoded.

10-17-2006, 07:22 AM
Ok, I will have a look at the site that you suggested. Thank you for your time and suggestions.

04-05-2011, 08:47 AM
My name is Ken. I see that you posted that you were looking for a script to change language on your page. Here is the script. You should supply your own flag graphics and upload to your server host .

<table width="320"> <tr><td width="40">
<td> <a href="http://www.worldlingo.com/wl/translate?wl_fl=2&wl_url=<$BlogItemPermalinkUrl$>&wl_lp=en-fr"><img alt="Français/French" src="http://photos1.blogger.com/img/43/1633/320/13539949_e76af75976.jpg" height="20" width="30"/></a></td>
<td><a href="http://www.worldlingo.com/wl/translate?wl_fl=2&wl_url=<$BlogItemPermalinkUrl$>&wl_lp=en-de"><img alt="Deutsch/German" src="http://photos1.blogger.com/img/43/1633/320/13539933_041ca1eda2.jpg" height="20" width="30"/></a> </td> <td width="40">
<td><a href="http://www.worldlingo.com/wl/translate?wl_fl=2&wl_url=<$BlogItemPermalinkUrl$>&wl_lp=en-it"><img alt="Italiano/Italian" src="http://photos1.blogger.com/img/43/1633/320/13539953_0384ccecf9.jpg" height="20" width="30"/></a> </td> <td width="40">
<td><a href="http://www.worldlingo.com/wl/translate?wl_fl=2&wl_url=<$BlogItemPermalinkUrl$>&wl_lp=en-pt"><img alt="Português/Portuguese" src="http://photos1.blogger.com/img/43/1633/320/13539966_0d09b410b5.jpg" height="20" width="30"/></a> </td> <td width="40">
<td><a href="http://www.worldlingo.com/wl/translate?wl_fl=2&wl_url=<$BlogItemPermalinkUrl$>&wl_lp=en-es"><img alt="Español/Spanish" src="http://photos1.blogger.com/img/43/1633/320/13539946_2fabed0dbf.jpg" height="20" width="30"/></a> </td> <td width="40">
<td><a href="http://www.worldlingo.com/wl/translate?wl_fl=2&wl_url=<$BlogItemPermalinkUrl$>&wl_lp=en-ja"><img alt="日本語/Japanese" src="http://photos1.blogger.com/img/43/1633/320/13539955_925e6683c8.jpg" height="20" width="30"/></a> </td> <td width="40">
<td><a href="http://www.worldlingo.com/wl/translate?wl_fl=2&wl_url=<$BlogItemPermalinkUrl$>&wl_lp=en-ko"><img alt="한국어/Korean" src="http://photos1.blogger.com/img/43/1633/320/13539958_3c3b482c95.jpg" height="20" width="30"/></a> </td> <td width="40">
<td><a href="http://www.worldlingo.com/wl/translate?wl_fl=2&wl_url=<$BlogItemPermalinkUrl$>&wl_lp=en-zh_cn"><img alt="中文(简体)/Chinese Simplified" src="http://photos1.blogger.com/img/43/1633/320/14324441_5ca5ce3423.jpg" height="20" width="30"/></a>
</td></tr> </table>

04-05-2011, 04:19 PM
This appears to work, sort of. However, the URL appears to be changed from what you list in your post, the translated page/site is then hosted on the translation service's server, and they slap ads onto it, which may or may not mess up the layout (depends upon your page's layout). Some script code, perhaps other content is 'lost in translation'.

I found an href like (here for English to Spanish, replace <$BlogItemPermalinkUrl$> with the actual URL of the page to be translated or a server side token for your server side language that will resolve to the desired URL to be translated):


worked in limited testing.

You should review the worldlingo dot com site's terms of use before putting something like that up live.

Something similar, perhaps with greater ease of use and perhaps with no ads could probably be gotten with Google Translate. However, to get a full navigable site translation, the Google Translate approach might require getting a free API key and learning a few or more than a few basics first. Google Chrome does this for a site for free, no ads, often automatically offering to do so (that's with default settings) when a page not in the browser's preferred language is navigated to. Some other browsers have similar utilities, but you have to ask - no offering by default.