I'm using WP 3.5 and Polylang 0.9.8 plugin to make translations to different languages.

All is good, and the plugin works fine, but now I'm facing a problem -- I need to translate custom strings, for example, strings inside widgets.

What can you recommend me to solve this problem?

ADDED: For example (I'm taling about text in widgets, but not header), can I add some string constants or so and write them from php-code into my page -- and got them to translate on String translation page of Polylang?

  • This question isn't very answerable in its current form. How you'd address translating those strings has a lot to do with how your plugins and theme are written and is a big topic.
    – s_ha_dum
    Jan 23 '13 at 23:53
  • How can I concrete question?
    – tro
    Jan 27 '13 at 19:01

Use this


on functions.php

Use it like this:


Allows plugins to add their own strings in the “strings translation” panel. The function must be called on admin side (the functions.php file is OK for themes).

pll_register_string($name, $string, $multiline);
‘$name’ => (required) name provided for sorting convenience (ex: ‘myplugin’)
‘$string’ => (required) the string to translate
‘$multiline’ => (optional) if set to true, the translation text field will be multiline, defaults to false


pll_register_string('Header Title', 'The title you want to appear');

Then on dashboard config, on languages, you are going to find a tap called "strings". There you're going to have this new created string, and an input text to fill the translation text for every active language on your site. Write translations, and then use the funcions:

pll_e() to directly echo, or pll__() to manually echo it. Your'ge going to use it like:

pll_e('The title you want to appear'); or
echo pll__('The title you want to appear');

That's it! :)

  • Thanx! That was issue! Strange, that question is simple, but no one answered for a long time.
    – tro
    Feb 14 '13 at 9:35
  • Shouldn't pll call the variable name, rather than its content? -> pll_e('Header Title'); ?
    – jj_
    Jul 20 '18 at 9:12

I have the some problem with troyane. There are a few escape functions that are integrated with internationalization functions,Such as :esc_html__() and esc_html_e() to get the Escaping strings. But how can I do that when I use ploylang?

Escaping strings

<a title="<?php esc_attr_e( 'Skip to content', 'my-theme' ); ?>" class="screen-reader-text skip-link" href="#content" >
  <?php _e( 'Skip to content', 'my-theme' ); ?>

Here is my code

            <?php if (get_theme_mod('col_heading','') != '') { ?>

                    <h2 class="section-heading"><?php esc_html_e(get_theme_mod('col_heading')); ?></h2>

                    <?php } else { ?>

                        <h2 class="section-heading">Services</h2>

                    <?php } ?>

                    <?php if (get_theme_mod('col_sub','') != '') { ?>

                        <h3 class="section-subheading text-muted"><?php echo esc_html(get_theme_mod('col_sub','')); ?></h3>

                    <?php } else { ?>

                        <h3 class="section-subheading text-muted">Phasellus elementum odio faucibus diam sollicitudin</h3>

                    <?php } ?>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.