Using gettext in PHP
I'm working on open source software and thinking of using a gettext to localize the interface. The question is: is there a way for me not to add a gettext module dependency?
Since gettext support comes as a PHP module, I need to make all users install i开发者_如何学JAVAt. Is there an alternative for that?
I think gettext
is compiled in in the vast majority of PHP installations. I have never seen one without it.
That said, Zend Framework's Zend_Translate is truly package independent, and much more powerful than gettext. It can handle a number of dictionary formats, including gettext. It can be used as a standalone component. If you're starting with localization, it's definitely worth a look.
Consider gettext
as a legacy extension. PHP now supports the new ICU library. Look up the following classes: Intl
, Locale
, MessageFormatter
.
There are two alternatives actually. php-gettext and gettext.php, both implemented in PHP userland so you can use them as fallback if the PHP native gettext extension is not compiled in.
精彩评论