Multi Language Website - Best way with PHP + MySQL

I am about the build a multi language website using PHP + MySQL.

It's for a real estate website and the translations will be manually interpreted (rather than automated like Google translate).

I am really looking for the most efficient way of creating this site.

I'm guessing i'll need a database table per language: one in english, one in spanish and one in french.

Would I then need 3 duplicate sites/directories? Is there a better way to do this?



BrighteyesDesignAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Ray PaseurCommented:
You might follow the general design that PHP.net uses.  They have separate directories for separate languages.
http://us.php.net/manual/en/function.var-dump.php
http://us.php.net/manual/es/function.var-dump.php
http://us.php.net/manual/fr/function.var-dump.php
http://us.php.net/manual/kr/function.var-dump.php

You might also want to let the client choose the language.  You can cookie the browser to remember the last choice.  This is a better strategy than trying to detect the client's IP address and choosing the language based on the IP.  Whether I was in Paris or Madrid, I would still prefer to use English.
0
RobOwner (Aidellio)Commented:
@Ray as you say, PHP use separate directories but that can be masked by a http url rewrite?  In other words you don't need to duplicate the code but detect via the url what language is being requested.

I agree that it's a waste of time trying to detect the IP for the language as @Ray has said.

In terms of the database there'll be countless ways to do this i'm sure.  In the past I have had tables for logical elements of a site such as for the products you're selling with basic properties such as codes and identifiable descriptions.   I have another table that handles the language for common properties of the product such as description and title.  Each row in that table represents a language.
0
Ray PaseurCommented:
But why bother to mask a URL?  Why not allow clients to send a link that tells the true URL?  It just feels more user-friendly to me that way.
0
Acronis True Image 2019 just released!

Create a reliable backup. Make sure you always have dependable copies of your data so you can restore your entire system or individual files.

BrighteyesDesignAuthor Commented:
Thanks for your help,

With the PHP.net method what would be in the root directory? If the default language is english would the root index.php redirect to /en/index.php

Also, with the drop down that selects the different languages. I guess this redirects the user to uURL's along the lines of...

http://us.php.net/manual/en/(code to detect the current pages filename)
http://us.php.net/manual/es/(code to detect the current pages filename) etc...
0
ee_reachCommented:
I am doing exactly that right now.  

Much depends on how similar your content is going to be.

Assuming the content is quite similar, the way I am doing it is as if it were a data driven site in English.  That is, all text, including "alt" text comes from a database.  But each phrase in the database has three different versions, depending on the active language as selected by the user at the beginning.  

Note that sometimes you have a difficulty with this because the structure of the languages differ, so you can't get too finely grained in most cases.  For example, most languages have a different order for where they place the subject, verb, and direct object.   So whole phrases and sentences are better than breaking up the sentence into small pieces.   Except navigation words.  Depending on the language, those can often be broken down quite small.

I am not keeping duplicate sites.  That would be a lot of work and error prone every time something changes.  So all three languages will sit inside the main structure of the site.  But there will be different sub-directories within the site for language-specific images, documents, videos, etc.

Mostly, the above going will work if you are sharing navigation and structure amongst the sites.

If they are three distinct sites with their own structure, background, and navigation style, and they just happen to share a domain name and an option to choose a language at the beginning, then that is a whole 'nother ball game.  E.g., if the English version is going to be very business like, but the Spanish one is going to have a Latin flair, then I would go with three different directories.

Hope this helps.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
ee_reachCommented:
Re figuring out the lang based on IP is problematic.  What is someone is a native Spanish speaker but they are travelling in Montreal, Quebec and they are accessing the site from a netbook?  

Even in the US, you can't assume English just because it is a US-based IP.  In some parts of L.A. even the roadside ads are in Spanish because the majority of the people who live in that area speak Spanish.

 
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
PHP

From novice to tech pro — start learning today.