PHP Classes

PHP CLDR: Retrieve locale details from Unicode CLDR files

Recommend this page to a friend!
  Info   Documentation   View files Files   Install with Composer Install with Composer   Download Download   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
Not yet rated by the usersTotal: 38 All time: 10,962 This week: 206Up
Version License PHP version Categories
cldr 1.0.0MIT/X Consortium ...5Localization, PHP 5, Text processing
Description 

Author

This package can retrieve locale details from Unicode CLDR files.

It can parse XML files downloaded from the Unicode CLDR repository to extract locale details of several types.

Currently it can retrieve details extracted from CLDR files like:

- The language
- Territory
- The languages list
- The language name by locale
- The scripts list
- The scripts name by type
- The territories list
- A territory name
- The variants list
- A variant name
- The measurement system names
- The character order,
- A date fields name,
- A date relative time steps name
- A date future and past times name by count
- The time z one names list
- A time zone name by code
- A calendar era name
- A calendar era abbreviated name
- A calendar era narrow name
- The calendar months list
- A calendar month name

Picture of Payam Naderi
  Performance   Level  
Innovation award
Innovation award
Nominee: 2x

 

Documentation

[[ Work in progress ]]

I will put more example and documentation.

at very basic, you may use something like this:


$locale = \Locale::getDefault();
$mainProvider = new \Poirot\Cldr\DataProvider\MainProvider($locale);

echo $mainProvider->getCharacterOrder(); // right-to-left

/*
array(3) {
  ["metric"]=>
  string(10) "?????"
  ["UK"]=>
  string(20) "??????????"
  ["US"]=>
  string(16) "????????"
}
*/
$mn = $mainProvider->getMeasurementSystemNames();

$mainProvider->setLocale('en');
echo $mainProvider->getTerritoryName('IR'); // Iran

/Use custom data path/
// Iran
echo $mainProvider->getRepoReader()
    ->getEntityByPath(
        'localeDisplayNames/territories/territory',
        array('type' => 'IR')
    );

Support

To report bugs or request features, please visit the Issue Tracker.

Please feel free to contribute with new issues, requests and code fixes or new features.


  Files folder image Files (11)  
File Role Description
Files folder imagePoirot (1 directory)
Files folder imagerepoLdml (1 file)
Accessible without login Plain text file composer.json Data Auxiliary data
Accessible without login Plain text file README.md Doc. Documentation

The PHP Classes site has supported package installation using the Composer tool since 2013, as you may verify by reading this instructions page.
Install with Composer Install with Composer
 Version Control Unique User Downloads Download Rankings  
 100%
Total:38
This week:0
All time:10,962
This week:206Up