We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

Gettext: 1.3.2 vs Incubator vs native extension, what is the difference?

Hi all!

What is the difference between using gettext adapter (1) from Phalcon 1.3.2, (2) from Phalcon Incubator and (3) native PHP extension?

I am confused with all these options available and don't know what to do...

Thanks!



8.1k

Phalcon's (Incubator) Gettext class/methods is just a way to use PHP's Gettext.

In any case, you need to have the Gettext extension loaded/enabled (and have GNU Gettext installed) (I believe if you're on Windows only the PHP extension is required (but there are issues: https://bugs.php.net/bug.php?id=66265 ) )

There's no documentation ATM on Phalcon's new built-in Gettext, it seems to have been released silenty with 1.3.2, breaking current implementations using the Incubator version. (I posted a while ago about this: https://forum.phalcon.io/discussion/2525/new-gettext-translate-adapter-1-3-2- (yet no response))



26.3k

@renskii thanks for your answer! Yes, I have seen your post about new build-in Gettext, waiting for docs as well.

But still, I do not understand everything. Let's say I have Gettext extension loaded/enabled (and have GNU Gettext installed). Can I use Gettext translations without Phalcon's Incubator adapter (or 1.3.2 adapter)?

Currently I am developing my project on Windows but I want to put in on some Linux as a production.



26.3k

I have read the link to the bug you posted. To put it shortly, you want to say that there is quite huge risk of using gettext on Windows, yes? I am going to set my production on Linux.



8.1k
edited Jul '14

Yes, I also used to use PHP on Windows, but that issue made me to completely steer away from that. (If you're on Windows and got somewhat of a decent computer, one should just use a virtualized *nix to run your site/app.) (You could check out Vagrant, providing a convenient way to get a virtualized environment in a snap, and/or: https://puphpet.com/ ) (or you could go the old-fashioned way of course, installing the OS yourself inside a VM and go from there.)

The classes are nothing more than somewhat of a wrapper. You decide if you like 'em and want to use 'em :) It's not hard to write your own class directly on top of PHP's Gettext functions. You could extend Phalcon\Translate\Adapter or not. Or, of course, you could use the Gettext functions directly without the use/aid of a class.