Title: Multilanguage confirmation message
Last modified: April 17, 2017

---

# Multilanguage confirmation message

 *  Resolved [Ciao121](https://wordpress.org/support/users/ciao121/)
 * (@ciao121)
 * [9 years, 1 month ago](https://wordpress.org/support/topic/multilanguage-confirmation-message/)
 * Hi,
    I’m using the plugin in a multil anguage WordPress site. I translated all
   outgoing mails. But when an admin confirms (or rejects) a reservation the email
   sent to the customer is sent in the language that the admin has set as his default
   language for the site. But the mail language should be the one used by the customer
   to make the reservation. Is this a missing feature or am I missing something?
 * Thank you!

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

 *  [NateWr](https://wordpress.org/support/users/natewr/)
 * (@natewr)
 * [9 years, 1 month ago](https://wordpress.org/support/topic/multilanguage-confirmation-message/#post-9046005)
 * Hi [@ciao121](https://wordpress.org/support/users/ciao121/),
 * This is a limitation of the way that WPML implements it’s multi-language features.
   The language is always set by the current user, so when a user makes a booking,
   it is done in the language the current user has selected. But when the admin 
   confirms the booking, WPML detects the current user’s language and runs off of
   that.
 * WPML doesn’t know the language of the booking itself, only the language the current
   user has selected, so the notification emails are always sent in the language
   of the request which triggered that email.
 * I usually advise restaurants to write their confirmation or rejection messages
   in all languages, so that whatever the language of the original booking, the 
   customer will receive a message in their language.
 *  Thread Starter [Ciao121](https://wordpress.org/support/users/ciao121/)
 * (@ciao121)
 * [9 years, 1 month ago](https://wordpress.org/support/topic/multilanguage-confirmation-message/#post-9046047)
 * Thank you. This is what I’m doing now.
    If I find a workaround I’ll write it 
   here.
 *  Thread Starter [Ciao121](https://wordpress.org/support/users/ciao121/)
 * (@ciao121)
 * [9 years, 1 month ago](https://wordpress.org/support/topic/multilanguage-confirmation-message/#post-9046644)
 * I think that WPML has this feature. Look here:
    [https://wpml.org/documentation/support/sending-emails-with-wpml/](https://wpml.org/documentation/support/sending-emails-with-wpml/)
 * On the same page:
    There is an example how to store user language when he’s not
   a registered user
 *  [NateWr](https://wordpress.org/support/users/natewr/)
 * (@natewr)
 * [9 years, 1 month ago](https://wordpress.org/support/topic/multilanguage-confirmation-message/#post-9050095)
 * What you’re indicating isn’t really appropriate for this use-case, as the user
   is never really stored in the database.
 * The main issue I face as a developer is that supporting this for WPML requires
   writing an implementation specifically for WPML. Since every multilingual plugin
   handles data differently, I’d need to also write implementations for other translation
   plugins (qTranslate, Babble, etc). It quickly becomes a lot of work to maintain
   that over time, and since I don’t have close control over these third-party plugins,
   it exposes the plugin to potential bugs down the line that are out of my control.
 * For these reasons, I have so far stopped short of providing any more than the
   most basic support for WPML. But I may consider taking additional steps in the
   future if I get stronger demand.
 *  Thread Starter [Ciao121](https://wordpress.org/support/users/ciao121/)
 * (@ciao121)
 * [9 years, 1 month ago](https://wordpress.org/support/topic/multilanguage-confirmation-message/#post-9051423)
 * If I have correctly understood the page I linked above it is not needed to store
   the user in the database. It’s only needed to store the language he’s using when
   storing his email. So it can be retrieved later and passed to wpml functions.
   And having the languge stored can be usful not only for WPML.
 * But it should already be a way to retrieve reservation language users (**but 
   I cannot find where**). Because, as in my other post, in the reservation admin
   page I can switch between reservations made in different languages.
 *  Thread Starter [Ciao121](https://wordpress.org/support/users/ciao121/)
 * (@ciao121)
 * [9 years, 1 month ago](https://wordpress.org/support/topic/multilanguage-confirmation-message/#post-9056745)
 * I’ve found a solution; when the user submit the reservation form we can take 
   the used language with this:
 *     ```
       if ( defined( 'ICL_LANGUAGE_CODE' ) ) {
         $reservation_language=ICL_LANGUAGE_CODE;
       }
       ```
   
 * If we append &lang=language code (i.e. &lang=$reservation_language) the the confirm
   or reject link template the sent confirm or reject mail will be sent in the user
   language.
    The admin should have the “Set admin language as editing language”
   option ON to make this work.
 * Do you think this can be added by default to the plugin, or should I find my 
   solution to add this in a way it stays in place after I update your plugin?
 * Thank you!
 *  [NateWr](https://wordpress.org/support/users/natewr/)
 * (@natewr)
 * [9 years, 1 month ago](https://wordpress.org/support/topic/multilanguage-confirmation-message/#post-9060567)
 * Hi [@ciao121](https://wordpress.org/support/users/ciao121/),
 * That’s great to hear! Unfortunately, the `&lang=<lang_code>` will only work on
   the confirm or reject links in the emails. This won’t work if the booking is 
   confirmed or rejected from the bookings list in the admin area.
 * I was unable to find any documentation in WPML about the `ICL_LANGUAGE_CODE` 
   constant. A bunch of forum posts pop up, but no official documentation. Have 
   you found documentation about it somewhere?
 * The key information I’m looking for is to determine under what conditions the`
   ICL_LANGUAGE_CODE` constant is defined and what language it is set to.
 * The issue with this is that it only works on the request right when the booking
   is made. We need to be able to query the language of the original booking even
   when we’re viewing information about the booking in a completely separate request.
   WPML must have some way to do this since, as you said, you can switch between
   bookings made in different languages.
 * It looks like this filter is what we need:
 * [https://wpml.org/wpml-hook/wpml_post_language_details/](https://wpml.org/wpml-hook/wpml_post_language_details/)
 * So we need to use that in combination some code to switch languages and thens
   switch back. Unfortunately, I’m really struggling to find any useful documentation
   from WPML about what seems like a very simple task. I will need to reach out 
   to them to explore this further.
 * Once we figure out that missing piece, though, you should be able to use the 
   following hooks from my plugin to toggle the language before sending the notification
   emails:
 *     ```
       /**
        * Hook in before a notification is sent
        */
       add_action( 'rtb_send_notification_before', function( $notification ) {
   
       	// Don't do anything if this isn't an email notification
       	if ( !is_a( $notification, 'rtbNotificationEmail' ) ) {
       		return;
       	}
   
       	// Switch the language here
   
       	// Fetch the subject and message again
       	$notification->set_subject();
       	$notification->set_message();
       }
   
       /**
        * Hook in after a notification is sent
        */
       add_action( 'rtb_send_notification_after', function( $notification ) {
   
       	// Don't do anything if this isn't an email notification
       	if ( !is_a( $notification, 'rtbNotificationEmail' ) ) {
       		return;
       	}
   
       	// Switch the language back to what it was before
   
       }
       ```
   
 *  [Ricardo Perdigão](https://wordpress.org/support/users/toyote/)
 * (@toyote)
 * [9 years ago](https://wordpress.org/support/topic/multilanguage-confirmation-message/#post-9167939)
 * Hi [@natewr](https://wordpress.org/support/users/natewr/)
 * I have the same problem.
 * I don’t understand the last solution
 * > Once we figure out that missing piece, though, you should be able to use the
   > following hooks from my plugin to toggle the language before sending the notification
   > emails:
   > /**
   >  * Hook in before a notification is sent */ add_action( ‘rtb_send_notification_before’,
   > function( $notification ) {
   >  // Don’t do anything if this isn’t an email notification
   >  if ( !is_a( $notification,‘
   > rtbNotificationEmail’ ) ) { return; }
   >  // Switch the language here
   >  // Fetch the subject and message again
   >  $notification->set_subject(); $notification-
   > >set_message(); }
   > /**
   >  * Hook in after a notification is sent */ add_action( ‘rtb_send_notification_after’,
   > function( $notification ) {
   >  // Don’t do anything if this isn’t an email notification
   >  if ( !is_a( $notification,‘
   > rtbNotificationEmail’ ) ) { return; }
   >  // Switch the language back to what it was before
   > }
 * Where I insert this code?
 * Best regards
    Ricardo
 *  [NateWr](https://wordpress.org/support/users/natewr/)
 * (@natewr)
 * [9 years ago](https://wordpress.org/support/topic/multilanguage-confirmation-message/#post-9169613)
 * Hi Ricardo,
 * This code is not yet working anyway. It needs further work to actually perform
   the language switch.
 * When it’s complete, you could insert it in a number of places, depending on what’s
   easiest, such as a custom plugin or your theme’s functions.php file.
 *  [brodiebrodie](https://wordpress.org/support/users/brodiebrodie/)
 * (@brodiebrodie)
 * [8 years, 11 months ago](https://wordpress.org/support/topic/multilanguage-confirmation-message/#post-9255847)
 * I am also interested to follow this topic.
    And many thanks for a great plug 
   in

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

The topic ‘Multilanguage confirmation message’ is closed to new replies.

 * ![](https://ps.w.org/restaurant-reservations/assets/icon-128x128.png?rev=2205491)
 * [Five Star Restaurant Reservations - WordPress Booking Plugin](https://wordpress.org/plugins/restaurant-reservations/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/restaurant-reservations/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/restaurant-reservations/)
 * [Active Topics](https://wordpress.org/support/plugin/restaurant-reservations/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/restaurant-reservations/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/restaurant-reservations/reviews/)

 * 10 replies
 * 4 participants
 * Last reply from: [brodiebrodie](https://wordpress.org/support/users/brodiebrodie/)
 * Last activity: [8 years, 11 months ago](https://wordpress.org/support/topic/multilanguage-confirmation-message/#post-9255847)
 * Status: resolved