i18n with gettext but without the locale hassle?

This method should work even with non-standard locales:

$locale="someWeirdLocale";

putenv('LC_MESSAGES=' . $locale);
bindtextdomain('domain', './locale');
textdomain('domain');

Enjoy!

Leave a Comment