Add translations

[MAILPOET-1798]
This commit is contained in:
Pavel Dohnal
2020-02-04 15:09:03 +01:00
committed by Jack Kitterhing
parent 7f2f4e0296
commit 43f628e580
3 changed files with 12 additions and 7 deletions

View File

@ -23,7 +23,7 @@ function Edit({ attributes, setAttributes }) {
className="mailpoet-block-create-forms-list"
value={attributes.selectedForm}
>
<option value="" disabled selected>Select a MailPoet form</option>
<option value="" disabled selected>{window.locale.selectForm}</option>
{allForms.map((form) => (
<option value={form.id}>
{form.name}
@ -50,7 +50,7 @@ function Edit({ attributes, setAttributes }) {
target="_blank"
className="mailpoet-block-create-new-link"
>
Create a new form
{window.locale.createForm}
</a>
{displayFormsSelect()}
</div>
@ -70,7 +70,7 @@ function Edit({ attributes, setAttributes }) {
<Placeholder
className="mailpoet-block-create-new"
icon={<BlockIcon icon={Icon} showColors />}
label="MailPoet Subscription Form"
label={window.locale.subscriptionForm}
>
{selectFormSettings()}
</Placeholder>

View File

@ -5,7 +5,7 @@ const wp = window.wp;
const { registerBlockType } = wp.blocks;
registerBlockType('mailpoet/form-block', {
title: 'MailPoet Subscription Form',
title: window.locale.subscriptionForm,
icon: Icon,
category: 'widgets',
example: {},

View File

@ -72,7 +72,12 @@ class PostEditorBlock {
$forms = $this->formsRepository->findAllNotDeleted();
?>
<script type="text/javascript">
window.mailpoet_forms =<?php echo json_encode($forms) ?>;
window.mailpoet_forms = <?php echo json_encode($forms) ?>;
window.locale = {
selectForm: '<?php echo __('Select a MailPoet form', 'mailpoet') ?>',
createForm: '<?php echo __('Create a new form', 'mailpoet') ?>',
subscriptionForm: '<?php echo __('MailPoet Subscription Form', 'mailpoet') ?>',
};
</script>
<?php
});
@ -85,12 +90,12 @@ class PostEditorBlock {
}
public function renderForm($attributes) {
if (!$attributes || !isset($attributes['selectedForm'])) {
if (!$attributes || !isset($attributes['form'])) {
return '';
}
$basicForm = new Widget();
return $basicForm->widget([
'form' => (int)$attributes['selectedForm'],
'form' => (int)$attributes['form'],
'form_type' => 'html',
]);
}