• Hi!

    Is there a possibility to translate strings in-place using shortcodes e.g. [trp_language language=”en”]Messages[/trp_language][trp_language language=”de”]Nachrichten[/trp_language]?

Viewing 2 replies - 1 through 2 (of 2 total)
  • No, there is nothing like this because it is not working with the concept of Polylang.

    Thread Starter asfhdf78as

    (@asfhdf78as)

    I’ve go a theme that does not “export” all the strings one can enter properly. It happens mainly in lists on the frontpage. I understand that a shortcode isn’t the clean solution and string literals will be on many places. Polylang doesn’t offer anything for such a case, correctly?

    I’ve found a shortcode that would do the thing I am asking. Colinschwebke has it on Github:

    // [polylang lang="en"]English[/polylang][polylang lang="de"]Deutsch[/polylang]
    //Add this code in your functions.php
    function polylang_shortcode($atts, $content = null)
    {
      if (empty($content))
        return '';
      extract( shortcode_atts( array('lang' => ''), $atts ) );
      if (empty($lang))
        return "### You must specify 'lang' using shortcode: polylang";
      return ($lang == pll_current_language()) ? $content : '';
    }
    add_shortcode('polylang', 'polylang_shortcode');
    • This reply was modified 5 years, 9 months ago by asfhdf78as.
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Shortcodes for translation in-place’ is closed to new replies.