views:

40

answers:

2

I have a PHP application and now I need to implement multi language support. This is the first time I have to deal with this. I did some searches on the internet and always come to PHP's gettext function, which I have compiled on my server. I would just like to know if gettext() is the best way doing this? Most articles date back to even 2002, isn't there a new way maybe in PHP 5.2? Also I read that you have to reboot the server when you make adjustments to the translations??

+1  A: 

The intl extension uses the new ICU library but it's only available in PHP 5.3+

stillstanding
A: 

Yes, rebooting the server is a major issue which was a dealbraker for me. Also gettext's primary intention is to translate language strings, not substitute constants with text, whether that's good for you is for you to decide (i.e. text replacement is 'A dog is brown'=>'Das hund ist braun' (I don't know German;), constant replacement is 'catalog_greeting'=>'Welcome to the catalog').

There are lots of alternative pure-PHP solutions that may work for you. I use a constant replacement scheme that I save in the database and create a separate serialized array for every language on each save, so fetching is extremely quick and the database format matters does not matter to performance. Works great, easy to setup (even from scratch), easy to maintain and extend.

Raveren