I have following locale strings:
pl_PL
en_GB
Is it possible to convert it with some native function that works with real locale dataset into:
pl
en
Solutions like:
list($short) = explode('_', 'pl_PL');
is not expected right now.
locale_parse
from the intl
extension should do this for you. From the documentation:
<?php
$arr = locale_parse('sl-Latn-IT-nedis');
if ($arr) {
foreach ($arr as $key => $value) {
echo "$key : $value , ";
// language : sl , script : Latn , region : IT , variant0 : NEDIS ,
}
}
?>