Setlocale stopped working


#1

Hi all and thanks for reading,

I’ve been at sparkletts server for several years and recently was moved to lilongwe server. PHP here is 5.2.13, as opposed to the 5.2.6 at sparkletts, and the new server is 64 bit instead of 32.

They tell me that the locales installed in directory :/usr/share/i18n/locales# include a bunch of them, including the ones I am interested of. But I can’t access them.

I am mirroring the DH PHP install from a cgi-bin directory just to have a custom php.ini, but my include_path includes the paths in their default php.ini, this is:

include_path = ".:/usr/local/php5/lib/php:/usr/local/lib/php:someOthersHere"And when I commented out the the custom php handlers in the htaccess file at the root of the site, to make the site work with the DH php install, setlocale wasn’t still working, and the only locales that seemed to be installed were:

Array ( [0] => C POSIX e [1] => _US.utf8 )… which I got from running:

function list_system_locales(){ ob_start(); system('locale -a'); $str = ob_get_contents(); ob_end_clean(); return split("\\n", trim($str)); } $locales = list_system_locales(); print_r($locales); So: is anyone of you aware of the possible origin of this problem?

Thanks a lot in advance.

Arturo


#2

test.php:

<?php echo '<pre>'; setlocale(LC_ALL, 'ar_IN.utf8'); echo strftime("%A %e %B %Y", mktime(0, 0, 0, 7, 22, 1968)); echo '<br />'; setlocale(LC_ALL, 'en_AU'); echo strftime("%A %e %B %Y", mktime(0, 0, 0, 7, 22, 1968)); ?>

Maximum Cash Discount on any plan with MAXCASH

How To Install PHP.INI / ionCube on DreamHost


#3

Obviously, that is what is not working for me as there seem to be no other locales installed than C, POSIX and en_US.utf8…


#4

You didn’t provide the method with which you’re setting the locale…

Browse /usr/share/i18n/locales directly. If you see a stack then undo any PHP and .bash* customisation you’ve set up.

Alternatively, try the test file on a new user set up on the new server.

Maximum Cash Discount on any plan with MAXCASH

How To Install PHP.INI / ionCube on DreamHost


#5

Well, I don’t know how to view the locales there, but as I said before, they emailed the list of them in that directory and there is really a bunch of them, including the ones I’ve tried with setlocale(). The thing is that I run

$ locale -ain the shell and it only shows:

C POSIX en_US.utf8 I have allso undone my PHP custom settings, as I said in the first post, without any change on this.

After googling for a while i found this:

you may have encountered that setlocale is not working at all, even though you have the files in the /usr/share/locale directory and everything was fine before the upgrade. in this case look at the /etc/locale.gen file, which contains the generated locales. if it is empty, you do not have any useful locales. To generate the needed locales run 'dpkg-reconfigure locales' as root and select the locales you need. … which looks as something that only the admins at DH can do, not me (?).

Anyway, thanks for your time!


#6

> Well, I don’t know how to view the locales there

[code]$ cd /usr/share/i18n/locales
$ ls

$ more /etc/locale.gen[/code]If it’s all there then it could be the server wasn’t rebooted after the locale config.

Maximum Cash Discount on any plan with MAXCASH

How To Install PHP.INI / ionCube on DreamHost


#7

Thanks again for your time:
I did what you said:

$ cd /usr/share/i18n/locales $ ls and showed a whole lot of locales, as I expected.
Then I did

$ more /etc/locale.gen And just showed

Which points to what you said (I also had read this in the PHP manual notes): the need for rebooting the server or to run ‘dpkg-reconfigure locales’ as root and restarting apache.

I mailed them with this. Still waiting for reply…


#8

Well: they just did it: PROBLEM SOLVED!!!

So if anyone comes up with this problem after a server upgrade, this thread might be useful to point DH admins in the right direction.