4

I'm trying this on Apache running on Ubuntu 14.04 and it works fine:

<?php
// Set language to Polish
var_dump(setlocale(LC_ALL, 'pl_PL.UTF8'));

echo file_get_contents('/var/www/app/backend/gettext/locale/pl_PL/LC_MESSAGES/app.mo');

// Specify location of translation tables
var_dump(bindtextdomain("app", "/var/www/app/backend/gettext/locale"));

var_dump(bind_textdomain_codeset("app", 'UTF-8'));

// Choose domain
var_dump(textdomain("app"));

echo _('I want translate this!');
echo _('This to!');

But when I try it on PHP built in webserver I get only English version and that's the only difference between these two. Is gettext supported by php built in webserver? Any way to get around it?

Thanks for help!

Isinlor
  • 1,111
  • 1
  • 13
  • 22
  • Do you mean `php -S`? Also, have you [installed GNU gettext](http://php.net/manual/en/gettext.requirements.php)? PHP needs that in order for gettext to work. – Sverri M. Olsen Oct 21 '14 at 10:06
  • Yes, I try to run it on php -S . In Ubuntu 14.04 PHP is compiled with gettext, so yes - I have it. Moreover it works OK on Apache, so everything should be configured just fine. Including language pack, permissions to app.mo (I've tried to run PHP as root) etc. – Isinlor Oct 21 '14 at 10:49
  • If gettext wasn't supported, you would get errors. – Guido Flohr Oct 18 '18 at 07:02
  • How exactly did you start the built-in webserver? – Stefan Feb 28 '19 at 17:34

0 Answers0