gettext()只翻译en_US

I've just started using gettext() and having a strange problem. I have the following code:

// $language = ["en_US", "en_US.UTF-8", "en-US", "en-US.UTF-8"];
// $language = ["tr_TR", "tr-TR", "tr", "tr_TR.UTF-8", "tr-TR.UTF-8", "tr.UTF-8"];
$language = ["nl_NL", "nl_NL.UTF-8", "nl-NL", "nl-NL.UTF-8"];

putenv("LANG=" . $language[0]);
$locale = setlocale(LC_ALL, $language);

$domain = "messages";
bindtextdomain($domain, "locales"); 
bind_textdomain_codeset($domain, "UTF-8");
textdomain($domain);

if (!defined("LC_MESSAGES")) {
    echo "<p>LC_MESSAGES is NOT defined.</p>";
}

if (!function_exists("gettext")) {
    echo "<p>gettext() does not exist.</p>";
}

echo "<p>" . $locale . "</p>";
echo "<p>" . _("title") . "</p>";
echo "<p>" . _("content") . "</p>";

This doesn't work on localhost (XAMPP 7.3.5), or rather it works (translates) only with en_US. The output I get is:

LC_MESSAGES is NOT defined.

nl_NL

_TITLE_

_CONTENT_

While it should translate en to nl, I get en -> en. This works fine on a remote server (DirectAdmin) and I don't get LC_MESSAGES error:

nl_NL

titel

inhoud

This problem might be specific to XAMPP, and I think this is vital. I should be able to use/change languages on localhost. What can be done to solve this? The only difference that I've noticed between the servers is that LC_MESSAGES is not defined on localhost (XAMPP). And in setlocale() page, there's a statement saying:

LC_MESSAGES for system responses (available if PHP was compiled with libintl)

Could this be the reason? Do I need to recompile PHP?

If there isn't a way to fix this, is there a workaround that I can use? I mean, I already have the required po/mo files. I know the directory that they're in. I know the requested locale. All I need would be a parser to get the translation from the file.

All files can be found at this repository.
Remote server output (page/link might be removed in the future).


Update

I'm constantly looking for a way to solve this, so I'm checking other Q/As. In one, it's suggested that I have to install the language that I want to use. So I downloaded/installed the languages (tr, nl). It didn't help. It still doesn't translate.

screenshot of language settings

Locale identifiers like nl_NL are not standardized and your Windows system may use something different. Try outputting the return value of setlocale(LC_ALL, 0) to get an idea of the format used.

You should also read the documentation: https://www.php.net/manual/en/function.setlocale.php

You will find this:

On Windows, setlocale(LC_ALL, '') sets the locale names from the system's regional/language settings (accessible via Control Panel).

So you should ensure that you have selected Dutch, before you make the test call to setlocale(LC_ALL, 0).

And about the supported locale categories you can find in the docs:

LC_MESSAGES for system responses (available if PHP was compiled with libintl)

So, the constant LC_MESSAGES may just not be defined for your version of PHP.

But ... I am not a PHP programmer but your sample code does not look correct. How can a string literal like "LC_MESSAGES" not be defined? Please post the original code.