The Language Mix plugin for WordPress¶
The Language Mix plugin for WordPress is a kind of assistant for the Polylang plugin of Chouby. As you might know, the Polylang is one of the best plugins, that implement support of multiple languages in WordPress. Thus, using this plugin you can create translations of your blog, which will be available under special URL paths like
/en for English. Each such translation will show only articles written in the appropriate language. Additionally, Polylang supports the concept of the default language, which is assumed when no special path is used. The Language Mix plugin is aimed to extend this concept...
In the case, when you don’t have all you articles translated into all other supported languages, you may want to show some articles untranslated, when you are sure, that the visitor can read the appropriate language. That’s what the Language Mix plugin changes! Certainly, this can be done, only when no language is specified explicitly – i.e., only for the default language view. This way your blog can still provide one-language-only areas.
User languages configuration¶
As a webmaster and a WordPress administrator you don’t have to care, contents in which languages a user wants to see – the Language Mix plugin takes care of this by itself, it’s between the plugin and the user! Anyway, to get the idea, how does the plugin do this check this page (well, it worth checking it anyway). Yet still you can help users by allowing them to tweak language settings through a widget on your blog...
The Languages widget¶
To determine, which languages the user can read the plugin inspects the Accept-Language HTTP header (check more details here). But before this it checks the special
pllx_languages cookie. I.e., if this cookie is available, its content has a higher priority than the content of the Accept-Language header! This way you can let your users configure, which languages they want to see. That’s what the Languages widget allows to do!
You can find this widget in Appearance → Widgets:
As it’s seen the widget supports only the “Title” option.
On the front-end the widget gets rendered as follows:
You can also see it live, e.g., here.
Its behavior is simple: Users just check, contents in which languages they want to see, and click “Apply”. The specified settings get saved into cookies of the user’s browser.
The Translations widget¶
The Polylang plugin comes with the Language Switcher widget, that lets you switch the language on any page. After selecting the language you get redirected either to the translation of the current page or to the index page of the language... There is no way to hide a language on this widget, if the appropriate translation is not available! To fix this the Language Mix comes with the Translations widget.
This widget (along with many others, actually) can be found in Appearance → Widgets:
Like the Languages widget this one has only the “Title” option.
On the front-end the widget looks like:
You can also check the widget live here.
If no translations are available for the content, the widget is not shown!
- Start from installing the Polylang plugin (check these instructions on how to do this).
Of course, if you don’t have the Polylang plugin installed yet...
- Copy the
language-mixdirectory to the
wp-content/pluginsdirectory of your WordPress installation.
- Activate the Language Mix plugin using the Plugins menu in WordPress.
- Optionally (but recommended) put the Languages widget on index pages using Appearance → Widgets.
- Optionally (but recommended) put the Translations widget on single post pages.