public function onTranslateRestaurantReservationDetails( object $reservation, string $langtag ) : void

Fires while translating the details of the restaurant reservation into a specific language.


Description

External plugins can use this event to apply the translations to additional details manually included within the reservation object.

Since the query used to load the details can be extended, this method offers the possibility to translate any additional data in the right way.


Parameters

$reservation

(object)  The object holding the details of the reservation.

$langtag

(string)  The language tag.

Return Value

None.


Example

The example below explains how the internal translation system works.

/**
 * External plugins can use this event to apply the translations to
 * additional details manually included within the reservation object.
 *
 * @param   object   $reservation  The reservation details object.
 * @param   string   $langtag      The requested language tag.
 *
 * @return  void
 */
public function onTranslateRestaurantReservationDetails($reservation, $langtag)
{
    // get translator
    $translator = VREFactory::getTranslator();

    // The products translation is already handled by the system, this is
    // just an explanation of how the translation system works.

    foreach ($reservation->items as &$item) {
        // translate product
        $tx = $translator->translate('menusproduct', $item->id, $langtag);

        if ($tx) {
            // inject translation within item details
            $item->productName = $tx->name;
        }
    }
}

Changelog

Version Description
1.8.4 Introduced.
Last Update: 2023-12-29 14:15
Helpful?
See Also: