I would like to know what are the different ways to build a multilingual websites and what is the best of them.
-
Are you using any CMS or do you code everything yourself? – Dion Jan 13 '12 at 13:45
-
possible duplicate of [PHP Localization Question](http://stackoverflow.com/questions/2149116/php-localization-question) – Neville Kuyt Jan 13 '12 at 13:48
-
@DRP96: I'm building a website from scratch. No CMS. – sikas Jan 13 '12 at 15:55
3 Answers
There are plenty of ways to create a multilangual php website:
- ini/CSV files - easy to edit, very simple format
- PHP files (arrays) - easy to edit for PHP programmers, good performance
Or, using some third party libraries like:
You should also take a look at the following questions:

- 1
- 1
You could create a table in your database and add e.g. three columns like "name", "english", "german". Then you can fetch the database's data on every page and save id into an array like language[]. Before you have to check the users language and customize the SQL-code like
$sql = "SELECT * FROM lang WHERE language='$language'";
$query = mysql_query($sql);
$language = mysql_fetch_assoc($query);
Then you can for example use echo $language["page_description"];
in your document..

- 3,145
- 20
- 37
-
although I like this idea, I'm not willing to implement it. What about the overhead of the data, I will be having lots of data stored. So if I just go and grab all the required data for each page and I have high traffic, then good bye my server! :( – sikas Jan 13 '12 at 15:55
-
Well the traffic is not higher than you would write it directly in your HTML Code, but the server request would be a bit slower. Usually that's not a problem. E.G. Wordpress does that exactly as my idea and it's working fine. – Dion Jan 13 '12 at 16:10
-
By "a Bit" I am really speaking of a very little bit (milliseconds or less) – Dion Jan 13 '12 at 18:15
-
You need to look into internationalization. There are many methods for dealing with it. I use Symfony 2, a php framework that was built from the ground up with internationalization in mind. Check out their introduction as well as their chapter on internationalization.

- 9,094
- 17
- 64
- 89