Hi,
I will be making a small site (my first in php) that will be available in 3 languages (eng, jap, chinese).
my idea is to have index.php page in the root, and then (also in the root) 3 folders (en, ja, zh) with a version for the site in each language.
This should be work as the site is pretty small.
So, index.php will try to automatically detect what langauge to be used, and redirect he user to mysite/en(or ja or zh)/home.php.
What is the best way to detect what language to be used?

Of course, on each langauge version will be "flags" that will take you to another language.

Also, I probably also want to use a cookie, for in case say an english user in japan, use the site in english, and dont have to switch from japanese to english each time they come bac,

Any suggestions against this plan of mine is also welcome of course.

How about detecting the browser language?

I thought going this way. (Seeing it's a pretty small site, mostly static pages)

1) In the first page (index) try to determine the user's language. First check for a previously set cookie (I Know how irritating it is for instance that google cannot remember I'm in China, but I use the english version). If no cookie, check if the browser lang is english, japanese or chinese. If not japanese or chinese, load in english.
2) Redirect the user to sitname/language/index.php.
3) On each of the pages, is 2 links that will take the user to the either one of the "other" 2 languaes, and when doing so, set the langauge cookie.

Now what bother me is that search engine spiders can only follow links (From what I heard), so if you redirect in code to another page, it cannot follow it.
My idea is that the main index page will never show, but in code redirect to site/lang/index.php.

Is this true? What is the best way to redirect in code to another page?

Hi,
I will be making a small site (my first in php) that will be available in 3 languages (eng, jap, chinese).
Snip.....

There is another way, check out http://comchatter.com, while the site is still incomplete it clearly demonstrates how true multi-lingual sites should work
Translation system is built in
Multi-Lingual support is probably the most advanced ever developed for web sites
Geo support also exceeds the capability of any other system I have looked at
True there is a learning curve, thats the pain, the gain however is this system supports hundreds of languages
Browser language detection is an integral part of the system
The included forms object cleans and type checks post variables thus reducing potential script injection risks
The code base used for this system is called NLSO, meaning Natural Language Support Objects
For those who will knock my work, this site is close to completion, it is actively being worked on daily and represents several years of research into advanced language support systems where I have had to address many issues with unicode support, or rather the lack of it in programs and systems which should support it
To the original poster, a word of caution on multi-lingual sites
The time and effort to achieve the goal are far greater than a conventional site, there is no quick fix or magic bullet to do it
NLSO while one of the most advanced systems is flawed and compromises have to be made to achieve the language support
The payoff for your language choices are excellent as Chinese (Mandarin) is the most widely spoken language on earth, Japanese is also a major language
Now imagine if you could support the top 20 languages and 300 others
ComChatter.com is already substantially translated to Mandarin and has some translations to other languages
I am happy to work with others who are willing to put in reasonable effort to improve NLSO
if interested contact me :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.