Bilingual website

This topic contains 4 replies, has 2 voices, and was last updated by  Luc Gagnon 8 years, 11 months ago.

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #22131

    Hi,
    I’m working on a bilingual website (using Polylang) and most of the plugin is working perfectly. I have 2 issues.
    1. How can I have confirmation emails in 2 languages?

    1. I want the registration form to present the Paypal page in the right language. So I set up a hidden field in the form to do it but it doesn’t work. I see the field in the form but it’s still the English page of Paypal I’m getting


    add_action( 'eventorganiser_get_event_booking_form', 'my_add_field');
    function my_add_field(){<br />
    $element = new EO_Booking_Form_Element_Hidden( array(
    'id' => 'lc', //a unique ID
    'value' => 'FR'
    ));
    }

    Any help would be appreciated as I really like plugin so far. Thanks.

    Luc Gagnon
    #22169

    Hi Luc,

    You can use the eventorganiser_booking_confirmed_email_body filter to change the e-mail text. (You can use the placeholders in the message too):

    add_filter( 'eventorganiser_booking_confirmed_email_body', function( $message, $booking_id ) {
         //alter $message
         return $message;
    }, 10, 2 );
    

    For setting PayPal’s language you can use the eventorganiser_pre_gateway_checkout_paypal (though setting the locale has not been tested).

    add_filter( 'eventorganiser_pre_gateway_checkout_paypal', function( $cart, $booking ) {
          $cart['lc'] = 'FR';
          return $cart;
    }, 10, 2 );
    

    Adding a booking field won’t help as the form doesn’t post directly to PayPal, it first goes through the plug-in.

    Stephen Harris
    #22179

    Thanks. It works great.

    Now, what would be the best way to translate the different error message like “Please select a ticket”. I’d like to do it in my custom plugin file.

    Luc Gagnon
    #22194

    Hi Luc,

    That text should already be translated based on the selected site language. I don’t know how Polylang works, so if they’re not switching the locale you can use the following method:

    add_filter( 'gettext', 'my_translate_text', 20, 3 );
    function my_translate_text( $translated_text, $text, $domain ) {
        if ( 'eventorganiserp' !== $domain ) {
              return $translated_text;
        }
    
        switch ( $translated_text ) {
                case 'Please select a ticket' :
                    $translated_text = 'Translated text';
                    break;
    
                case 'Another string to translate' :
                    $translated_text = 'Another string translated';
                    break;
    
                //Add more cases as required
            }
        }
    
        return $translated_text;
    }
    

    Please note that not all strings you see will be able to be translated like this. Only hard-coded strings can be translated. Any user-provided text is not translatable unless it has its own dedicated filter (such as the booking e-mail body).

    Finally, you may want to perform some check on the language currently in use – you’ll have to consult Polylang’s API on how to do that.

    Stephen Harris
    #22211

    Thanks again. Don’t know why, most of the plugin is translated but this Error message wasn’t. It was in the booking-actions.php file.

    Luc Gagnon
Viewing 5 posts - 1 through 5 (of 5 total)
To enable me to focus on Pro customers, only users who have a valid license for the Pro add-on may post new topics or replies in this forum. If you have a valid license, please log-in or register an account using the e-mail address you purchased the license with. If you don't you can purchase one here. Or there's always the WordPress repository forum.