WordPress.org

Forums

Polylang
[resolved] How do I translate entries of display options section in YARPP plugin with Polyl (6 posts)

  1. alefam
    Member
    Posted 2 years ago #

    I would like to translate entries of display options section in YARPP plugin admin area with Polylang plugin. The default texts are "Related posts" and "No related posts". These strings do not appear in "string translations" section of polylang. I have tried pll_register_string('name', 'string'); and echo pll__('string'); but they did not work. I think I have to put something with $ instead of string. Any help appreciated.

    http://wordpress.org/extend/plugins/polylang/

  2. Chouby
    Member
    Plugin Author

    Posted 2 years ago #

    You can add this in custom plugin:

    add_filter('option_yarpp', 'translate_yarpp');
    function translate_yarpp($options) {
    	$to_translate = array('before_related', 'no_results');
    	foreach ($options as $key=>$opt) {
    		if (in_array($key, $to_translate)) {
    			if (is_admin())
    				pll_register_string($key, $opt);
    			else
    				$options[$key] = pll__($opt);
    		}
    	}
    	return $options;
    }
  3. alefam
    Member
    Posted 2 years ago #

    Hi Choby

    Thank you very much for your great plugin and help. The custom plugin works for "Default display if no results:" section but the "Heading" section doesn't change and always shows "Related posts:" and obviously cannot be translated. I have replaced array('before_related', 'no_results');with array('thumbnails_heading', 'no_results'); and now it works fine.
    I am really appreciated for your help and time.

  4. alefam
    Member
    Posted 2 years ago #

    It would be great if you could implement this function into the next version.
    thanks again.

  5. Chouby
    Member
    Plugin Author

    Posted 2 years ago #

  6. Chouby
    Member
    Plugin Author

    Posted 2 years ago #

    You can look at our discussion with mitcho in the link above to have a definitive solution which better integrates with the way YARPP is working.

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • Polylang
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic