3 ms·
I would recommend direly against using the gettext extension and _() because these imply setlocale and setlocale, when called from a PHP script has some side ef
by pilif 17y ago
I would recommend direly against using the gettext extension and _() because these imply setlocale and setlocale, when called from a PHP script has some side effects: For one, it changes the locale per process. Now I know that PHP isn't totally thread save (actually it is - the extensions - like gettext grin are the problem), but imagine apache in a threaded MPM and setlocale being called from different scripts.
Then, setlocale() alters how certain library functions work. *printf() for example uses the number formatting settings of the current locale. If the libraries you are using are not aware of locale settings, they might fail in interesting ways once you set the locale to something that uses, say, a comma as the decimal separator.
And last but not least, if you change your language file, you will have to restart the web server which generally isn't needed with PHP otherwise.
Wordpress has actually reimplemented portions of gettext so it works with the .mo files, but it doesn't alter the locale of the web server process.
And for regional formatting of numbers and dates, we got the intl extension with 5.3 which does just that, also not interfering with the web server process, other libraries and PHP itself.