1

I would like to know what are the different ways to build a multilingual websites and what is the best of them.

sikas
  • 5,435
  • 28
  • 75
  • 120

3 Answers3

1

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:

  • i18n internationalization
  • Gettext - open format for translations.

You should also take a look at the following questions:

  1. Best system for multiple language support in PHP?

  2. PHP Localization Question

Community
  • 1
  • 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..

Dion
  • 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
  • well, I can check this ... you are making me thinking of it :D – sikas Jan 14 '12 at 21:12
0

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.

MrGlass
  • 9,094
  • 17
  • 64
  • 89