-2

I have a simple question here. How do I build a multilingual website using php?

What are the tools that I need to do so?

Also, if I'm planning to build my website using a framework (like cakePHP, or symfony, etc...), do theses frameworks have features that will allow me to do that?

Please give me the best and the most simple and straightforward solution.

Thanks in advance

PeeHaa
  • 71,436
  • 58
  • 190
  • 262
user765368
  • 19,590
  • 27
  • 96
  • 167
  • Both Symfony and Zend Framwework have i18n/i10n features/components available. I thought Cake and CI did to but im not 100% on that. – prodigitalson Jan 21 '12 at 00:05
  • Have you tried looking at those frameworks to see if they support any localization features? That's what you should probably do first, some real research, instead of asking the community how to do this. I'm pretty sure there are lots of hits on google and on stack overflow. A quick search tells me that a lot of people are using gettext. http://stackoverflow.com/questions/2790952/php-localization-best-practices-gettext – tjarratt Jan 21 '12 at 00:08

2 Answers2

3

If you want to build a multilingual website your best option is to use some gettext implementation. PHP has this and most frameworks like CakePHP support this (the keyword to search for is i18n (short for internationalization).

All strings in your app need to be send through the gettext function. In PHP this function is aliased to __() so that your string will look like this:

<?php
echo __('Hello world');
?>

You then need to generate so called .po files which store these strings together with their translations. An example entry of a .po file looks like this

msgid "Hello world"
msgstr "Ola mundo"

Your app then needs to load the right .po file for the right language. CakePHP has a nice manual for doing this, but other frameworks have this built in as well.

vindia
  • 1,678
  • 10
  • 14
0

I'd recommend you CodeIgniter. It has some very simple and user friendly tools to achieve what you are looking for.

Example implementation.

Zar
  • 6,786
  • 8
  • 54
  • 76