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
2020-09-24 (1 hour ago) RSS 2.0 feedNot enough user ratingsTotal: 273 This week: 1All time: 7,563 This week: 254Up
Version License PHP version Categories
country-to-locale 1.0.7Custom (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
Picture of Peter Kahl
  Performance   Level  
Name: Peter Kahl <contact>
Classes: 37 packages by
Country: United Kingdom
Innovation award
Innovation award
Nominee: 23x

Winner: 2x

Details

locale

Downloads Download per Month License If this project has business value for you then don't hesitate to support me with a small donation.

Determine locale from country code.

Usage

use peterkahl\locale\locale;

echo locale::country2locale('hk')."\n";
echo locale::country2locale('DE')."\n";
echo locale::country2locale('gb')."\n";

/* Prints:
zh_HK,en_HK
de_DE
en_GB,ga_GB,cy_GB,gd_GB,kw_GB
*/
  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 README.md 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  
 100%
Total:273
This week:1
All time:7,563
This week:254Up

For more information send a message to info at phpclasses dot org.