0

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>';
}
0

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).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.