How to get full native language instead of iso?

I am not using WPML or Polylang, but multisite to create multiple languages. The code below is used to make a language switcher, but I want a second menu with the full language name for a different menu (i.e. EN should be English, FR - Français, DE - Deutsch). Wordpress has the native names stored (because when selecting a language you get a list with the native language name), but how can I access this to use?

$languages = get_available_languages();
foreach ($languages as $item) {
   $iso = substr($item, 0, 2);
   echo 'li'. $iso .'/li';
}

Topic multi-language multisite theme-development Wordpress

Category Web


Use this locale_get_display_name()


I'm almost sure that you can use locale_get_primary_language function for that.

echo locale_get_primary_language( $item ); 

Maybe it'll need some tweaking, because I'm not sure if formats will match (for example you may have to change '' to '' or change it to lower/upper-case).

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.