Language switcher block

The Language switcher block can display a placeholder language switcher when a multilingual plugin isn’t installed yet, but will switch to using languages from WPML or Polylang once detected.

Language list

Language dropdown

Flag dropdown

Circular flag dropdown

Custom icon

It’s not possible to configure the Language Switcher block to use an icon, but it can be wrapped in a container element that has an icon (Image block in “Icon” mode) and the language switcher (with flag/label hidden), producing the desired result.

Block options

Mode

The block can be in “List” mode to render a basic <ul> > <li> of the languages, or in “Dropdown” mode which utilizes the Dropdown module to show other languages in a dropdown.

Label

Allows to choose which language label to render: Name, Native name, Translated name, language Code or none. Additional customizations can be made with the following filter:

Custom language switcher labelPHP
/**
 * Language structure ($lang):
 *	[
 *		'id' => string,
 *		'code' => string,
 *		'name' => string,
 *		'native_name' => string,
 *		'translated_name' => string,
 *		'is_active' => boolean,
 *		'has_translation' => boolean,
 *		'url' => string,
 *		'flag_url' => string,
 *	]
 */
add_filter('ska_blocks_language_switcher_label', function($label, $lang) {
	return sprintf(
		'%1$s (%2$s)', 
		esc_attr($lang['native_name']), 
		esc_attr($lang['translated_name'])
	);
}, 10, 2);

Toggles

  • Show language flag
  • Show active languages
  • Show inactive languages
  • Show missing languages