Viewing 12 posts - 1 through 12 (of 12 total)
  • Author
    Posts
  • #1480589

    I am using the WP Booking System plugin together with the Enfold theme. WP Booking System does not support WPML, but it allows me to create the booking form in 3 languages. I need to insert a slightly different shortcode in the editor (lang=en, lang=de etc.) per language.

    [wpbs id="1" language="nl" title="no" legend="yes" legend_position="side" display="1" year="0" month="0" language="auto" start="1" dropdown="yes" jump="no" history="1" tooltip="1" highlighttoday="no" weeknumbers="no" show_first_available_date="no" form_id="1" form_position="bottom" auto_pending="yes" selection_type="multiple" selection_style="split" minimum_days="0" maximum_days="0" booking_start_day="0" booking_end_day="0" show_date_selection="no"]

    So I create a WPML config file in the root folder of my Enfold child theme with the following content:

    <wpml-config>
      <shortcodes>
        <shortcode>
          <tag>wpbs</tag>
          <attributes>
            <attribute>id</attribute>
            <attribute>language</attribute>
          </attributes>
        </shortcode>
      </shortcodes>
    </wpml-config>

    I reopened the page, updated the content, but I can still not change the German and English page through the Advanced Translation editor.
    Do you have any clue what I am doing wrong?

    PS. I have tried this solution with both a content block and a code block, both don’t give me any result.

    #1480613

    Hey envis,

    Thank you for the inquiry.

    Have you tried placing the shortcode inside a Text Block? You should be able to translate the content of the Text Block element in the WPML Translation Editor. If this doesn’t work, please provide the login details in the private field. For additional assistance, please contact the WP Booking System plugin developers.

    Best regards,
    Ismael

    #1480655

    Ismael,

    I asked WPML and they came up with this solution.

    So I expect that because of this XML, I would see an ID and LANGUAGE attribute that I can change with WPML per language version. But I do not.

    Greetings,
    Gerben

    • This reply was modified 3 weeks, 3 days ago by envis.
    #1480687

    Hi,

    Thank you for the info.

    We would like to try to override the wpml-config using the dedicated field in WPML > Settings (https://wpml.org/documentation/support/language-configuration-files/overriding-language-configuration-files/), but a script error prevents us from saving the changes. This is the error:

    Uncaught SyntaxError: Unexpected token '<' (at https://site.de/?wpml-app=ate-dashboard&ver=472900:8:1)
    
    Line:8
    
    ateDashboard(params);
    <pre style="padding:1em; background-color: #f8f8f8; color: #0a001f"><?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?>
    <shortcodes>
      <shortcode>
        <tag>av_codeblock</tag>
        <attributes>
          <attribute>alb_description</attribute>
          <attribute>av_uid</attribute>
          <attribute>codeblock_type</attribute>
    

    This might also be the reason why the Text Block and other elements are not translatable. Please forward this error to WPML support and once the issue is fixed, try to delete the wpml-config.xml file in the child theme folder, then transfer its content into the WPML > Settings > Custom XML Configuration tab.

    Let us know the result.

    Best regards,
    Ismael

    #1480704

    Maybe this was a human error. The wpml-config.xml was missing from the enfold theme folder. I have put it back there. Can you try again? Or does it have nothing to do with it?

    #1480707

    Hi,

    We actually removed the code from the config file for testing. Please try to completely remove the config xml file, then paste its content into W.P.M.L > Settings > Custom XML Configuration. You may need to forward the error to W.P.M.L support first.

    Best regards,
    Ismael

    #1480994

    Ismael, Did forward the error to WPML support. No result yet. Will try adding the content of the XML file to WPML. I am not sure where I can then find the translations of the schortcode? Should they appear in the Advanced Translation Editor?

    #1481037

    Hi,

    Yes, the builder elements should be translatable, but this doesn’t seem to be working due to the error mentioned above. Fixing the error should allow you to translate the content of the Text Block and place different versions of the wpbs shortcode for different languages.

    Another option is to create a custom shortcode that wraps the wpbs shortcode and alters the id and language attribute based on the active WPML language. Please add this code in the functions.php file:

    function av_wpbs_wpml_cb() {
        $lang = apply_filters('wpml_current_language', null);
        $id = 1;
        $language = 'en';
    
        switch ($lang) {
            case 'nl':
                $id = 1;
                $language = 'nl';
                break;
            case 'fr':
                $id = 2;
                $language = 'fr';
                break;
            case 'de':
                $id = 3;
                $language = 'de';
                break;
            default:
                $id = 1;
                $language = 'en';
                break;
        }
    
        return do_shortcode('[wpbs id="' . esc_attr($id) . '" language="' . esc_attr($lang) . '" title="no" legend="yes" legend_position="side" display="1" year="0" month="0" start="1" dropdown="yes" jump="no" history="1" tooltip="1" highlighttoday="no" weeknumbers="no" show_first_available_date="no" form_id="1" form_position="bottom" auto_pending="yes" selection_type="multiple" selection_style="split" minimum_days="0" maximum_days="0" booking_start_day="0" booking_end_day="0" show_date_selection="no"]');
    }
    add_shortcode('av_wpbs_wpml', 'av_wpbs_wpml_cb');
    

    Instead of using the default shortcode, you can use this instead:

    [av_wpbs_wpml]
    

    Best regards,
    Ismael

    #1481088

    Ismael,

    Thank you very much for your solution. I have added your shortcode generator in functions.php of the child-theme.

    function av_wpbs_wpml_cb() {
        $lang = apply_filters('wpml_current_language', null);
        $id = 1;
        $language = 'en';
    
        switch ($lang) {
            case 'nl':
                $id = 1;
                $language = 'nl';
                break;
            case 'en':
                $id = 1;
                $language = 'en';
                break;
            case 'fr':
                $id = 1;
                $language = 'de';
                break;
            default:
                $id = 1;
                $language = 'nl';
                break;
        }
    
        return do_shortcode('[wpbs id="' . esc_attr($id) . '" language="' . esc_attr($lang) . '" show_prices="yes" title="no" legend="yes" legend_position="side" display="1" year="0" month="0" start="1" dropdown="yes" jump="no" history="1" tooltip="1" highlighttoday="no" weeknumbers="no" show_first_available_date="no" form_id="1" form_position="bottom" auto_pending="yes" selection_type="multiple" selection_style="split" minimum_days="7" maximum_days="0" booking_start_day="6" booking_end_day="6" show_date_selection="no"]');
    	
    }
    add_shortcode('av_wpbs_wpml', 'av_wpbs_wpml_cb');

    Then added the shortcode to a text block:
    [av_wpbs_wpml]

    Test URL:
    https://villasari.de/nl/test-shortcode/

    I get this error:
    Fatal error: Uncaught TypeError: ksort(): Argument #1 ($array) must be of type array, null given in /var/www/vhosts/villasari.de/httpdocs/wp-content/plugins/multilingual-tools-2.2.6/inc/class-mltools-shortcode-attribute-filter.php:86 Stack trace: #0 /var/www/vhosts/villasari.de/httpdocs/wp-content/plugins/multilingual-tools-2.2.6/inc/class-mltools-shortcode-attribute-filter.php(86): ksort() #1 /var/www/vhosts/villasari.de/httpdocs/wp-content/plugins/multilingual-tools-2.2.6/inc/class-mltools-shortcode-attribute-filter.php(66): MLTools_Shortcode_Attribute_Filter->add_tag() #2 /var/www/vhosts/villasari.de/httpdocs/wp-includes/class-wp-hook.php(326): MLTools_Shortcode_Attribute_Filter->do_shortcode_tag_filter() #3 /var/www/vhosts/villasari.de/httpdocs/wp-includes/plugin.php(205): WP_Hook->apply_filters() #4 /var/www/vhosts/villasari.de/httpdocs/wp-includes/shortcodes.php(447): apply_filters() #5 [internal function]: do_shortcode_tag() #6 /var/www/vhosts/villasari.de/httpdocs/wp-includes/shortcodes.php(273): preg_replace_callback() #7 /var/www/vhosts/villasari.de/httpdocs/wp-content/themes/enfold/config-templatebuilder/avia-template-builder/php/class-shortcode-helper.php(580): do_shortcode() #8 /var/www/vhosts/villasari.de/httpdocs/wp-content/themes/enfold/config-templatebuilder/avia-shortcodes/textblock/textblock.php(541): ShortcodeHelper::avia_apply_autop() #9 /var/www/vhosts/villasari.de/httpdocs/wp-content/themes/enfold/config-templatebuilder/avia-template-builder/php/class-shortcode-template.php(1329): avia_sc_text->shortcode_handler() #10 /var/www/vhosts/villasari.de/httpdocs/wp-includes/shortcodes.php(434): aviaShortcodeTemplate->shortcode_handler_prepare() #11 [internal function]: do_shortcode_tag() #12 /var/www/vhosts/villasari.de/httpdocs/wp-includes/shortcodes.php(273): preg_replace_callback() #13 /var/www/vhosts/villasari.de/httpdocs/wp-includes/class-wp-hook.php(324): do_shortcode() #14 /var/www/vhosts/villasari.de/httpdocs/wp-includes/plugin.php(205): WP_Hook->apply_filters() #15 /var/www/vhosts/villasari.de/httpdocs/wp-content/themes/enfold/template-builder.php(102): apply_filters() #16 /var/www/vhosts/villasari.de/httpdocs/wp-includes/template-loader.php(106): include('...') #17 /var/www/vhosts/villasari.de/httpdocs/wp-blog-header.php(19): require_once('...') #18 /var/www/vhosts/villasari.de/httpdocs/index.php(17): require('...') #19 {main} thrown in /var/www/vhosts/villasari.de/httpdocs/wp-content/plugins/multilingual-tools-2.2.6/inc/class-mltools-shortcode-attribute-filter.php on line 86

    Any clue?

    #1481118

    Hi,

    Thank you for the update.

    The error doesn’t occur when the Multilingual Tools plugin is disabled. And according to the following documentation, the booking form fields need to be translated manually using the translation option in the backend — WPML will not translate the fields automatically.

    https://www.wpbookingsystem.com/documentation/translations/

    To test this, we translated the first field Familienaam to Family Name.

    View post on imgur.com

    Result:

    View post on imgur.com

    Best regards,
    Ismael

    #1481152

    Ismael,

    You are awesome, thanx for that :) It works like a charm.
    I have translated the form in the WP Booking System plugin and it looks good.

    But it seems like a side effect showed up. I have a button on the same page in the bottom. But that button URL is not translateable anymore in WPML. It used to be. Can this be related to your fix?

    WPML ATE

    • This reply was modified 2 weeks, 1 day ago by envis.
    #1481176

    Hi,

    Glad to know it’s working correctly now. As for the button, it seems to be translated correctly on our end.

    View post on imgur.com

    Best regards,
    Ismael

Viewing 12 posts - 1 through 12 (of 12 total)
  • You must be logged in to reply to this topic.