Frage

ISSUE RESOLVED (see below)

I have generated the locales on my server, I have confirmed that they exist (my locale -a provided below), but when I use:

    setlocale(LC_TIME,'fr_FR');
    or setlocale(LC_TIME,'fr_FR.utf8');

it doesn't work at all.

Sample:

    <?php
    setlocale(LC_TIME,'fr_FR.utf8');
    echo 'locale - '.setlocale(LC_TIME,'0');
    echo ' : month - '.strftime('%B');
    echo '<br />';

    setlocale(LC_TIME,'fr_FR');
    echo 'locale - '.setlocale(LC_TIME,'0');
    echo ' : month - '.strftime('%B');
    echo '<br />';

    setlocale(LC_TIME,'fr-FR');
    echo 'locale - '.setlocale(LC_TIME,'0');
    echo ' : month - '.strftime('%B');
    echo '<br />';

    setlocale(LC_TIME,'fr');
    echo 'locale - '.setlocale(LC_TIME,'0');
    echo ' : month - '.strftime('%B');
    echo '<br />';

    setlocale(LC_TIME,'french');
    echo 'locale - '.setlocale(LC_TIME,'0');
    echo ' : month - '.strftime('%B');
    echo '<br />';
    ?>

Results:

    locale - C : month - October
    locale - C : month - October
    locale - C : month - October
    locale - C : month - October
    locale - C : month - October

locale -a (showing the fr locales):

    fr_BE.utf8
    fr_CA.utf8
    fr_CH.utf8
    fr_FR.utf8
    fr_LU.utf8

Thank you for the help!

War es hilfreich?

Lösung

okay, after posting this, I tried one more thing. So for those experiencing the same issue, you need to set this first before setting the new locale:

setlocale(LC_TIME, "");

Andere Tipps

You have to restart php before use new installed locales.

If you want to use the system default locale in Apache2, you just need to add (or uncomment) the following line in the /etc/apache2/envvars file :

. /etc/default/locale

Think to restart apache2 after this operation and clear your potential cache to check locale is well given to PHP.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top