• Hello,

    I wish my WP to automatically send an email in different languages, depending on some program condition.

    I have a pll_register_string() for an email text, and this text is translated. But pll__() always returns an email text in WP’s native language, and I’m failing to see where can I use this program condition of mine.

    Is it possible to do something like this:

    $translation = pll__($my_string, 'en'); // get english translation
    $translation = pll__($my_string, 'fr'); // get french translation

    I have a latest Polylang and WP.
    Permalinks structure is /%postname%/
    Homepage is static.

    https://wordpress.org/plugins/polylang/

Viewing 1 replies (of 1 total)
  • Plugin Author Chouby

    (@chouby)

    Hi!

    Yes. By default only one language is loaded by WordPress (and Polylang does not load other for performance reasons).

    You can inspire yourself from this to get translated strings registered with pll_register_string:

    global $polylang;
    
    foreach ($polylang->model->get_languages_list() as $language) {
    	$mo = new PLL_MO();
    	$mo->import_from_db($language);
    	$translation = $mo->translate($my_string);
    	...
    }
Viewing 1 replies (of 1 total)
  • The topic ‘Getting string translation on custom language’ is closed to new replies.