0, ]; $min_max_settings = apply_filters( 'eshb_min_max_global_settings_localize', $min_max_settings_global); $calendar_start_date_buffer = !empty($eshb_min_max_settings['calendar_start_date_buffer']) ? $eshb_min_max_settings['calendar_start_date_buffer'] : 0; $eshb_admin_translations = [ 'billingEmailErr' => __('Billing email not found!', 'easy-hotel'), 'maximumTimeSlot' => __('Allowed max time for this slot is', 'easy-hotel'), 'minimumTimeSlot' => __('Allowed min time for this slot is', 'easy-hotel'), 'minNightsErrorMsg' => __('Ops! This Reservation has been failed. Requried Minimum', 'easy-hotel'), 'maxNightsErrorMsg' => __('Ops! This Reservation has been failed. Requried Maximum', 'easy-hotel'), 'minNightsErrorMsgAvCal' => __('Requried Minimum Nights:', 'easy-hotel'), 'maxNightsErrorMsgAvCal' => __('Requried Maximum Nights:', 'easy-hotel'), ]; $nonce_action = ESHB_Helper::generate_secure_nonce_action('eshb_global_nonce_action'); wp_localize_script( 'eshb-admin-script', 'eshb_ajax', array( 'ajaxurl' => admin_url( 'admin-ajax.php' ), 'is_admin' => is_admin(), 'nonce' => wp_create_nonce($nonce_action), 'pluginURL' => ESHB_DIR_URL, 'admin_translations' => $eshb_admin_translations, 'calendar_start_date_buffer' => $calendar_start_date_buffer, ) ); wp_localize_script('eshb-admin-script', 'eshb_rest', [ 'root' => esc_url(rest_url()), 'nonce' => wp_create_nonce('wp_rest'), 'is_admin' => is_admin(), ]); // Get WordPress current locale $locale = get_locale(); $eshb_settings = get_option('eshb_settings'); $apply_text_default = isset($eshb_settings['string_apply']) && !empty($eshb_settings['string_apply']) ? $eshb_settings['string_apply'] : ''; $cancel_text_default = isset($eshb_settings['string_cancel']) && !empty($eshb_settings['string_cancel']) ? $eshb_settings['string_cancel'] : ''; // Prepare translations dynamically based on current locale $calendar_translations = [ 'applyLabel' => !empty($apply_text_default) ? eshb_get_translated_string($apply_text_default) : __('Apply', 'easy-hotel'), 'cancelLabel' => !empty($cancel_text_default) ? eshb_get_translated_string($cancel_text_default) : __('Cancel', 'easy-hotel'), 'BookedTooltip' => __('Already Booked!', 'easy-hotel'), 'holidayTooltip' => __('This is Holiday!', 'easy-hotel'), 'fromLabel' => __('From', 'easy-hotel'), 'toLabel' => __('To', 'easy-hotel'), 'customRangeLabel' => __('Custom Range', 'easy-hotel'), 'weekLabel' => __('W', 'easy-hotel'), 'firstDay' => get_option('start_of_week'), // Get WordPress's start of the week setting 'currentLocale' => $locale, // Pass current locale for debugging or further use ]; // Pass translations to JavaScript wp_localize_script('eshb-date-range-picker-js', 'eshb_daterangepicker_i18n', $calendar_translations); }