| 1 |
<?php |
| 2 |
/** |
| 3 |
* Translatable Class file for Sureforms. |
| 4 |
* |
| 5 |
* @package Sureforms |
| 6 |
* @since 1.0.5 |
| 7 |
*/ |
| 8 |
|
| 9 |
namespace SRFM\Inc; |
| 10 |
|
| 11 |
if ( ! defined( 'ABSPATH' ) ) { |
| 12 |
exit; // Exit if accessed directly. |
| 13 |
} |
| 14 |
|
| 15 |
/** |
| 16 |
* Sureforms Translatable Class |
| 17 |
* |
| 18 |
* A helper class providing an interface for handling translation of text elements, specifically |
| 19 |
* frontend validation messages, used in the Sureforms plugin. This class enables dynamic and |
| 20 |
* reusable translated strings to enhance user experience across different languages. |
| 21 |
* |
| 22 |
* @since 1.0.5 |
| 23 |
*/ |
| 24 |
class Translatable { |
| 25 |
/** |
| 26 |
* Retrieve default frontend validation messages. |
| 27 |
* |
| 28 |
* Returns an array of validation messages, each identified by a unique key. Messages are |
| 29 |
* translated for frontend display, with placeholders included for dynamically populated values. |
| 30 |
* |
| 31 |
* @since 1.0.5 |
| 32 |
* @return array<string, string> Associative array of translated validation messages for frontend use. |
| 33 |
*/ |
| 34 |
public static function get_frontend_validation_messages() { |
| 35 |
$translatable_array = [ |
| 36 |
'valid_phone_number' => __( 'Please enter a valid phone number.', 'sureforms' ), |
| 37 |
'valid_url' => __( 'Please enter a valid URL.', 'sureforms' ), |
| 38 |
'confirm_email_same' => __( 'Confirmation email does not match.', 'sureforms' ), |
| 39 |
'valid_email' => __( 'Please enter a valid email address.', 'sureforms' ), |
| 40 |
'confirm_password_same' => __( 'Confirmation password does not match.', 'sureforms' ), |
| 41 |
|
| 42 |
/* translators: %s represents the minimum acceptable value */ |
| 43 |
'input_min_value' => __( 'Minimum value is %s', 'sureforms' ), |
| 44 |
|
| 45 |
/* translators: %s represents the maximum acceptable value */ |
| 46 |
'input_max_value' => __( 'Maximum value is %s', 'sureforms' ), |
| 47 |
|
| 48 |
/* translators: %s represents the minimum number of selections required */ |
| 49 |
'dropdown_min_selections' => __( 'Minimum %s selections are required', 'sureforms' ), |
| 50 |
|
| 51 |
/* translators: %s represents the maximum number of selections allowed */ |
| 52 |
'dropdown_max_selections' => __( 'Maximum %s selections are allowed', 'sureforms' ), |
| 53 |
]; |
| 54 |
|
| 55 |
return apply_filters( 'srfm_frontend_validation_messages', $translatable_array ); |
| 56 |
} |
| 57 |
} |
| 58 |
|