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    
Ratings Unique User Downloads Download Rankings
StarStarStar 58%Total: 330 All time: 7,135 This week: 122Up
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
Age: ???
All time rank: 41721 in United Kingdom
Week rank: 91 Up3 in United Kingdom Up
Innovation award
Innovation award
Nominee: 23x

Winner: 2x

Documentation

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:330
This week:0
All time:7,135
This week:122Up
 User Ratings  
 
 All time
Utility:83%StarStarStarStarStar
Consistency:83%StarStarStarStarStar
Documentation:83%StarStarStarStarStar
Examples:-
Tests:-
Videos:-
Overall:58%StarStarStar
Rank:1502