Polylang

Polylang
WordPress plugin

Polylang is a great free alternative to the popular, but premium WPML plugin for creating a multilingual WordPress site.

Chap theme supports Polylang Language Switcher widget in all widget areas: Header, Menu, Sidebar and Footer. The widget must be displayed as dropdown. Chap will automatically add flags to the dropdown. In order to conserve space, in header widget area all text will be hidden.

Language switcher widget must be displayed as a dropdown
Language switcher widget must be displayed as a dropdown.
Read also: How to translate strings.

Rendering the language switcher in a template

Using the pll_the_languages function it’s possible to render the language switcher in a template file, how ever the theme filter that applies Semantic UI styles to the switcher is by default only called for widgets in widget areas.
How ever it’s possible to apply the filter function manually:

PHP
Rendering the language switcher in a template
if(function_exists('pll_the_languages')) {
	$language_switcher = Chap\Widgets\filter_polylang('<span class="widget_polylang">' .
		pll_the_languages([
			'dropdown' => true,
			'echo' => false,
		]) .
	'</span>', '', 'sidebar-header');
	echo str_replace('icon button', 'your-custom-button-classes icon button', $language_switcher);
}

One response to “Polylang

Leave a comment

Your email address will not be published. Required fields are marked *