문제

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!

도움이 되었습니까?

해결책

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, "");

다른 팁

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top