Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to enable PHP Locale class

Tags:

php

locale

I am using PHP 5.4.18 and am trying to use the Locale object.

I have tried the following calls:

$locale = locale_accept_from_http($_SERVER['HTTP_ACCEPT_LANGUAGE']);
$locale = Locale::acceptFromHttp($_SERVER['HTTP_ACCEPT_LANGUAGE']);

I get the errors 'Call to undefined function' and 'Class Locale not fund', respectively.

I found a mention somewhere that the php_intl extension needs to be enabled. I did this.

I've also looked at the Locale Manual(http://www.php.net/manual/en/class.locale.php), but there is not mention of needing to enable anything.

What preparation do I need to undergo to enable the Locale class?

Okie. I found that the php_intl file is not loading. However, it is present in the php/ext directory and the path it shows in the error log is correct.

As a note: I am using WAMP.

like image 395
Lee Loftiss Avatar asked Aug 20 '13 23:08

Lee Loftiss


People also ask

What is locale PHP?

A "Locale" is an identifier used to get language, culture, or regionally-specific behavior from an API. PHP locales are organized and identified the same way that the CLDR locales used by ICU (and many vendors of Unix-like operating systems, the Mac, Java, and so forth) use.

How many locales are there?

Edit: The original list of locales has been edited to add additional locales that were not included before. Now 228 listed. The most important thing for various versions of English is in formatting numbers and dates.


2 Answers

On Ubuntu Linux:

sudo apt-get install php5-intl
service apache2 restart
like image 118
Carlos Ariza Avatar answered Oct 19 '22 21:10

Carlos Ariza


Solution for XAMPP

Uncomment (remove ; at the beginning) this line in php.ini

extension=intl
like image 33
SandroMarques Avatar answered Oct 19 '22 23:10

SandroMarques