• Hello,
    Thank you for this amazing plugin! My question is: Can I translate the database with Polylang? I couldn’t find info about that anywhere.

    Thank you =)

Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Author xnau webdesign

    (@xnau)

    The plugin dos not have specific support for Polylang, but I believe it will work because it does use the standard gettext method for using translation files.

    I don’t know enough about Polylang to know how it handles user settings, since these strings are set by the user and are not in the translation files. I have an article on using the plugin in a multilingual setup that might be helpful:

    Localizing Participants Database

    Thread Starter neshkaa

    (@neshkaa)

    Thank you, I have added the define( 'PDB_MULTILINGUAL', true ); line in functions.php, but I couldn’t find a way to add complex strings like in the example with Q-Translate-X.

    I found this solution and tried it, but I still can’t get the translations I added in the .po and .mo files to show up on the [pdb_list] and [pdb_single] pages. What could I be missing?

    Plugin Author xnau webdesign

    (@xnau)

    Complex strings are only used for user settings, they don’t actually have anything to do with translation files. Translation files are used for static text like labels and help text in the admin. Some text seen on the frontend comes from the translation files, but most of it will be user settings, and so they need to be constructed using complex strings.

    For instance, you would use a complex string for the title of a field which would then be parsed to show the title in the user’s chosen language.

    Thread Starter neshkaa

    (@neshkaa)

    Thank you for clearing that up, I am pretty much a beginner and this is very helpful.
    I understand that Polylang doesn’t have a way to input complex strings, but I found a way to translate strings with a shortcode:

    // [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 seems to be working on posts, pages and everywhere in my theme, but it is still not translating the Participants Database fields. Instead, it displays the entire shortcode. Do you have any ideas on how this can be resolved?

    Thank you again for your help =)

    Plugin Author xnau webdesign

    (@xnau)

    Shortcodes in Participants Database strings are not normally processed, but there are several approaches you could take to get what you want. All Participants Database strings are passed through a translation filter ‘pdb-translate_string’

    You can set up a function on the filter that applies your shortcode (using do_shortcode() ), or you can use some other method (like a lookup table) to provide the correct language string.

    Thread Starter neshkaa

    (@neshkaa)

    Thank you again! =) It worked after I added this:

    add_filter( 'pdb-translate_string', 'shortcode_unautop');
    add_filter( 'pdb-translate_string', 'do_shortcode', 11);

    There is just one small issue: my new multilingual shortcode dissapears after I save it in the database fields. Everything is still there and correctly translated on the frontend, but I cannot see the shortcode in the Title field in Manage Database Fields (however the shortcodes in the Options field are not dissapearing), in Manage List Columns, in List Participants and in List Participants / Sort by (attached are screenshots). What can I do to make them visible?

    I am also looking for a way to translate the pdb_single page. I read that you advised someone with a similar question to change the “single_record_link” attribute of the pdb_list shortcode based on language chosen, but I have no idea where and how to do that. I tried modifying just the shortcode itself by adding [pdb_list single_record_link="page-slug"] and having that page in the correct language, but regardless of that it always displays the list in the language of whatever page is set in Participants Database / Settings / List Display Settings / Single Record Page, where I can select only one page. The single record also is only visible in that language, and can be opened only from the [pdb_list] page of the same language. What am I missing?

    Thank you again for the invaluable support! =)

    Plugin Author xnau webdesign

    (@xnau)

    For your first questions, I’m traveling and can’t properly test that issue, so I don’t know why your filter is not working on those titles in the admin.

    For the single record page, if you want to change the destination of the single record link based on the language, you need to use the pdb-single_record_url filter, where you can change the URL that is used in the single record link.

    The “single_record_link” attribute of the list shortcode determines which field gets the link, not where the link goes.

Viewing 7 replies - 1 through 7 (of 7 total)

The topic ‘Compatibility with Polylang’ is closed to new replies.