user165210
user165210

Reputation: 300

Php errors with localization translate

Hello i tried to do translate to my website with localization with this code:

    $locale = "he_IL.UTF-8";
    $domain = "./locale";

    putenv("LANG=$locale");
    putenv("LANGUAGE=$locale");
    putenv("LC_ALL=$locale");
    putenv("LC_MESSAGES=$locale");
    setlocale(LC_ALL, $locale);
    setlocale(LC_MESSAGES, $locale);

and i got error:

Notice: Use of undefined constant LC_MESSAGES - assumed 'LC_MESSAGES'
Deprecated: setlocale(): Passing locale category name as string is deprecated. Use the LC_* -constants instead in
Warning: setlocale(): Invalid locale category name LC_MESSAGES, must be one of LC_ALL, LC_COLLATE, LC_CTYPE, LC_MONETARY, LC_NUMERIC, or LC_TIME in

and the language dont working... i tried to set:

 if (!defined('LC_MESSAGES'))
     define('LC_MESSAGES', 6);

its solve the errors but still the lagnauge dont translated... i using wamp for this website, but in web server its working good the translate... only in the wamp not

tnx a lot

Upvotes: 1

Views: 1016

Answers (1)

Syeknom
Syeknom

Reputation: 86

The PHP Manual entry for setlocale

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

We can assume therefore that your webserver has a version of PHP compiled with libintl, but that your WAMP server does not. My understanding is that LC_MESSAGES doesn't work very well on Windows.

Try instead using:

putenv("LC_ALL=$locale");
setlocale(LC_ALL=$locale);

If you're using php-gettext then make sure you've installed your locales to the appropriate folders.

Upvotes: 2

Related Questions