Support » Theme: Customizr » Polylang and Customizr

  • We’ve had a few unresolved questions on this forum about using qTranslate with Customizr.

    qTranslate required some work from nikeo to get it working with Customizr. Changes were required to lengthen the strings on the front page so that you had enough room to enter several languages’ worth of text (with qTranslate shortcodes) in the Featured Page texts / Buttons etc. From the Customizr side, this is all working fine.

    But qTranslate’s own problems cannot be solved from the Customizr side and I know that there are a lot of problems that aren’t being answered on the qTranslate forum. And because qTranslate is so tightly bound up with the WordPress menus etc., it disables part of itself when a new version of WordPress comes out. An update for WP 3.8.1 was not immediate.

    So: what else can we do?

    Well there’s WPML, which I’ve never tried; and the latest versions are not free. And then there’s Polylang, which I tried once—and liked—but it doesn’t support Customizr’s Front Page options right out of the box.

    To explain: Polylang takes a different approach to qTranslate. While qTranslate keeps both languages on one page and presents the browser with the right subset of title/text, Polylang keeps a separate page for each language and allows you to link the pages together from the page edit screen.

    The problem was always the Customizr Front Page. While qTranslate allows you to enter shortcodes into the Customizr Featured Pages texts and buttons, Polylang doesn’t have shortcodes. For “special” text, such as the date formats, site title, tagline, and widget titles, Polylang has a separate panel for “Strings translation”. Out of the box, it doesn’t give you any options to change Customizr’s Featured Page texts and buttons.

    Last November, this changed, when the author of Polylang very kindly posted some code that put some of the Customizr strings into Polylang’s “Strings translation” panel. Bingo!

    I’ve been meaning to look at it for a while and finally got round to doing so.

    The code (from the Polylang author’s site) is:

    // Makes Customizr frontpage multilingual with Polylang; License: GPLv3; Credits:
    if (defined('POLYLANG_VERSION')) add_filter('option_tc_theme_options', 'pll_tc_options');
    function pll_tc_options($options) {
    	$areas = array('one', 'two', 'three');
    	if (is_admin()) {
    		pll_register_string('tc_featured_page_button_text', $options['tc_featured_page_button_text'], 'Customizr');
    		foreach ($areas as $area)
    		pll_register_string('tc_featured_text_'.$area, $options['tc_featured_text_'.$area], 'Customizr', true);
    	else {
    		$options['tc_featured_page_button_text'] = pll__($options['tc_featured_page_button_text']);
    		foreach ($areas as $area) {
    			$options['tc_featured_text_'.$area] = pll__($options['tc_featured_text_'.$area]);
    			$options['tc_featured_page_'.$area] = pll_get_post($options['tc_featured_page_'.$area]);
    		// filters sliders by language
    		$pll_options = get_option('polylang');
    		if (!empty($options['tc_sliders']) && $pll_options['media_support']) {
    			foreach ($options['tc_sliders'] as $slider => $images)
    			foreach ($images as $key => $img)
    			if (!(($id = pll_get_post($img)) && $id == $img))
    	return $options;

    Once again: thanks to the author for sharing this code.

    You can either load this as a plugin as he suggests (in which case, you’ll need the extra header code shown on his page) or—as I prefer—load it in your Customizr child-theme’s functions.php (I find that easier: so all my custom code is in one place).

    If you don’t know how to add code to a Customizr child theme, read how to customize Customizr first. Now—with Polylang active and “Show all languages” selected in the Admin bar—select Dashboard > Settings > Languages and click the “Strings translation” tab. From there, you will be able to change the Featured pages text and buttons, as well as the WordPress Site Title/Tagline/date format/Widget titles etc.

    A word about the slider. The only way to make the slider work seems to be to set the option “Activate languages and translations for media” to ON (in Dashboard > Settings > Languages). Then:
    – Create copies of your slides—one copy for each language.
    – Set the language of each copy of the slide to match your languages (so if your langs are en/fr, then each slide should have 2 copies: en and fr).
    – Add every slide (all slides in all languages) to your slider, filling in the relevant language’s Title, Description, and Button text for each.
    – (You may not need to do this step, but I found that I did at one point (at the beginning), so I put it in here, just in case.) For each language, choose the language from the admin bar, then open Customiz’it and set the slider name in the Front Page panel.

    Although all the language slides are in the slider, Polylang will only deliver the slides for the relevant language to the browser.

    When “Activate languages and translations for media” (in Settings > Languages) is set OFF, I can’t get it to work (though I feel I ought to be able to make a sliders for each language, but I couldn’t hack it; maybe someone else can).

    Note the author’s caveat that this works only if the language is set in the url (directory, subdomain or domain name). So you will have to see “/en/” at the end of your links or “en.” at the beginning. Note also that this code has been reported to NOT work with featured pages unlimited, but I’m hoping that someone who has that extension can generalize the code to make it work on both.

    Once enough people have tried this and we’ve ironed out the issues, then I’ll try to immortalize it into a snippet or a new guide on the site.

    Fire away with problems!

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘Polylang and Customizr’ is closed to new replies.