Jump to content
janpeeters

Workaround: Translating PL Framework with Polylang

Recommended Posts

janpeeters+    31
janpeeters

Hi,

I've been searching and posting around to get Polylang (a relatively new kid on the block when it comes to translation) to work with Framework. I wanted this because WPML is a paid solution nowadays and because I think its good if WPML gets some competitors. Well Polylang is not yet at that stage, but I got a full translation of Framework with it.

At first the blog title and tagline didn't translate nor user definable strings like 'Continue Reading…' and the 'Posted on [date] by [author]' Metabar, but after some communication with Chouy (his name on WP forums) the Polylang dev fixed this as follows.

At the moment you can translate Framework by installing the latest Polylang build 0.9.3.1.

Then you create a php file with the following code:

The code pulls the Metabar and Continue Reading strings from Pagelines settings so that you can translate them manually


<?php

/*

Plugin Name: Polylang translates Pagelines strings

*/

add_action('pagelines_hook_pre', 'pll_pagelines_settings');

function pll_pagelines_settings() {

if (function_exists('pll_register_string'))

  add_filter('option_pagelines-settings-two', 'translate_pagelines_settings');

$pll_options = get_option('polylang');

if (!($GLOBALS['wp_rewrite']->using_permalinks() && $pll_options['force_lang']))

  add_action('wp', 'pll_reload_pl_settings');

}

// reload pagelines settings to translate them when Polylang defers language loading

function pll_reload_pl_settings() {

$GLOBALS['global_pagelines_settings'] = ( array ) get_option(PAGELINES_SETTINGS);

}

// translates strings in the array $to_translate

function translate_pagelines_settings($values) {

$to_translate = array(

  'metabar_standard',

  'continue_reading_text'

);

foreach ($values as $key=>$value) {

  if (in_array($key, $to_translate)) {

   pll_register_string($key, $value);

   $values[$key] = pll__($value); 

  }

}

return $values;

}

You can also find it here: http://paste.pagelines.com/8w8

And you save the file e.g. with name polylang_plframework.php in your WP plugin folder and activate it.

This creates two new strings up in the Strings Translation page in Polylang for the 'metabar' and the 'continue reading' string.

Translate the strings to your liking and you are all set.

Of course this is a workaround. In another thread I'm trying to find out how Pagelines Framework works with WPML so that the Polylang dev can update his plugin to fully (without workarounds) support Framework. Until this is clear, the workaround above is a quick fix.

http://www.pagelines.com/forum/topic/22467-how-to-translate-manually-added-strings-like-continue-reading%E2%80%A6-in-polylang/

You can see the proper translation at work at my site:

www.janpeeters.nl

Good luck,

Jan

Share this post


Link to post
Share on other sites
Rob    547
Rob

Thank you Jan. It was very kind of you to share this.


Former PageLines Moderator, Food Expert and Raconteur

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now


×