views:

276

answers:

3

Hi the folks!

I'm building a Open Source product and I thinking about Localization, I've read about gettext but there seems to be a lot of problem to get it to work in different systems (servers,os etc).

How would you handle this? Is there a secure way to help gettext work on several systems? Perhaps it already is?

Regards from Sweden / Tobias

A: 

The language blocks should be kept external to the program. They may be in a database or in XML files. This will enable further languages to be added at a later point in time.

Then all your application needs to do is identify the localisation by the user and serve up the appropriate text for each situation.

Jon Winstanley
+2  A: 

I recommend you take a look at Zend_translate, Zend_locale and Zend_Date. I'm only starting to dabble with them myself, but to me, they already look like a really good, clean and modern solution to internationalization, in contrast to the chaos that is gettext.

The introduction to Zend_translate lists a number of strong arguments why to choose it (or something similar) over gettext.

In multilingual applications, the content must be translated into several languages and display content depending on the user's language. PHP offers already several ways to handle such problems, however the PHP solution has some problems:

Inconsistent API: There is no single API for the different source formats. The usage of gettext for example is very complicated.

PHP supports only gettext and native array: PHP itself offers only support for array or gettext. All other source formats have to be coded manually, because there is no native support.

No detection of the default language: The default language of the user cannot be detected without deeper knowledge of the backgrounds for the different web browsers.

Gettext is not thread-safe: PHP's gettext library is not thread safe, and it should not be used in a multithreaded environment. This is due to problems with gettext itself, not PHP, but it is an existing problem.

Pekka
I'm looking at it right now, seem a bit large perhaps. Do you now how, for example, Drupal and WordPress are doing this?
sandelius
WP uses gettext: http://codex.wordpress.org/I18n_for_WordPress_Developers I think Drupal has its own system, I don't know what it's based on: http://drupal.org/project/i18n It may seem a bit large but It's certainly one of the leanest and best solutions around. There isn't that much else on the market, check my question at http://stackoverflow.com/questions/1620670/i18n-with-gettext-but-without-the-locale-hassle
Pekka
sandelius
+2  A: 

Zend Framework's Zend_Translate is most flexible what I've seen. It doesn't necessarily need gettext support module in PHP's side as it reads the .mo-binary format itself.

raspi