• 0

Translation certain DMS strings with Polylang

Question

Posted · Report post

Hi,

 

I've been using Polylang translation plugin with Framework v2 with great succes after the developer of Polylang wrote a plugin for me that 'harvested' the pagelines strings that needed translation like 'continue reading' links and the post metabars. With DMS this stopped working so I'm trying to find out why.

 

I don't now yet if this is is due to a change in DMS or in Polylang. But I have to start somewhere and since DMS is quite a change etc... so...

 

FYI:

About string translations in Polylang:

http://polylang.wordpress.com/documentation/setting-up-a-wordpress-multilingual-site-with-polylang/strings-translation/

 

About Polylang working with the WPML config file;

http://polylang.wordpress.com/documentation/documentation-for-developers/the-wpml-language-configuration-file/

 

The developer of Polylang wrote the following plugin for me. 

I've determined that the names of the strings like 'metabar_standard' are still the same.

But it could be that the name of the hooks changed but what is the right one to use then?

<?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',
		'metbar_clip',
		'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;
}

Thanks for any help.

 

Jan

Share this post


Link to post
Share on other sites

5 answers to this question

  • 0

Posted · Report post

HI Jan,

 

I have no experience with that plugin and if the developer wrote a specific plugin for PageLines Framework, then you will want to contact he/she for assistance.

Share this post


Link to post
Share on other sites
  • 0

Posted · Report post

Hi Danny, 

 

I understand. I contacted you because as far as aI can tell there is Pagelines specific 'code' in this plugin.

Do you know if the hook 'pagelines_hook_pre' is still available? And if not if there is a new one and what its name is?

 

Thanks, Jan

Share this post


Link to post
Share on other sites
  • 0

Posted · Report post

I searched our hook list and that doesn't appear to be there any more.

 

There is this pagelines_hook_init however, I am not entirely sure what that does and if it has replace the pre hook.

 

http://www.pagelines.com/api/dms-updates/hooks.php

Share this post


Link to post
Share on other sites
  • 0

Posted · Report post

Hi Danny,

 

Tried the hook you found, but it didn't work. Thanks for looking anyway. I'll wait for the Polylang dev. Maybe he has an idea how to get this working again. If by any chance you speak to one of the devs maybe you ask him which hook replaced the one that I mentioned before. Maybe the purpose of the hook is I to install some code that replaces a translated string. 

 

Thanks, Jan

Share this post


Link to post
Share on other sites
  • 0

Posted · Report post

Hi Danny,

 

The Polylang dev just replied. He said that Polylang-wise the code should still work. 

So I guess it's changed hooks/filters in the code I posted earlier that prevents it from working.

 

In reseaching it further I did find the following page in the Polylang documentation in which is explained that Polylang supports the WPML API. It states that the following WPML function is supported:

 
----------------------------------
icl_register_string
Polylang equivalent: pll_register_string
 
Allows plugins to add their own strings in the “strings translation” panel. Unlike pll_register_string, icl_register_string stores the string in the database (as the WPML original function does).
 
Usage:
icl_register_string($context, $name, $string);
$context => (required) the name of the plugin
$name => (required) the name of the string
$string => (required) the string that needs to be translated
 
from:

http://polylang.wordpress.com/documentation/documentation-for-developers/compatibility-with-the-wpml-api/

----------------------------

 

So I'm wondering if the following DMS strings are also included for WPML, I thought DMS was compatible?

'metabar_standard',
'metbar_clip',
'continue_reading_text'
 
They don't show up anyway in the custom strings panel of Polylang and they most likely would if these strings were registered in the WPML-way

 

If possible please ask one of the devs to have a quick look. I guess it could be useful for other DMS users too since It's a free plugin (in contrary to WPML).

 

Maybe I'm just thinking to complex and there is another way to translation these strings?

 

Thanks, Jan

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