libintl-perl 1.16 review

by on

libintl-perl is a library that supports message translation for Perl, written in pure Perl (version 5.004 or better)

License: Artistic License
File size: 454K
Developer: Guido Flohr
0 stars award from

libintl-perl is a library that supports message translation for Perl, written in pure Perl (version 5.004 or better). A faster C version is also built and installed if the system fulfills all requirements.

Its interface is very similar to the gettext family of functions in C, and it uses the same file formats as GNU gettext, making it possible to use all tools available for gettext itself and to seamlessly integrate internationalized Perl code into mixed-language projects. An alternative library with a similar purpose is available as Locale::MakeText.

The core of the library is the module Locale::gettext_pp. It is a pure Perl re-implementation of the module Locale::gettext available on CPAN. However, the XS version Locale::gettext lacks some functions (notably plural handling and output conversion) that are already
present in Locale::gettext_pp. Locale::gettext_pp provides the internationalization functions that are available in your system library (libc) or additional C libraries (for example libintl in the case of GNU gettext).

The class Locale::Messages is an additional abstraction layer that is prepared for dynamic switching between different gettext implementations (for example Locale::gettext_pp and Locale::gettext). It provides basically the same interface as Locale::gettext_pp but in an
implementation-independent manner.

The module Locale::TextDomain is the only module that you should actually use in your software. It represents the message translation system for a particular text domain (a text domain is a unique identifier for your software package), makes use of Locale::Messages
for message translation and catalog location, and it provides additional utility functions, for example common shortcut names for i18n routines, tied hashes for hash-like lookups into the translation database, and finally an interpolation mechanism suitable for
internationalized messages.

The package also contains a charset conversion library Locale::Recode. This library is used internally by Locale::gettext_pp to allow on-the-fly charset conversion between the charset in a message catalog and the preferred (end) user charset. Its main advantage about the Encode package available for recent Perl versions is its portability, since it does not require the Unicode capabilities of Perl that were introduced with Perl 5.6. It fully supports UTF-8 with every Perl version and a wealth of common 8 bit encodings. If you have to do charset conversion with older Perl versions, then Locale::Recode may be worth a try although it is really only a helper library, not intended as a competitor to Encode.

The library is entirely written in Perl. It should run on every system with a Perl5 interpreter. The minimum required Perl version should be 5.004.
The behavior of the package varies a little depending on the Perl version:

- Perl 5.8 or better

Recommended. Perl 5.8 offers maximum performance and support for various multi-byte encodings (even more if Encode::Han is installed). Additionally the output charset is chosen automatically according to the information provided by I18N::Langinfo. In fact, I18N::Langinfo is already available for Perl 5.7 but this developer version is
probably not much in use any more.

- Perl 5.6 or better

Still offers high-performance UTF-8 handling but no support for other multi-byte encodings unless the package Encode is installed.

- Earlier Perl versions

Full UTF-8 support but quiet slow since all conversion routines are written in Perl. More exactly: Encoding from 8 bit charsets into UTF-8 is reasonably fast and usable. Decoding UTF-8 is slow, however.

Note that these are actually the requirements for the *users* of your software internationalized with libintl-perl.

As a maintainer of a Perl package that uses libintl-perl, you will also need a recent version of GNU gettext (see the file README in the subdirectory "sample/" of the source distribution of libintl-perl). Translators of your software can basically do their job with any text editor, but it usually makes sense for them, too, to have GNU gettext installed. End users of your software, or people that install an internationalized Perl package do *not* need it, unless they want to add a new language to your software.


If libintl-perl is not installed on your system, you have to build it
from the sources. You need the program "make" for that and a command
line shell. No C compiler is required.

Unpack the package in a directory of your choice, cd into that
directory and then type

perl Makefile.PL

This will build the package. You can then run the tests with

make test

To install the package, type

make install

You will probably need root permissions to do that.

libintl-perl 1.16 search tags