Use WP logic to enqueue Parsley validation strings
[MAILPOET-5118]
This commit is contained in:
@@ -75,6 +75,9 @@ class AssetsController {
|
||||
true
|
||||
);
|
||||
$this->wp->wpSetScriptTranslations($name, 'mailpoet');
|
||||
|
||||
// append Parsley validation string translations
|
||||
$this->wp->wpAddInlineScript($name, $this->renderer->render('parsley-translations.html'));
|
||||
}
|
||||
|
||||
private function registerAdminDeps(): void {
|
||||
|
@@ -206,32 +206,4 @@
|
||||
</script>
|
||||
<% endif %>
|
||||
|
||||
<script>
|
||||
Parsley.addMessages('mailpoet', {
|
||||
defaultMessage: '<%= __("This value seems to be invalid.") %>',
|
||||
type: {
|
||||
email: '<%= __("This value should be a valid email.") %>',
|
||||
url: '<%= __("This value should be a valid url.") %>',
|
||||
number: '<%= __("This value should be a valid number.") %>',
|
||||
integer: '<%= __("This value should be a valid integer.") %>',
|
||||
digits: '<%= __("This value should be digits.") %>',
|
||||
alphanum: '<%= __("This value should be alphanumeric.") %>'
|
||||
},
|
||||
notblank: '<%= __("This value should not be blank.") %>',
|
||||
required: '<%= __("This value is required.") %>',
|
||||
pattern: '<%= __("This value seems to be invalid.") %>',
|
||||
min: '<%= __("This value should be greater than or equal to %s.") %>',
|
||||
max: '<%= __("This value should be lower than or equal to %s.") %>',
|
||||
range: '<%= __("This value should be between %s and %s.") %>',
|
||||
minlength: '<%= __("This value is too short. It should have %s characters or more.") %>',
|
||||
maxlength: '<%= __("This value is too long. It should have %s characters or fewer.") %>',
|
||||
length: '<%= __("This value length is invalid. It should be between %s and %s characters long.") %>',
|
||||
mincheck: '<%= __("You must select at least %s choices.") %>',
|
||||
maxcheck: '<%= __("You must select %s choices or fewer.") %>',
|
||||
check: '<%= __("You must select between %s and %s choices.") %>',
|
||||
equalto: '<%= __("This value should be the same.") %>'
|
||||
});
|
||||
|
||||
Parsley.setLocale('mailpoet');
|
||||
</script>
|
||||
<div id="mailpoet-modal"></div>
|
||||
|
27
mailpoet/views/parsley-translations.html
Normal file
27
mailpoet/views/parsley-translations.html
Normal file
@@ -0,0 +1,27 @@
|
||||
|
||||
Parsley.addMessages('mailpoet', {
|
||||
defaultMessage: '<%= __("This value seems to be invalid.") %>',
|
||||
type: {
|
||||
email: '<%= __("This value should be a valid email.") %>',
|
||||
url: '<%= __("This value should be a valid url.") %>',
|
||||
number: '<%= __("This value should be a valid number.") %>',
|
||||
integer: '<%= __("This value should be a valid integer.") %>',
|
||||
digits: '<%= __("This value should be digits.") %>',
|
||||
alphanum: '<%= __("This value should be alphanumeric.") %>'
|
||||
},
|
||||
notblank: '<%= __("This value should not be blank.") %>',
|
||||
required: '<%= __("This value is required.") %>',
|
||||
pattern: '<%= __("This value seems to be invalid.") %>',
|
||||
min: '<%= __("This value should be greater than or equal to %s.") %>',
|
||||
max: '<%= __("This value should be lower than or equal to %s.") %>',
|
||||
range: '<%= __("This value should be between %s and %s.") %>',
|
||||
minlength: '<%= __("This value is too short. It should have %s characters or more.") %>',
|
||||
maxlength: '<%= __("This value is too long. It should have %s characters or fewer.") %>',
|
||||
length: '<%= __("This value length is invalid. It should be between %s and %s characters long.") %>',
|
||||
mincheck: '<%= __("You must select at least %s choices.") %>',
|
||||
maxcheck: '<%= __("You must select %s choices or fewer.") %>',
|
||||
check: '<%= __("You must select between %s and %s choices.") %>',
|
||||
equalto: '<%= __("This value should be the same.") %>'
|
||||
});
|
||||
|
||||
Parsley.setLocale('mailpoet');
|
Reference in New Issue
Block a user