public static function langToLocale($lang)
    {
        $defaultLocale = 'C';
        $langs         = [];
        foreach (self::$alllngs as $langCode => $language) {
            $langs[$langCode] = [strstr($langCode, '_') ? substr($langCode, 0,
                    strpos($langCode, '_')) : $langCode, $language];
        }
        foreach ($langs as $code => $langInfo) {
            if ($lang == $langInfo[0]) {
                $defaultLocale = $code;
                break;
            }
        }
        return $defaultLocale;
    }
public static function langToLocale($lang)
    {
        $defaultLocale = 'C';
        $langs         = [];
        foreach (self::$alllngs as $langCode => $language) {
            $langs[$langCode] = [strstr($langCode, '_') ? substr($langCode, 0,
                    strpos($langCode, '_')) : $langCode, $language];
        }
        foreach ($langs as $code => $langInfo) {
            if ($lang == $langInfo[0]) {
                $defaultLocale = $code;
                break;
            }
        }
        return $defaultLocale;
    }
public static function langToLocale ( $ lang ) { $ defaultLocale = 'C' ; $ langs = [ ] ; foreach ( self :: $ alllngs as $ langCode => $ language ) { $ langs [ $ langCode ] = [ strstr ( $ langCode , '_' ) ? substr ( $ langCode , 0 , strpos ( $ langCode , '_' ) ) : $ langCode , $ language ] ; } foreach ( $ langs as $ code => $ langInfo ) { if ( $ lang == $ langInfo [ 0 ] ) { $ defaultLocale = $ code ; break ; } } return $ defaultLocale ; }
Find Locale Code for browser language

@param string $lang browser lan en|cs|..

@return string locale code
Find Locale Code for browser language