Support » Plugins » [Plugin: Polylang] How to use String Translation?

  • I’m using the Polylang plugin for a multilingual website, but I can’t figure out how to use
    the string translation functionality for translating custom lines.

    I added this line to my functions.php:

    pll_register_string('Test Textblock', $testtextblock);

    And I put this line in my page template:

    <?php pll__('Test Textblock'); ?>

    But yet nothing shows up in the ‘Strings Translation’ tab of the Polylang plugin.
    I’d like to add more strings to the Strings Translation tab, to make the whole website multilingual. I hope someone here can help me out with this, thanks!

Viewing 1 replies (of 1 total)
  • Are you sure that $testtextblock contains a non empty string?

    <?php pll__('Test Textblock'); ?> won’t work. The original string that will be translated is the second parameter of the pll_register_string function. The first parameter is provided only for convenience to sort strings in the translations list table. Moreover pll__ does not echo the string. Either use echo pll__(...) or pll_e(...).


    if (is_admin())
      pll_register_string('custom translation', 'my string to translate');
      echo pll__('my string to translate');

Viewing 1 replies (of 1 total)
  • The topic ‘[Plugin: Polylang] How to use String Translation?’ is closed to new replies.