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