bug66267.phpt 1001 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. --TEST--
  2. #66265: gettext doesn't switch locales within the same script
  3. --EXTENSIONS--
  4. gettext
  5. --SKIPIF--
  6. <?php
  7. if (PHP_ZTS) {
  8. /* this is supposed to fail on the TS build at least on Windows,
  9. should be even XFAIL till it's fixed there */
  10. die("skip NTS only");
  11. }
  12. if (substr(PHP_OS, 0, 3) != 'WIN') {
  13. $loc = ["de_DE", "fr_FR", "en_US"];
  14. foreach($loc as $l) {
  15. if (!setlocale(LC_ALL, $l)) {
  16. die("SKIP '$l' locale not supported.");
  17. }
  18. }
  19. }
  20. ?>
  21. --FILE--
  22. <?php
  23. $domain = 'domain';
  24. $loc = ["de_DE", "fr_FR", "en_US"];
  25. foreach ($loc as $l) {
  26. putenv("LC_ALL=$l");
  27. setlocale(LC_ALL, $l);
  28. $path = realpath(__DIR__ . DIRECTORY_SEPARATOR . "66265");
  29. bindtextdomain($domain, $path);
  30. bind_textdomain_codeset($domain, "UTF-8");
  31. textdomain($domain);
  32. echo 'LC_ALL=', getenv('LC_ALL'), "\n";
  33. echo 'hello=', _('hello'), "\n";
  34. echo "\n";
  35. }
  36. ?>
  37. --EXPECT--
  38. LC_ALL=de_DE
  39. hello=hallo
  40. LC_ALL=fr_FR
  41. hello=salut
  42. LC_ALL=en_US
  43. hello=hello