Polylang for translating WP-reCAPTCHA plugin
-
Hi,
I’ve been searching in the documentation and in the forum but still I miss some basic instructions about using Polylang to modify plugins.
Many plugins come with no multi-language compatibility, or not enough, so I would like to translate some of the most useful for me.
I use Polylang (always last version) in my blog and I’m starting trying to translate WP-reCAPTCHA plugin (I just want to make the language of the reCaptcha dependent on the language of the user) but I’m stuck in the first part, registration of Strings.I’m not WordPress or PHP programer so I have some lacks about the basic working of WP, but I’ve frequently used other languages.
From this thread I get that I have to register the string in the constructor of the plugin. Correct me if I’m wrong but this constructor is called each time I load the settings page of the plugin, right?On the other hand as far as I understand when I refresh the String Table in the admin view of Polylang it get all the registered strings wherever they come from.
What I don’t find is the relationship between the constructor of the plugin and Polylang. And in fact, when I write the following code, see below, $polylang variable is NULL and never try to register the variable:
function __construct($options_name) { parent::__construct($options_name); $this->register_default_options(); // require the recaptcha library $this->_require_library(); // register the hooks $this->register_actions(); $this->register_filters(); // Register variable for Polylang global $polylang; if (isset($polylang)){ $options = $this->retrieve_options("recaptcha"); pll_register_string("Language Recaptcha", $options['recaptcha_language']); } }
Do I have to “require_once” any php file to be able to access to $polylang variable?
Thanks a lot,
Regards,
- The topic ‘Polylang for translating WP-reCAPTCHA plugin’ is closed to new replies.