PHP setlocale() not working

Problems with the Mac OS X version of XAMPP, questions, comments, and anything related.

PHP setlocale() not working

Postby cimorrison » 15. December 2020 17:53

I am using XAMPP 8.0.0 on MacOS 11.0.1 and find that setlocale() in PHP is not working. It will return the locale that has been set, as opposed to FALSE, but when I use strftime() the output is always in English, no matter what locale I set. I have checked the contents of the locale files in /usr/share/locale and they are in the correct language, so I am not sure what can be going wrong. Here is my test program:

Code: Select all
<?php
error_reporting(-1);
ini_set('display_errors', '1');

$disabled = explode(',', ini_get('disable_functions'));

if (in_array('exec', $disabled))
{
    $locales = array(
        "de",
        "de_DE",
        "de_DE.utf-8",
        "de_DE.UTF-8",
        "de_DE.utf8",
        "de_DE.UTF8",
        "deu",
        "german",
        "fr_FR"
    );
}
else
{
    exec('locale -a', $locales);
}

foreach ($locales as $locale)
{
    setlocale(LC_TIME, "");
    $result = setlocale(LC_TIME, $locale);
    var_dump($result);
    echo strftime("%A %e %B");
    echo "<br>\n";
}
cimorrison
 
Posts: 2
Joined: 15. December 2020 17:44
XAMPP version: 8.0.0
Operating System: MacOS

Re: PHP setlocale() not working

Postby dave_van » 28. January 2021 09:41

I have the same issue, but with XAMPP 7.4.14.

I use macOs BigSur 11.1.

Did you solve this issue?
dave_van
 
Posts: 1
Joined: 28. January 2021 09:20
XAMPP version: 7.4.14
Operating System: MacOs 11.1

Re: PHP setlocale() not working

Postby cimorrison » 28. January 2021 09:56

No, never solved it.
cimorrison
 
Posts: 2
Joined: 15. December 2020 17:44
XAMPP version: 8.0.0
Operating System: MacOS


Return to XAMPP for macOS

Who is online

Users browsing this forum: No registered users and 4 guests