PHP: native language support

Usually, programs are written and documented in English, and use English at execution time to interact with users. Using a common language is quite handy for communication between developers, maintainers and users from all countries. On the other hand, most people are less comfortable with English than with their own native language, and would prefer to use their mother tongue for day to day’s work, as far as possible.

GNU gettext is an internationalization (i18n) and localization (l10n) library, that offers to programmers, translators and even users, a well integrated set of tools and documentation. Specifically, the GNU gettext utilities are a set of tools that provides a framework within which other free packages may produce multi-lingual messages. Also for PHP developers the gettext functions implement an NLS (Native Language Support) API which can be used to internationalize applications.

There are basically two ways to use gettext in your PHP applications. You can use the native gettext PHP extension or you can use a library implemented in PHP that does not need any extension, such as php-gettext.

To make internationalisation possible you have to use a server where the locales you want to use must be installed. This is most likely not the case when you are working on a server which is not yours. That’s why the specific functions of php-gettext are so usefull because they permit to become server-configuration independant.

Leave a Reply