PHP Classes

PHP Get Locale from CountryCode: Determine locale language from country code

Recommend this page to a friend!
  Info   View files Documentation   View files View files (4)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog    
Last Updated Ratings Unique User Downloads Download Rankings
2017-06-11 (9 months ago) RSS 2.0 feedNot enough user ratingsTotal: 191 This week: 2All time: 8,149 This week: 325Up
Version License PHP version Categories
country-to-locale 1.0.1Custom (specified...5Localization, PHP 5, Geography
Description Author

This class can determine locale language from country code.

It can take the code of a country and converts it to the locale name that identifies the country and language used in that country.

For countries that use different languages, it returns a string with all locale names separated by commas.

Innovation Award
PHP Programming Innovation award nominee
April 2017
Number 13
Locale is the definition of settings that change from country to country, like the language and the way to format values like time, dates and money amounts.

Each locale has a name string formed by the country and the language or languages associated with that country.

This class can determine which locales are associated with each country and returns a string with the names of the country locales.

Manuel Lemos
  Performance   Level  
Name: Peter Kahl <contact>
Classes: 32 packages by
Country: United Kingdom United Kingdom
Age: ???
All time rank: 63030 in United Kingdom United Kingdom
Week rank: 28 Up2 in United Kingdom United Kingdom Up
Innovation award
Innovation award
Nominee: 19x



Determine locale from 2-letter country code. (Can be used as language code.)


use peterkahl\locale\locale;

echo locale::country2locale('DE'); # 'de_DE'

echo locale::country2locale('CN'); # 'zh_CN'
  Files folder image Files  
File Role Description
Files folder imagesrc (1 file)
Accessible without login Plain text file composer.json Data Auxiliary data
Accessible without login Plain text file LICENSE Lic. License text
Accessible without login Plain text file Doc. Documentation

  Files folder image Files  /  src  
File Role Description
  Plain text file locale.php Class Class source

 Version Control Unique User Downloads Download Rankings  
This week:2
All time:8,149
This week:325Up