php - How to get the default languge from the ICU library by Country Code -


en_us gives me en english it's in code

i need us return en english or 'de' return de german

echo locale::getprimarylanguage('en_us'); echo locale::getprimarylanguage('us'); 

both of above should output en, latter outputs us.

getprimarylanguage not icu function have no idea how it's implemented. in icu call uloc_addlikelysubtags expand und_us (you put und unknown before region code us) en_us or und_de de_de - , then, calling uloc_getlanguage return en, de, etc.

your result of us us due us being interpreted language code. try und_us see behavior is.


Comments

Popular posts from this blog

jquery - Invalid Assignment Left-Hand Side -

java - Play! framework 2.0: How to display multiple image? -

asp.net mvc - Implementing normal user/pass, Twitter & Facebook auth -